Skip to content

Commit

Permalink
Add Outscale in Rancher Cluster Template chart (#26)
Browse files Browse the repository at this point in the history
* Update Outscale Rancher cluster template

* Fix wrong namespace

* Dump version to 0.1.2

* Add default values for Rancher cluster template

* Updates
  • Loading branch information
devpro authored Aug 17, 2023
1 parent 48c5d33 commit 35aea07
Show file tree
Hide file tree
Showing 12 changed files with 140 additions and 62 deletions.
22 changes: 19 additions & 3 deletions charts/rancher-cluster-templates/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -25,10 +25,26 @@ sed -i "s/AZURE_PREFIX/$USER-$resourcekey/g" values_mine.yaml
sed -i "s/CLOUD_CREDENTIAL_SECRET/<secret_name>/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/<secret_name>/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
Expand Down
2 changes: 1 addition & 1 deletion charts/rancher-cluster-templates/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
86 changes: 69 additions & 17 deletions charts/rancher-cluster-templates/README.md
Original file line number Diff line number Diff line change
@@ -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

Expand All @@ -21,16 +21,14 @@ 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

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`
Expand All @@ -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).
2 changes: 2 additions & 0 deletions charts/rancher-cluster-templates/docs/azure.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ cloudprovider: outscale

cloudCredentialSecretName: CLOUD_CREDENTIAL_SECRET

kubernetesVersion: "v1.25.10+k3s1"

nodepools:
- etcd: true
controlplane: true
Expand All @@ -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"
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Expand Down
29 changes: 17 additions & 12 deletions charts/rancher-cluster-templates/templates/cluster.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Expand Down
34 changes: 14 additions & 20 deletions charts/rancher-cluster-templates/templates/outscaleconfig.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,32 +6,26 @@ apiVersion: rke-machine-config.cattle.io/v1
kind: OutscaleConfig
metadata:
name: {{ $nodepool.name }}
namespace: default
# annotations:
# key: string
{{- if $nodepool.labels }}
namespace: fleet-default
{{- 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 }}
11 changes: 6 additions & 5 deletions charts/rancher-cluster-templates/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -98,3 +98,4 @@ nodepools: []
# updateDomainCount: "5" # Azure only
# usePrivateIp: false # Azure only
# virtualNetwork: "vnet-AZURE_PREFIX" # Azure only
# diskIops: "1500" # Outscale only

0 comments on commit 35aea07

Please sign in to comment.