Skip to content

Commit

Permalink
Add Helm chart for AKS managed cluster
Browse files Browse the repository at this point in the history
Note: this is originated from the following repo: https://github.com/nellyk/azure-managed-cluster-capz-helm

Co-authored-by: Nelly Kiboi <3062772+nellyk@users.noreply.github.com>
Co-authored-by: Alessandro Vozza <alessandro.vozza@microsoft.com>
Co-authored-by: jorgearteiro <jorgearteiro@hotmail.com>
  • Loading branch information
4 people committed May 9, 2024
1 parent 8858e94 commit 4b0a3ab
Show file tree
Hide file tree
Showing 10 changed files with 612 additions and 0 deletions.
23 changes: 23 additions & 0 deletions charts/azure-managed-cluster/.helmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Patterns to ignore when building packages.
# This supports shell glob matching, relative path matching, and
# negation (prefixed with !). Only one pattern per line.
.DS_Store
# Common VCS dirs
.git/
.gitignore
.bzr/
.bzrignore
.hg/
.hgignore
.svn/
# Common backup files
*.swp
*.bak
*.tmp
*.orig
*~
# Various IDEs
.project
.idea/
*.tmproj
.vscode/
23 changes: 23 additions & 0 deletions charts/azure-managed-cluster/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
apiVersion: v2
name: azure-managed-cluster
description: A Helm chart to deploy an AKS cluster via the cluster-api-provider-azure ManagedCluster

# A chart can be either an 'application' or a 'library' chart.
#
# Application charts are a collection of templates that can be packaged into versioned archives
# to be deployed.
#
# Library charts provide useful utilities or functions for the chart developer. They're included as
# a dependency of application charts to inject those utilities and functions into the rendering
# pipeline. Library charts do not define any templates and therefore cannot be deployed.
type: application

# This is the chart version. This version number should be incremented each time you make changes
# to the chart and its templates, including the app version.
# Versions are expected to follow Semantic Versioning (https://semver.org/)
version: 0.2.0

# This is the version number of the application being deployed. This version number should be
# incremented each time you make changes to the application. Versions are not expected to
# follow Semantic Versioning. They should reflect the version the application is using.
appVersion: 1.16.0
62 changes: 62 additions & 0 deletions charts/azure-managed-cluster/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
{{/*
Expand the name of the chart.
*/}}
{{- define "azure-managed-cluster.name" -}}
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }}
{{- end }}

{{/*
Create a default fully qualified app name.
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
If release name contains chart name it will be used as a full name.
*/}}
{{- define "azure-managed-cluster.fullname" -}}
{{- if .Values.fullnameOverride }}
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }}
{{- else }}
{{- $name := default .Chart.Name .Values.nameOverride }}
{{- if contains $name .Release.Name }}
{{- .Release.Name | trunc 63 | trimSuffix "-" }}
{{- else }}
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }}
{{- end }}
{{- end }}
{{- end }}

{{/*
Create chart name and version as used by the chart label.
*/}}
{{- define "azure-managed-cluster.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
{{- end }}

{{/*
Common labels
*/}}
{{- define "azure-managed-cluster.labels" -}}
helm.sh/chart: {{ include "azure-managed-cluster.chart" . }}
{{ include "azure-managed-cluster.selectorLabels" . }}
{{- if .Chart.AppVersion }}
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
{{- end }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
{{- end }}

{{/*
Selector labels
*/}}
{{- define "azure-managed-cluster.selectorLabels" -}}
app.kubernetes.io/name: {{ include "azure-managed-cluster.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
{{- end }}

{{/*
Create the name of the service account to use
*/}}
{{- define "azure-managed-cluster.serviceAccountName" -}}
{{- if .Values.serviceAccount.create }}
{{- default (include "azure-managed-cluster.fullname" .) .Values.serviceAccount.name }}
{{- else }}
{{- default "default" .Values.serviceAccount.name }}
{{- end }}
{{- end }}
200 changes: 200 additions & 0 deletions charts/azure-managed-cluster/templates/agentpools.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,200 @@
{{- if not .Values.agentpools }}
apiVersion: infrastructure.cluster.x-k8s.io/v1beta1
kind: AzureManagedMachinePool
metadata:
name: {{ .Values.cluster.name }}pool0
spec:
name: {{ .Values.cluster.name }}pool0
scaling:
minSize: {{ .Values.defaults.agentPool.scaling.minSize }}
maxSize: {{ .Values.defaults.agentPool.scaling.maxSize }}
osDiskSizeGB: {{ .Values.defaults.agentPool.osDiskSizeGB }}
sku: {{ .Values.defaults.agentPool.sku }}
availabilityZones:
{{- range .Values.defaults.agentPool.availabilityZones }}
- {{ . | quote }}
{{- end }}
nodeLabels:
{{- range $nodeLabels := .Values.defaults.agentPool.nodeLabels }}
{{ $nodeLabels.key }}: {{ $nodeLabels.value }}
{{- end }}
mode: System
maxPods: {{ .Values.defaults.agentPool.maxPods }}
osDiskType: {{ .Values.defaults.agentPool.osDiskType }}
enableUltraSSD: {{ .Values.defaults.agentPool.enableUltraSSD }}
osType: {{ .Values.defaults.agentPool.osType }}
enableNodePublicIP: {{ .Values.defaults.agentPool.enableNodePublicIP }}
nodePublicIPPrefixID: {{ .Values.defaults.agentPool.nodePublicIPPrefixID }}
scaleSetPriority: {{ .Values.defaults.agentPool.scaleSetPriority }}
scaleDownMode: {{ .Values.defaults.agentPool.scaleDownMode }}
spotMaxPrice: {{ .Values.defaults.agentPool.spotMaxPrice }}
kubeletConfig: {{ .Values.defaults.agentPool.kubeletConfig }}
kubeletDiskType: {{ .Values.defaults.agentPool.kubeletDiskType }}
linuxOSConfig: {{ .Values.defaults.agentPool.linuxOSConfig }}
subnetName: {{ .Values.defaults.agentPool.subnetName }}
enableFIPS: {{ .Values.defaults.agentPool.enableFIPS }}
enableEncryptionAtHost: {{ .Values.defaults.agentPool.enableEncryptionAtHost }}
---
apiVersion: cluster.x-k8s.io/v1beta1
kind: MachinePool
metadata:
name: {{ .Values.cluster.name }}pool0
spec:
clusterName: {{ .Values.cluster.name }}
replicas: {{ .Values.defaults.agentPool.nodecount }}
template:
metadata: {}
spec:
bootstrap:
dataSecretName: ""
clusterName: {{ .Values.cluster.name }}
infrastructureRef:
apiVersion: infrastructure.cluster.x-k8s.io/v1beta1
kind: AzureManagedMachinePool
name: {{ .Values.cluster.name }}pool0
namespace: {{ $.Release.Namespace }}
version: {{ .Values.controlplane.kubernetes_version }}
---
apiVersion: infrastructure.cluster.x-k8s.io/v1beta1
kind: AzureManagedMachinePool
metadata:
name: {{ .Values.cluster.name }}pool1
spec:
name: {{ .Values.cluster.name }}pool1
scaling:
minSize: {{ .Values.defaults.agentPool.scaling.minSize }}
maxSize: {{ .Values.defaults.agentPool.scaling.maxSize }}
osDiskSizeGB: {{ .Values.defaults.agentPool.osDiskSizeGB }}
sku: {{ .Values.defaults.agentPool.sku }}
availabilityZones:
{{- range .Values.defaults.agentPool.availabilityZones }}
- {{ . | quote }}
{{- end }}
nodeLabels:
{{- range $nodeLabels := .Values.defaults.agentPool.nodeLabels }}
{{ $nodeLabels.key }}: {{ $nodeLabels.value }}
{{- end }}
mode: User
maxPods: {{ .Values.defaults.agentPool.maxPods }}
osDiskType: {{ .Values.defaults.agentPool.osDiskType }}
enableUltraSSD: {{ .Values.defaults.agentPool.enableUltraSSD }}
osType: {{ .Values.defaults.agentPool.osType }}
enableNodePublicIP: {{ .Values.defaults.agentPool.enableNodePublicIP }}
nodePublicIPPrefixID: {{ .Values.defaults.agentPool.nodePublicIPPrefixID }}
scaleSetPriority: {{ .Values.defaults.agentPool.scaleSetPriority }}
scaleDownMode: {{ .Values.defaults.agentPool.scaleDownMode }}
spotMaxPrice: {{ .Values.defaults.agentPool.spotMaxPrice }}
kubeletConfig: {{ .Values.defaults.agentPool.kubeletConfig }}
kubeletDiskType: {{ .Values.defaults.agentPool.kubeletDiskType }}
linuxOSConfig: {{ .Values.defaults.agentPool.linuxOSConfig }}
subnetName: {{ .Values.defaults.agentPool.subnetName }}
enableFIPS: {{ .Values.defaults.agentPool.enableFIPS }}
enableEncryptionAtHost: {{ .Values.defaults.agentPool.enableEncryptionAtHost }}
---
apiVersion: cluster.x-k8s.io/v1beta1
kind: MachinePool
metadata:
name: {{ .Values.cluster.name }}pool1
spec:
clusterName: {{ .Values.cluster.name }}
replicas: {{ .Values.defaults.agentPool.nodecount }}
template:
metadata: {}
spec:
bootstrap:
dataSecretName: ""
clusterName: {{ .Values.cluster.name }}
infrastructureRef:
apiVersion: infrastructure.cluster.x-k8s.io/v1beta1
kind: AzureManagedMachinePool
name: {{ .Values.cluster.name }}pool1
namespace: {{ $.Release.Namespace }}
version: {{ .Values.controlplane.kubernetes_version }}
---
{{- else }}
{{- range $index, $agentPool := .Values.agentPools }}
apiVersion: infrastructure.cluster.x-k8s.io/v1beta1
kind: AzureManagedMachinePool
metadata:
name: {{ $agentPool.name }}
spec:
name: {{ $agentPool.name }}
scaling:
{{- if $agentPool.scaling }}
minSize: {{ $agentPool.scaling.minSize | default .Values.defaults.agentPool.scaling.minSize }}
maxSize: {{ $agentPool.scaling.maxSize | default .Values.defaults.agentPool.scaling.maxSize }}
{{- else }}
minSize: {{ .Values.defaults.agentPool.scaling.minSize }}
maxSize: {{ .Values.defaults.agentPool.scaling.maxSize }}
{{- end }}
{{- if $agentPool.additionalTags }}
additionalTags:
{{- range $additionalTags := $agentPool.additionalTags }}
{{ $additionalTags.key }}: {{ $additionalTags.value }}
{{- end }}
{{- end }}
osDiskSizeGB: {{ $agentPool.osDiskSizeGB | default .Values.defaults.agentPool.osDiskSizeGB }}
sku: {{ $agentPool.sku | default .Values.defaults.agentPool.sku }}
availabilityZones:
{{- if $agentPool.availabilityZones }}
{{- range $agentPool.availabilityZones }}
- {{ . | quote }}
{{- end }}
{{- else }}
{{- range .Values.defaults.agentPool.availabilityZones }}
- {{ . | quote }}
{{- end }}
{{- end }}
{{- if $agentPool.nodeLabels }}
nodeLabels:
{{- range $nodeLabels := $agentPool.nodeLabels }}
{{ $nodeLabels.key }}: {{ $nodeLabels.value }}
{{- end }}
{{- end }}
{{- if .Values.defaults.agentPool.nodeLabels }}
taints:
{{- range $taints := $agentPool.taints }}
- key: {{ $taints.key }}
value: {{ $taints.value }}
effect: {{ $taints.effect }}
{{- end }}
{{- end }}
mode: {{ $agentPool.mode | default .Values.defaults.agentPool.mode }}
maxPods: {{ $agentPool.maxPods | default .Values.defaults.agentPool.maxPods }}
osDiskType: {{ $agentPool.osDiskType | default .Values.defaults.agentPool.osDiskType }}
enableUltraSSD: {{ $agentPool.enableUltraSSD | default .Values.defaults.agentPool.enableUltraSSD }}
osType: {{ $agentPool.osType | default .Values.defaults.agentPool.osType }}
enableNodePublicIP: {{ $agentPool.enableNodePublicIP | default .Values.defaults.agentPool.enableNodePublicIP }}
nodePublicIPPrefixID: {{ $agentPool.nodePublicIPPrefixID | default .Values.defaults.agentPool.nodePublicIPPrefixID }}
scaleSetPriority: {{ $agentPool.scaleSetPriority | default .Values.defaults.agentPool.scaleSetPriority }}
scaleDownMode: {{ $agentPool.scaleDownMode | default .Values.defaults.agentPool.scaleDownMode }}
spotMaxPrice: {{ $agentPool.spotMaxPrice | default .Values.defaults.agentPool.spotMaxPrice }}
kubeletConfig: {{ $agentPool.kubeletConfig | default .Values.defaults.agentPool.kubeletConfig }}
kubeletDiskType: {{ $agentPool.kubeletDiskType | default .Values.defaults.agentPool.kubeletDiskType }}
linuxOSConfig: {{ $agentPool.linuxOSConfig | default .Values.defaults.agentPool.linuxOSConfig }}
subnetName: {{ $agentPool.subnetName | default .Values.defaults.agentPool.subnetName }}
enableFIPS: {{ $agentPool.enableFIPS | default .Values.defaults.agentPool.enableFIPS }}
enableEncryptionAtHost: {{ $agentPool.enableEncryptionAtHost | default .Values.defaults.agentPool.enableEncryptionAtHost }}
---
apiVersion: cluster.x-k8s.io/v1beta1
kind: MachinePool
metadata:
name: {{ $agentPool.name }}
spec:
clusterName: {{ $.Values.cluster.name }}
replicas: {{ $agentPool.nodecount }}
template:
metadata: {}
spec:
bootstrap:
dataSecretName: ""
clusterName: {{ $.Values.cluster.name }}
infrastructureRef:
apiVersion: infrastructure.cluster.x-k8s.io/v1beta1
kind: AzureManagedMachinePool
name: {{ $agentPool.name }}
namespace: {{ $.Release.Namespace }}
version: {{ $.Values.controlplane.kubernetes_version }}
---
{{- end }}
{{- end }}
17 changes: 17 additions & 0 deletions charts/azure-managed-cluster/templates/azureclusteridentity.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
apiVersion: infrastructure.cluster.x-k8s.io/v1beta1
kind: AzureClusterIdentity
metadata:
labels:
clusterctl.cluster.x-k8s.io/move-hierarchy: "true"
name: {{ $.Values.identity.clusterIdentityName }}
spec:
allowedNamespaces:
list:
- {{ $.Values.identity.clusterIdentitySecretNamespace }}
clientSecret:
name: {{ $.Values.identity.clusterIdentitySecretName }}
namespace: {{ $.Values.identity.clusterIdentitySecretNamespace }}
clientID: {{ $.Values.identity.clientID }}
tenantID: {{ $.Values.identity.tenantID }}
type: {{ $.Values.identity.type }}
resourceID: {{ $.Values.identity.resourceID }}
Loading

0 comments on commit 4b0a3ab

Please sign in to comment.