Add Windows helm example

This commit is contained in:
Nick Gerace
2021-02-04 09:47:25 -05:00
parent c6e54d7a56
commit 5be7ae7e98
5 changed files with 102 additions and 0 deletions

5
windows-helm/Chart.yaml Normal file
View File

@@ -0,0 +1,5 @@
apiVersion: v2
name: windows-app
description: Sample Windows application
version: 0.0.0
appVersion: 0.0.0

15
windows-helm/README.md Normal file
View File

@@ -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
```

33
windows-helm/fleet.yaml Normal file
View File

@@ -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

View File

@@ -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='<html><body><H1>Windows Container Web Server</H1>' ;$$callerCountsString='' ;$$callerCounts.Keys | % { $$callerCountsString+='<p>IP {0} callerCount {1} ' -f $$ip[1].IPAddress,$$callerCounts.Item($$_) } ;$$footer='</body></html>' ;$$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

2
windows-helm/values.yaml Normal file
View File

@@ -0,0 +1,2 @@
image:
tag: 2004