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 <[email protected]>
Co-authored-by: Alessandro Vozza <[email protected]>
  • Loading branch information
3 people committed May 10, 2024
1 parent 8858e94 commit f791b47
Show file tree
Hide file tree
Showing 11 changed files with 599 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*.code-workspace
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/
9 changes: 9 additions & 0 deletions charts/azure-managed-cluster/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
apiVersion: v2
name: azure-managed-cluster
description: A Helm chart to deploy an AKS cluster via the cluster-api-provider-azure ManagedCluster
type: application
maintainers:
- email: [email protected]
name: Jont828
version: 0.2.0
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 | default .Release.Name }}pool0
spec:
name: {{ .Values.cluster.name | default .Release.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 | default .Release.Name }}pool0
spec:
clusterName: {{ .Values.cluster.name | default .Release.Name }}
replicas: {{ .Values.defaults.agentPool.nodecount }}
template:
metadata: {}
spec:
bootstrap:
dataSecretName: ""
clusterName: {{ .Values.cluster.name | default .Release.Name }}
infrastructureRef:
apiVersion: infrastructure.cluster.x-k8s.io/v1beta1
kind: AzureManagedMachinePool
name: {{ .Values.cluster.name | default .Release.Name }}pool0
namespace: {{ $.Release.Namespace }}
version: {{ .Values.controlplane.kubernetes_version }}
---
apiVersion: infrastructure.cluster.x-k8s.io/v1beta1
kind: AzureManagedMachinePool
metadata:
name: {{ .Values.cluster.name | default .Release.Name }}pool1
spec:
name: {{ .Values.cluster.name | default .Release.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 | default .Release.Name }}pool1
spec:
clusterName: {{ .Values.cluster.name | default .Release.Name }}
replicas: {{ .Values.defaults.agentPool.nodecount }}
template:
metadata: {}
spec:
bootstrap:
dataSecretName: ""
clusterName: {{ .Values.cluster.name | default .Release.Name }}
infrastructureRef:
apiVersion: infrastructure.cluster.x-k8s.io/v1beta1
kind: AzureManagedMachinePool
name: {{ .Values.cluster.name | default .Release.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 }}
21 changes: 21 additions & 0 deletions charts/azure-managed-cluster/templates/azureclusteridentity.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{{- if not (lookup "infrastructure.cluster.x-k8s.io/v1beta1" "AzureClusterIdentity" .Values.identity.clusterIdentityNamespace .Values.identity.clusterIdentityName) }}
apiVersion: infrastructure.cluster.x-k8s.io/v1beta1
kind: AzureClusterIdentity
metadata:
labels:
clusterctl.cluster.x-k8s.io/move-hierarchy: "true"
annotations:
helm.sh/resource-policy: keep
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 }}
{{- end }}
Loading

0 comments on commit f791b47

Please sign in to comment.