diff --git a/windows-helm/Chart.yaml b/windows-helm/Chart.yaml new file mode 100644 index 0000000..6f4f0cf --- /dev/null +++ b/windows-helm/Chart.yaml @@ -0,0 +1,5 @@ +apiVersion: v2 +name: windows-app +description: Sample Windows application +version: 0.0.0 +appVersion: 0.0.0 diff --git a/windows-helm/README.md b/windows-helm/README.md new file mode 100644 index 0000000..4aed638 --- /dev/null +++ b/windows-helm/README.md @@ -0,0 +1,15 @@ +# Windows Helm Example + +This example will deploy the [Windows application example](https://kubernetes.io/docs/setup/production-environment/windows/user-guide-windows-containers/) packaged as a Helm chart. + +```yaml +kind: GitRepo +apiVersion: fleet.cattle.io/v1alpha1 +metadata: + name: helm + namespace: fleet-local +spec: + repo: https://github.com/rancher/fleet-examples + paths: + - windows-helm +``` diff --git a/windows-helm/fleet.yaml b/windows-helm/fleet.yaml new file mode 100644 index 0000000..ac7e7ed --- /dev/null +++ b/windows-helm/fleet.yaml @@ -0,0 +1,33 @@ +# This file and all contents in it are OPTIONAL. + +# The namespace this chart will be installed and restricted to, +# if not specified the chart will be installed to "default" +namespace: fleet-helm-windows-example + +# Custom helm options +helm: + # The release name to use. If empty a generated release name will be used + releaseName: windows-app + + # The directory of the chart in the repo. Also any valid go-getter supported + # URL can be used there is specify where to download the chart from. + # If repo below is set this value if the chart name in the repo + chart: "" + + # An https to a valid Helm repository to download the chart from + repo: "" + + # Used if repo is set to look up the version of the chart + version: "" + + # Force recreate resource that can not be updated + force: false + + # How long for helm to wait for the release to be active. If the value + # is less that or equal to zero, we will not wait in Helm + timeoutSeconds: 0 + + # Custom values that will be passed as values.yaml to the installation + values: + image: + tag: 2004 diff --git a/windows-helm/templates/windows.yaml b/windows-helm/templates/windows.yaml new file mode 100644 index 0000000..5f62af3 --- /dev/null +++ b/windows-helm/templates/windows.yaml @@ -0,0 +1,47 @@ +# Source: https://kubernetes.io/docs/setup/production-environment/windows/user-guide-windows-containers/ +apiVersion: v1 +kind: Service +metadata: + name: win-webserver + labels: + app: win-webserver +spec: + ports: + # the port that this service should serve on + - port: 80 + targetPort: 80 + selector: + app: win-webserver + type: NodePort +--- +apiVersion: apps/v1 +kind: Deployment +metadata: + labels: + app: win-webserver + name: win-webserver +spec: + replicas: 2 + selector: + matchLabels: + app: win-webserver + template: + metadata: + labels: + app: win-webserver + name: win-webserver + spec: + containers: + - name: windowswebserver + image: "mcr.microsoft.com/windows/servercore:{{ .Values.image.tag }}" + command: + - powershell.exe + - -command + - "<#code used from https://gist.github.com/19WAS85/5424431#> ; $$listener = New-Object System.Net.HttpListener ; $$listener.Prefixes.Add('http://*:80/') ; $$listener.Start() ; $$callerCounts = @{} ; Write-Host('Listening at http://*:80/') ; while ($$listener.IsListening) { ;$$context = $$listener.GetContext() ;$$requestUrl = $$context.Request.Url ;$$clientIP = $$context.Request.RemoteEndPoint.Address ;$$response = $$context.Response ;Write-Host '' ;Write-Host('> {0}' -f $$requestUrl) ; ;$$count = 1 ;$$k=$$callerCounts.Get_Item($$clientIP) ;if ($$k -ne $$null) { $$count += $$k } ;$$callerCounts.Set_Item($$clientIP, $$count) ;$$ip=(Get-NetAdapter | Get-NetIpAddress); $$header='

Windows Container Web Server

' ;$$callerCountsString='' ;$$callerCounts.Keys | % { $$callerCountsString+='

IP {0} callerCount {1} ' -f $$ip[1].IPAddress,$$callerCounts.Item($$_) } ;$$footer='' ;$$content='{0}{1}{2}' -f $$header,$$callerCountsString,$$footer ;Write-Output $$content ;$$buffer = [System.Text.Encoding]::UTF8.GetBytes($$content) ;$$response.ContentLength64 = $$buffer.Length ;$$response.OutputStream.Write($$buffer, 0, $$buffer.Length) ;$$response.Close() ;$$responseStatus = $$response.StatusCode ;Write-Host('< {0}' -f $$responseStatus) } ; " + nodeSelector: + kubernetes.io/os: windows + tolerations: + - key: cattle.io/os + operator: "Equal" + value: "windows" + effect: NoSchedule diff --git a/windows-helm/values.yaml b/windows-helm/values.yaml new file mode 100644 index 0000000..38239ed --- /dev/null +++ b/windows-helm/values.yaml @@ -0,0 +1,2 @@ +image: + tag: 2004