Skip to content

Instantly share code, notes, and snippets.

@jldeen
Last active December 30, 2019 11:28
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jldeen/e18cb7453bf8814565f5a5ffdc740065 to your computer and use it in GitHub Desktop.
Save jldeen/e18cb7453bf8814565f5a5ffdc740065 to your computer and use it in GitHub Desktop.
KubeCon North America Kubernetes: Windows Apps with Draft and Helm

Deploying Windows Apps with Draft, Helm, and Kubernetes

Scroll all the way down for more resources

Slides

Deploying Windows Apps with Draft, Helm, and Kubernetes

Get involved

Microsoft Azure Resources

Demo Resources

Other helpful resources (may be more focused on Linux containers, but still useful)

Dotfiles

Other links

Contact Information

Let's stay in touch!

# Modern CI/CD DevOps EXAMPLE BUILD Pipeline via Codefresh
# This demo should run on either Windows 2016 (1803 or 1809), but the build server will have to match the Windows kernel version your windows/linux cluster is running. In this case, my Codefresh build server was running Windows 2016 so I deployed to a 1803 (2016) hybrid cluster
# This yaml is provided only as an example to get started. You *may* have to update certain variables and fields according to your environment
# This demo run on either Windows 2016 (1803 or 1809), but the build server will have to match the Windows kernel version your windows/linux cluster is running. In this case, my Codefresh build server was running Windows 2016 so I deployed to a 1803 (2016 hybrid cluster)
# GitHub Repo used: https://github.com/jldeen/eShopOnWeb/tree/patricklang/k8s-win
# Dockerfile link: https://github.com/jldeen/eShopOnWeb/blob/patricklang/k8s-win/src/WebRazorPages/Dockerfile
# Docker build context: .
version: '1.0'
steps:
BuildingDockerImage:
title: Building Docker Image
type: build
image_name: kubecon18/eshopweb
working_directory: ./
dockerfile: src/WebRazorPages/Dockerfile
tag: '${{CF_BRANCH_TAG_NORMALIZED}}-${{CF_SHORT_REVISION}}'
PushingDockerImage:
title: Promote to Azure Container Registry
type: push
candidate: ${{BuildingDockerImage}}
image_name: kubecon18/eshopweb
tag: '${{CF_BRANCH_TAG_NORMALIZED}}-${{CF_SHORT_REVISION}}'
registry: acrjdk8s
### For registry reference, I pre-added my azurecr registry and named it 'acrjdk8s' to my Codefresh account. The "registry: acrjdk8s" is a reference to that.
# Modern CI/CD DevOps EXAMPLE DEPLOY Pipeline via Codefresh
# This demo should run on either Windows 2016 (1803 or 1809), but the build server will have to match the Windows kernel version your windows/linux cluster is running. In this case, my Codefresh build server was running Windows 2016 so I deployed to a 1803 (2016 hybrid cluster)
# This yaml is provided only as an example to get started. You *may* have to update certain variables and fields according to your environment
# Examples of variables you will need to create are:
## - KUBE_CONTEXT
## - CHART_NAME
## - RELEASE_NAME
## - NAMESPACE
# GitHub Repo used: https://github.com/jldeen/eShopOnWeb/tree/patricklang/k8s-win
version: '1.0'
steps:
PackageHelmChart:
image: devth/helm
commands:
- cf_export PACKAGE=$(helm package .charts/eShopOnWeb | cut -d " " -f 8)
Deploy_with_Helm:
image: codefresh/cfstep-helm:2.11.0
when:
branch:
only:
- patricklang/k8s-win
environment:
- custom_commit_sha=${{CF_SHORT_REVISION}}
- custom_image_repository=acr-reg-here.azurecr.io/kubecon18/eshopweb
- custom_image_tag=${{CF_BRANCH_TAG_NORMALIZED}}-${{CF_SHORT_REVISION}}
# Traditional CI/CD DevOps EXAMPLE BUILD Pipeline via Azure Pipelines via Azure DevOps
# This yaml is provided only as an example to get started. You will have to update certain variables and fields according to your environment
# This build pipeline references an undefined variable named ‘Parameters.solution’. Create or edit the build pipeline for this YAML file, define the variable on the Variables tab. See https://go.microsoft.com/fwlink/?linkid=865972
# GitHub Repo used: https://github.com/jldeen/fabrikamfiber/tree/helm-2019-mssql-linux
# Dockerfile link: https://github.com/jldeen/fabrikamfiber/blob/helm-2019-mssql-linux/FabrikamFiber.Web/Dockerfile
resources:
- repo: self
queue:
name: Default #self-hosted agent with Windows Server 2019 with Containers Support, Visual Studio and Docker installed
demands:
- msbuild
- visualstudio
variables:
BuildPlatform: 'Any CPU'
BuildConfiguration: 'Release'
Parameters.solution:
steps:
- task: NuGetToolInstaller@0
displayName: 'Use NuGet 4.4.1'
inputs:
versionSpec: 4.4.1
- task: NuGetCommand@2
displayName: 'NuGet restore'
inputs:
restoreSolution: '$(Parameters.solution)'
- task: VSBuild@1
displayName: 'Build solution **\*.sln'
inputs:
solution: '$(Parameters.solution)'
msbuildArgs: '/p:PublishProfile=FolderProfile /p:DeployOnBuild=true'
platform: '$(BuildPlatform)'
configuration: '$(BuildConfiguration)'
clean: true
- task: Docker@1
displayName: 'Build an image'
inputs:
azureSubscriptionEndpoint: 'az-sub-here'
azureContainerRegistry: acr-reg-here.azurecr.io
dockerFile: FabrikamFiber.Web/Dockerfile
- task: Docker@1
displayName: 'Push an image'
inputs:
azureSubscriptionEndpoint: 'az-sub-here'
azureContainerRegistry: acr-reg-here.azurecr.io
command: 'Push an image'
- task: HelmInstaller@0
displayName: 'Install Helm 2.11.0'
inputs:
helmVersion: 2.11.0
- task: HelmDeploy@0
displayName: 'helm init'
inputs:
connectionType: 'Kubernetes Service Connection'
kubernetesServiceConnection: kubecon2019
command: init
arguments: '--client-only'
- task: HelmDeploy@0
displayName: 'helm package'
inputs:
command: package
chartPath: charts/fabrikamfiber
- task: PublishBuildArtifacts@1
displayName: 'Publish Artifact: drop'
### Yaml for Azure Pipelines is currently only supported for build. See below for markdown file for what is needed for release/deploy

Traditional Windows K8s release for traditional ASP.net application with traditional_wink8s_devops_build.yaml

GitHub Repo used for both build (see yaml) and release (deploy): https://github.com/jldeen/fabrikamfiber/tree/helm-2019-mssql-linux Dockerfile direct link: https://github.com/jldeen/fabrikamfiber/blob/helm-2019-mssql-linux/FabrikamFiber.Web/Dockerfile

The following tasks can run on Windows or Linux hosted (or private) agent.

You will need to add 3 tasks:

  1. Install Helm via the Helm tool installer (I used version 2.11.0 and made sure to UNCHECK "Check for latest version of Helm" since my cluster was using 2.11.0. If you do not uncheck this, Azure DevOps will download 2.12.0 and you will have a client server mismatch)

  2. Helm init (with --client-only as an arguement) via the Package and deploy Helm charts task

  3. Helm upgrade via the Package and deploy Helm charts task

    • Ensure you add in a connection to a valid hybrid windows/linux cluster running Windows 1809
    • I used the release name "eshop"
    • I used the following values override in the Arguments section:
      • --set image.repository=acr-reg-here.azurecr.io/jldeen/eshoponweb --set image.tag=$(Build.BuildId)

Note: These steps are the same you would use to deploy to K8s via helm in a standard Linux containers scenario

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment