diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..8acba3c --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +tests/output/ diff --git a/README.md b/README.md index ba8c3a6..1606037 100644 --- a/README.md +++ b/README.md @@ -28,3 +28,4 @@ and configure the app differently for each target. | [helm-external](multi-cluster/helm-external/) | A full example of using a Helm chart that is downloaded from a third party source and customizing it per target cluster | | [kustomize](multi-cluster/kustomize/) | A full example of using Kustomize and customizing it per target cluster | | [helm-kustomize](multi-cluster/helm-kustomize/) | A full example of using Kustomize to modify a third party Helm chart | +| [windows-helm](multi-cluster/windows-helm/) | A full example of using Helm for Windows cluster(s) diff --git a/windows-helm/Chart.yaml b/multi-cluster/windows-helm/Chart.yaml similarity index 100% rename from windows-helm/Chart.yaml rename to multi-cluster/windows-helm/Chart.yaml diff --git a/multi-cluster/windows-helm/README.md b/multi-cluster/windows-helm/README.md new file mode 100644 index 0000000..3a9e7d2 --- /dev/null +++ b/multi-cluster/windows-helm/README.md @@ -0,0 +1,47 @@ +# 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. +This must be deployed in a multi-cluster configuration. + +## Preparing Your Downstream Cluster(s) + +Clusters (`clusters.fleet.cattle.io`) must have the `windows.version` label in order for the example to be deployed. +You can determine the value for the `windows.version` label key based on the release version of your Windows node(s). + +Description | Example +--- | --- +For Windows Server SAC nodes, the value will be the SAC release number prepended with "win". | 2004 SAC would result in `windows.version: win2004` +For Windows Server LTSC nodes, the value will be the SAC release number that the LTSC is based on. | 2019 LTSC would result in `windows.version: win1809` + +## Creating the GitRepo + +Create the following `GitRepo` in your local cluster to get started. + +```yaml +kind: GitRepo +apiVersion: fleet.cattle.io/v1alpha1 +metadata: + name: helm + namespace: fleet-default +spec: + repo: https://github.com/rancher/fleet-examples + paths: + - multi-cluster/windows-helm + targets: + - name: win2004 + clusterSelector: + matchLabels: + windows.version: win2004 + - name: win1909 + clusterSelector: + matchLabels: + windows.version: win1909 + - name: win1903 + clusterSelector: + matchLabels: + windows.version: win1903 + - name: win1809 + clusterSelector: + matchLabels: + windows.version: win1809 +``` diff --git a/multi-cluster/windows-helm/fleet.yaml b/multi-cluster/windows-helm/fleet.yaml new file mode 100644 index 0000000..10cb63f --- /dev/null +++ b/multi-cluster/windows-helm/fleet.yaml @@ -0,0 +1,34 @@ +namespace: fleet-helm-windows-example +targetCustomizations: +- name: win2004 + helm: + values: + image: + tag: 2004 + clusterSelector: + matchLabels: + windows.version: win2004 +- name: win1909 + helm: + values: + image: + tag: 1909 + clusterSelector: + matchLabels: + windows.version: win1909 +- name: win1903 + helm: + values: + image: + tag: 1903 + clusterSelector: + matchLabels: + windows.version: win1903 +- name: win1809 + helm: + values: + image: + tag: 1809 + clusterSelector: + matchLabels: + windows.version: win1809 diff --git a/windows-helm/templates/windows.yaml b/multi-cluster/windows-helm/templates/windows.yaml similarity index 100% rename from windows-helm/templates/windows.yaml rename to multi-cluster/windows-helm/templates/windows.yaml diff --git a/windows-helm/values.yaml b/multi-cluster/windows-helm/values.yaml similarity index 100% rename from windows-helm/values.yaml rename to multi-cluster/windows-helm/values.yaml diff --git a/tests/test.sh b/tests/test.sh index a2d66ad..78ad4ad 100755 --- a/tests/test.sh +++ b/tests/test.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash set -e export COMMIT=fake @@ -7,6 +7,17 @@ cd $(dirname $0) rm -rf output +FLEET_PATH=fleet +if ! [ $(command -v fleet) ]; then + printf "Not found in PATH: fleet\n" + read -p "Specify path to fleet binary (leave blank to exit): " TEMP_FLEET_PATH + if ! [ $TEMP_FLEET_PATH ]; then + exit 0 + fi + FLEET_PATH=$(realpath $TEMP_FLEET_PATH) + printf "Path to fleet binary: $FLEET_PATH\n" +fi + for i in ../single-cluster/*; do if [ ! -d $i ]; then continue @@ -14,8 +25,8 @@ for i in ../single-cluster/*; do pushd $i for j in dev test prod; do mkdir -p ../../tests/output/garbage/${i} - fleet test > ../../tests/output/garbage/${i}/${j}-output.yaml - fleet apply -o - test > ../../tests/output/garbage/${i}/bundle.yaml + eval $FLEET_PATH test > ../../tests/output/garbage/${i}/${j}-output.yaml + eval $FLEET_PATH apply -o - test > ../../tests/output/garbage/${i}/bundle.yaml done popd done @@ -27,8 +38,8 @@ for i in ../multi-cluster/*; do pushd $i for j in dev test prod; do mkdir -p ../../tests/output/garbage/${i} - fleet test -l env=${j} > ../../tests/output/garbage/${i}/${j}-output.yaml - fleet apply -n fleet-default -o - test > ../../tests/output/garbage/${i}/bundle.yaml + eval $FLEET_PATH test -l env=${j} > ../../tests/output/garbage/${i}/${j}-output.yaml + eval $FLEET_PATH apply -n fleet-default -o - test > ../../tests/output/garbage/${i}/bundle.yaml done popd done diff --git a/windows-helm/README.md b/windows-helm/README.md deleted file mode 100644 index 4aed638..0000000 --- a/windows-helm/README.md +++ /dev/null @@ -1,15 +0,0 @@ -# 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 deleted file mode 100644 index ac7e7ed..0000000 --- a/windows-helm/fleet.yaml +++ /dev/null @@ -1,33 +0,0 @@ -# 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