From 7d946008ee556b9b2444429a1c9c6e2bdb72c7dc Mon Sep 17 00:00:00 2001 From: Bertrand Thomas Date: Thu, 10 Aug 2023 17:20:44 +0200 Subject: [PATCH 1/5] Update Outscale Rancher cluster template --- .../rancher-cluster-templates/CONTRIBUTING.md | 22 +++++++++++-- .../rancher-cluster-templates/docs/azure.md | 2 ++ .../examples/values_outscale.yaml | 8 +++++ .../templates/outscaleconfig.yaml | 32 ++++++++----------- charts/rancher-cluster-templates/values.yaml | 11 ++++--- 5 files changed, 48 insertions(+), 27 deletions(-) diff --git a/charts/rancher-cluster-templates/CONTRIBUTING.md b/charts/rancher-cluster-templates/CONTRIBUTING.md index f4da9d1..9068d48 100644 --- a/charts/rancher-cluster-templates/CONTRIBUTING.md +++ b/charts/rancher-cluster-templates/CONTRIBUTING.md @@ -14,7 +14,7 @@ helm template my-cluster . -f values.yaml -f values_mine.yaml --namespace fleet- 💡 This commands must be run on the Kubernetes cluster hosting Rancher (called `local` by default). -### Example with a cluster on Azure +### Azure example ```bash # copies the example @@ -25,10 +25,26 @@ sed -i "s/AZURE_PREFIX/$USER-$resourcekey/g" values_mine.yaml sed -i "s/CLOUD_CREDENTIAL_SECRET//g" values_mine.yaml # runs the installation with Helm -helm upgrade --install rke2-azure-cluster01 . -f values.yaml -f values_mine.yaml --namespace fleet-default +helm upgrade --install rke2-azure01 . -f values.yaml -f values_mine.yaml --namespace fleet-default # removes the installation -helm uninstall rke2-azure-cluster01 -n fleet-default +helm uninstall rke2-azure01 -n fleet-default +``` + +### Outscale example + +```bash +# copies the example +cp examples/values_outscale.yaml values_mine.yaml +resourcekey=$(openssl rand -hex 6) +sed -i "s/CLUSTER_NAME/az-rke2-$resourcekey/g" values_mine.yaml +sed -i "s/CLOUD_CREDENTIAL_SECRET//g" values_mine.yaml + +# runs the installation with Helm +helm upgrade --install rke2-outscale01 . -f values.yaml -f values_mine.yaml --namespace fleet-default + +# removes the installation +helm uninstall rke2-outscale01 -n fleet-default ``` ## How to troubleshoot diff --git a/charts/rancher-cluster-templates/docs/azure.md b/charts/rancher-cluster-templates/docs/azure.md index 69b6f86..a0086cd 100644 --- a/charts/rancher-cluster-templates/docs/azure.md +++ b/charts/rancher-cluster-templates/docs/azure.md @@ -3,6 +3,8 @@ ## Design * [Availability sets overview](https://learn.microsoft.com/en-us/azure/virtual-machines/availability-set-overview) +* [Azure Virtual Network concepts and best practices](https://learn.microsoft.com/en-us/azure/virtual-network/concepts-and-best-practices) +* [General purpose virtual machine sizes](https://learn.microsoft.com/en-us/azure/virtual-machines/sizes-general) ## Configuration diff --git a/charts/rancher-cluster-templates/examples/values_outscale.yaml b/charts/rancher-cluster-templates/examples/values_outscale.yaml index 880f211..9f9c7dc 100644 --- a/charts/rancher-cluster-templates/examples/values_outscale.yaml +++ b/charts/rancher-cluster-templates/examples/values_outscale.yaml @@ -5,6 +5,8 @@ cloudprovider: outscale cloudCredentialSecretName: CLOUD_CREDENTIAL_SECRET +kubernetesVersion: "v1.25.10+k3s1" + nodepools: - etcd: true controlplane: true @@ -13,3 +15,9 @@ nodepools: taints: {} quantity: 1 name: nodepool-1 + region: eu-west-2 + machineImage: ami-cd8d714e + instanceType: tinav5.c3r4p1 + # storageType: "gp2" + # diskSize: "15" + # diskIops: "1500" diff --git a/charts/rancher-cluster-templates/templates/outscaleconfig.yaml b/charts/rancher-cluster-templates/templates/outscaleconfig.yaml index 0751bf2..04ffbdd 100644 --- a/charts/rancher-cluster-templates/templates/outscaleconfig.yaml +++ b/charts/rancher-cluster-templates/templates/outscaleconfig.yaml @@ -7,31 +7,25 @@ kind: OutscaleConfig metadata: name: {{ $nodepool.name }} namespace: default - # annotations: - # key: string -{{- if $nodepool.labels }} + {{- if $nodepool.annotations }} + annotations: + {{- toYaml $nodepool.annotations | indent 4 }} + {{- end }} + {{- if $nodepool.labels }} labels: -{{ toYaml $nodepool.labels | indent 4 }} -{{- end }} + {{- toYaml $nodepool.labels | indent 4 }} + {{- end }} # accessKey: string -# extraTagsAll: -# - string -# extraTagsInstances: -# - string -{{- if $nodepool.instanceType }} +extraTagsAll: [] +extraTagsInstances: [] instanceType: {{ $nodepool.instanceType }} -{{- end }} -{{- if $nodepool.region }} region: {{ $nodepool.region }} -{{- end }} -# rootDiskIops: string -# rootDiskSize: string -# rootDiskType: string +rootDiskIops: "{{ default "1500" $nodepool.diskIops }}" +rootDiskSize: "{{ default "15" $nodepool.diskSize }}" +rootDiskType: {{ default "gp2" $nodepool.storageType }} # secretKey: string # securityGroupIds: # - string -{{- if $nodepool.sourceOmi }} -sourceOmi: {{ $nodepool.sourceOmi }} -{{- end }} +sourceOmi: {{ $nodepool.machineImage }} {{- end }} {{- end }} diff --git a/charts/rancher-cluster-templates/values.yaml b/charts/rancher-cluster-templates/values.yaml index a3ff4ea..54bbfe0 100644 --- a/charts/rancher-cluster-templates/values.yaml +++ b/charts/rancher-cluster-templates/values.yaml @@ -50,13 +50,14 @@ nodepools: [] # maxUnavailable: "5" # machineDeploymentAnnotations: {} # machineDeploymentLabels: {} - # region: "" # AWS, Azure - # machineImage: "" # AWS, Azure - # instanceType: "" # AWS, Azure - # storageType: "" # AWS, Azure + # region: "" # AWS, Azure, Outscale + # machineImage: "" # AWS, Azure, Outscale + # instanceType: "" # AWS, Azure, Outscale + # storageType: "" # AWS, Azure, Outscale # sshUser: "" # AWS, Azure # openPorts: # AWS, Azure # - 42/tcp + # diskSize: "30" # Azure, Outscale # blockDurationMinutes: 0 # AWS spot instance duration in minutes (60, 120, 180, 240, 300, or 360) # deviceName: "/dev/sda1" # AWS root device name # encryptEbsVolume: false # AWS Encrypt the EBS volume using the AWS Managed CMK @@ -84,7 +85,6 @@ nodepools: [] # availabilitySet: "avs-AZURE_PREFIX" # Azure only # azureEnvironment: AzurePublicCloud # Azure only # customData: "" # Azure only - # diskSize: "30" # Azure only # dockerPort: "2376" # Azure only # faultDomainCount: "3" # Azure only # managedDisks: true # Azure only @@ -98,3 +98,4 @@ nodepools: [] # updateDomainCount: "5" # Azure only # usePrivateIp: false # Azure only # virtualNetwork: "vnet-AZURE_PREFIX" # Azure only + # diskIops: "1500" # Cloudscale only From 004e44f1c0586a0a1fd2ad4e79a9575d03477fee Mon Sep 17 00:00:00 2001 From: Bertrand Thomas Date: Wed, 16 Aug 2023 18:05:39 +0200 Subject: [PATCH 2/5] Fix wrong namespace --- .../rancher-cluster-templates/templates/cloudscaleconfig.yaml | 2 +- charts/rancher-cluster-templates/templates/exoscaleconfig.yaml | 2 +- charts/rancher-cluster-templates/templates/linodeconfig.yaml | 2 +- charts/rancher-cluster-templates/templates/nutanixconfig.yaml | 2 +- charts/rancher-cluster-templates/templates/outscaleconfig.yaml | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/charts/rancher-cluster-templates/templates/cloudscaleconfig.yaml b/charts/rancher-cluster-templates/templates/cloudscaleconfig.yaml index 855ff6e..396ba49 100644 --- a/charts/rancher-cluster-templates/templates/cloudscaleconfig.yaml +++ b/charts/rancher-cluster-templates/templates/cloudscaleconfig.yaml @@ -6,7 +6,7 @@ apiVersion: rke-machine-config.cattle.io/v1 kind: CloudscaleConfig metadata: name: {{ $nodepool.name }} - namespace: default + namespace: fleet-default # annotations: # key: string {{- if $nodepool.labels }} diff --git a/charts/rancher-cluster-templates/templates/exoscaleconfig.yaml b/charts/rancher-cluster-templates/templates/exoscaleconfig.yaml index d29fc74..2947fc9 100644 --- a/charts/rancher-cluster-templates/templates/exoscaleconfig.yaml +++ b/charts/rancher-cluster-templates/templates/exoscaleconfig.yaml @@ -6,7 +6,7 @@ apiVersion: rke-machine-config.cattle.io/v1 kind: ExoscaleConfig metadata: name: {{ $nodepool.name }} - namespace: default + namespace: fleet-default # annotations: # key: string {{- if $nodepool.labels }} diff --git a/charts/rancher-cluster-templates/templates/linodeconfig.yaml b/charts/rancher-cluster-templates/templates/linodeconfig.yaml index 256c4e2..e26cfef 100644 --- a/charts/rancher-cluster-templates/templates/linodeconfig.yaml +++ b/charts/rancher-cluster-templates/templates/linodeconfig.yaml @@ -6,7 +6,7 @@ apiVersion: rke-machine-config.cattle.io/v1 kind: LinodeConfig metadata: name: {{ $nodepool.name }} - namespace: default + namespace: fleet-default # annotations: # key: string {{- if $nodepool.labels }} diff --git a/charts/rancher-cluster-templates/templates/nutanixconfig.yaml b/charts/rancher-cluster-templates/templates/nutanixconfig.yaml index e03a575..06d12ac 100644 --- a/charts/rancher-cluster-templates/templates/nutanixconfig.yaml +++ b/charts/rancher-cluster-templates/templates/nutanixconfig.yaml @@ -6,7 +6,7 @@ apiVersion: rke-machine-config.cattle.io/v1 kind: NutanixConfig metadata: name: {{ $nodepool.name }} - namespace: default + namespace: fleet-default # annotations: # key: string {{- if $nodepool.labels }} diff --git a/charts/rancher-cluster-templates/templates/outscaleconfig.yaml b/charts/rancher-cluster-templates/templates/outscaleconfig.yaml index 04ffbdd..1d59344 100644 --- a/charts/rancher-cluster-templates/templates/outscaleconfig.yaml +++ b/charts/rancher-cluster-templates/templates/outscaleconfig.yaml @@ -6,7 +6,7 @@ apiVersion: rke-machine-config.cattle.io/v1 kind: OutscaleConfig metadata: name: {{ $nodepool.name }} - namespace: default + namespace: fleet-default {{- if $nodepool.annotations }} annotations: {{- toYaml $nodepool.annotations | indent 4 }} From 855a4b1eb00337b23fb9a0b26f0f4e43c69a831a Mon Sep 17 00:00:00 2001 From: Bertrand Thomas Date: Wed, 16 Aug 2023 18:06:04 +0200 Subject: [PATCH 3/5] Dump version to 0.1.2 --- charts/rancher-cluster-templates/Chart.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/charts/rancher-cluster-templates/Chart.yaml b/charts/rancher-cluster-templates/Chart.yaml index 9627ad8..83786e4 100644 --- a/charts/rancher-cluster-templates/Chart.yaml +++ b/charts/rancher-cluster-templates/Chart.yaml @@ -2,7 +2,7 @@ apiVersion: v2 name: rancher-cluster-templates description: Helm chart for managing Rancher cluster templates type: application -version: "0.1.1" +version: "0.1.2" appVersion: "0.1.0" annotations: catalog.cattle.io/type: cluster-template From f93d92a6f6dda99d78dc70fffddc35cda0e3772b Mon Sep 17 00:00:00 2001 From: Bertrand Thomas Date: Thu, 17 Aug 2023 14:52:49 +0200 Subject: [PATCH 4/5] Add default values for Rancher cluster template --- .../templates/cluster.yaml | 29 +++++++++++-------- 1 file changed, 17 insertions(+), 12 deletions(-) diff --git a/charts/rancher-cluster-templates/templates/cluster.yaml b/charts/rancher-cluster-templates/templates/cluster.yaml index 5cb1837..3a6446c 100644 --- a/charts/rancher-cluster-templates/templates/cluster.yaml +++ b/charts/rancher-cluster-templates/templates/cluster.yaml @@ -32,10 +32,12 @@ spec: kubernetesVersion: {{ .Values.kubernetesVersion }} {{- end }} localClusterAuthEndpoint: - enabled: {{ .Values.rke.localClusterAuthEndpoint.enabled }} {{- if .Values.rke.localClusterAuthEndpoint.enabled }} + enabled: {{ .Values.rke.localClusterAuthEndpoint.enabled }} fqdn: {{ .Values.rke.localClusterAuthEndpoint.fqdn }} caCerts: {{ .Values.rke.localClusterAuthEndpoint.caCerts }} + {{- else }} + {} {{- end }} # redeploySystemAgentGeneration: integer rkeConfig: @@ -134,7 +136,9 @@ spec: # maxUnhealthy: string # nodeStartupTimeout: string name: {{ $nodepool.name }} + {{- if $nodepool.paused }} paused: {{ $nodepool.paused }} + {{- end }} quantity: {{ $nodepool.quantity }} {{- if $nodepool.rollingUpdate }} rollingUpdate: @@ -188,29 +192,30 @@ spec: controlPlaneConcurrency: "10%" controlPlaneDrainOptions: enabled: false - # deleteEmptyDirData: boolean - # disableEviction: boolean - # gracePeriod: integer + deleteEmptyDirData: false + disableEviction: false + force: false + gracePeriod: 0 # ignoreDaemonSets: boolean # ignoreErrors: boolean # postDrainHooks: # - annotation: string # preDrainHooks: # - annotation: string - # skipWaitForDeleteTimeoutSeconds: integer - # timeout: integer + skipWaitForDeleteTimeoutSeconds: 0 + timeout: 0 workerConcurrency: "10%" workerDrainOptions: enabled: false - # deleteEmptyDirData: boolean - # disableEviction: boolean - # force: boolean - # gracePeriod: integer + deleteEmptyDirData: false + disableEviction: false + force: false + gracePeriod: 0 # ignoreDaemonSets: boolean # ignoreErrors: boolean # postDrainHooks: # - annotation: string # preDrainHooks: # - annotation: string - # skipWaitForDeleteTimeoutSeconds: integer - # timeout: integer + skipWaitForDeleteTimeoutSeconds: 0 + timeout: 0 From 77c9ac704f34f0db38bbbe25fada8fc35150585b Mon Sep 17 00:00:00 2001 From: Bertrand Thomas Date: Thu, 17 Aug 2023 16:44:48 +0200 Subject: [PATCH 5/5] Updates --- charts/rancher-cluster-templates/README.md | 86 ++++++++++++++++---- charts/rancher-cluster-templates/values.yaml | 2 +- 2 files changed, 70 insertions(+), 18 deletions(-) diff --git a/charts/rancher-cluster-templates/README.md b/charts/rancher-cluster-templates/README.md index d47ec8f..a2542c9 100644 --- a/charts/rancher-cluster-templates/README.md +++ b/charts/rancher-cluster-templates/README.md @@ -1,6 +1,6 @@ # Helm chart for Rancher cluster templates -This Helm chart will create a Kubernetes cluster from Rancher through [Cluster Templates](https://ranchermanager.docs.rancher.com/how-to-guides/new-user-guides/manage-clusters/manage-cluster-templates). +This Helm chart gives the possibility to create and manage a Kubernetes cluster from Rancher thanks to [Rancher Cluster Templates](https://ranchermanager.docs.rancher.com/how-to-guides/new-user-guides/manage-clusters/manage-cluster-templates). ## Usage @@ -21,8 +21,6 @@ helm upgrade --install my-cluster rancher-cluster-templates -f values.yaml --nam helm uninstall my-cluster -n fleet-default ``` -## Configuration - ### Infrastructure providers 💡 Node driver must be enabled in Rancher prior to Helm chart installation @@ -30,7 +28,7 @@ helm uninstall my-cluster -n fleet-default Provider | Example | Template | Node Driver ---------------------------------|----------------------------------------------------------|---------------------------------------------------------|---------------- **Amazon Web Services (AWS)** | [values_aws](examples/values_aws.yaml) | [amazonec2config](templates/amazonec2config.yaml) | `Amazon EC2` -**Azure** | [values_azure](examples/values_azure.yaml) | [azureconfig](templates/azureconfig.yaml) | `Azure` +[**Azure**](docs/azure.md) | [values_azure](examples/values_azure.yaml) | [azureconfig](templates/azureconfig.yaml) | `Azure` **CloudScale** | [values_cloudscale](examples/values_cloudscale.yaml) | [cloudscaleconfig](templates/cloudscaleconfig.yaml) | `Cloudscale` **Digitial Ocean** | [values_digitalocean](examples/values_digitalocean.yaml) | [digitaloceanconfig](templates/digitaloceanconfig.yaml) | `DigitalOcean` **Exoscale** | [values_digitalocean](examples/values_digitalocean.yaml) | [digitaloceanconfig](templates/digitaloceanconfig.yaml) | `Exoscale` @@ -42,20 +40,74 @@ Provider | Example **Outscale** | [values_aws](examples/values_outscale.yaml) | [outscaleconfig](templates/outscaleconfig.yaml) | `Outscale` **VMware vSphere** | [values_vsphere](examples/values_vsphere.yaml) | [vsphereconfig](templates/vsphereconfig.yaml) | `vSphere` -## Contributing - -Follow the [guide](CONTRIBUTING.md). +### Automation + +This chart can be installed and managed by GitOps tools like [ArgoCD](https://github.com/devpro/helm-charts#from-argocd) and [Fleet](https://github.com/devpro/helm-charts#from-fleet). +It can also be installed in [Rancher Apps](https://github.com/devpro/helm-charts#from-rancher). + +#### Fleet example for creating RKE2 cluster in Azure + +- Git repository > `fleet.yaml` + +```yaml +helm: + repo: https://devpro.github.io/helm-charts + chart: rancher-cluster-templates + version: 0.1.1 + releaseName: rke2-azure-demo + values: + cluster: + name: "azurevm-rke2-01" + cloudprovider: azure + cloudCredentialSecretName: cattle-global-data:cc-xxxx + kubernetesVersion: "v1.24.14+rke2r1" + nodepools: + - etcd: true + controlplane: true + worker: true + quantity: 1 + name: nodepool-1 + region: westeurope + machineImage: "Canonical:0001-com-ubuntu-server-focal:20_04-lts-gen2:20.04.202307240" + instanceType: Standard_DS2_v2 + storageType: Standard_LRS + sshUser: azureuser + availabilitySet: "avs-someprefix-rke2-01" + azureEnvironment: AzurePublicCloud + managedDisks: true + networkSecurityGroup: "nsg-someprefix-rke2-01" + resourceGroup: "rg-someprefix-rke2-01" + subnet: rke2 + subnetPrefix: "192.168.0.0/16" + virtualNetwork: "vnet-someprefix-rke2-01" +``` -### Going further +- Rancher > Continuous Delivery > Git Repo + +```yaml +apiVersion: fleet.cattle.io/v1alpha1 +kind: GitRepo +metadata: + name: cluster-templates + namespace: fleet-local +spec: + branch: release/demo + clientSecretName: auth-xxxx + insecureSkipTLSVerify: false + paths: + - fleet/rke2-azure-demo + repo: https://github.com/my-account/my-kubernetes-definitions.git + targets: + - clusterSelector: + matchExpressions: + - key: provider.cattle.io + operator: NotIn + values: + - harvester +``` -* Infrastructure providers - * [Azure](docs/azure.md) -* Chart installation - * [ArgoCD](https://github.com/devpro/helm-charts#from-argocd) - * [Fleet](https://github.com/devpro/helm-charts#from-fleet) - * [Rancher Apps](https://github.com/devpro/helm-charts#from-rancher) +## Going further -## Inspirations +If you feel like it, have a look at the [contibution guide](CONTRIBUTING.md). -* [bloriot/rancher-cluster-templates](https://github.com/bloriot/rancher-cluster-templates) -* [rancher/cluster-template-examples](https://github.com/rancher/cluster-template-examples) +This chart has been inspired by two examples: [bloriot/rancher-cluster-templates](https://github.com/bloriot/rancher-cluster-templates) and [rancher/cluster-template-examples](https://github.com/rancher/cluster-template-examples). diff --git a/charts/rancher-cluster-templates/values.yaml b/charts/rancher-cluster-templates/values.yaml index 54bbfe0..7e844a9 100644 --- a/charts/rancher-cluster-templates/values.yaml +++ b/charts/rancher-cluster-templates/values.yaml @@ -98,4 +98,4 @@ nodepools: [] # updateDomainCount: "5" # Azure only # usePrivateIp: false # Azure only # virtualNetwork: "vnet-AZURE_PREFIX" # Azure only - # diskIops: "1500" # Cloudscale only + # diskIops: "1500" # Outscale only