Skip to content

Commit 85340c2

Browse files
committed
add aks-aso chart
1 parent b03dc47 commit 85340c2

File tree

7 files changed

+371
-0
lines changed

7 files changed

+371
-0
lines changed

charts/azure-aks-aso/.helmignore

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Patterns to ignore when building packages.
2+
# This supports shell glob matching, relative path matching, and
3+
# negation (prefixed with !). Only one pattern per line.
4+
.DS_Store
5+
# Common VCS dirs
6+
.git/
7+
.gitignore
8+
.bzr/
9+
.bzrignore
10+
.hg/
11+
.hgignore
12+
.svn/
13+
# Common backup files
14+
*.swp
15+
*.bak
16+
*.tmp
17+
*.orig
18+
*~
19+
# Various IDEs
20+
.project
21+
.idea/
22+
*.tmproj
23+
.vscode/

charts/azure-aks-aso/Chart.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
apiVersion: v2
2+
name: azure-aks-aso
3+
description: A chart describing an AKS cluster for CAPZ using the ASO API
4+
type: application
5+
version: 0.1.0
6+
appVersion: 0.1.0
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
{{- define "capz.commonLabels" -}}
2+
app.kubernetes.io/name: azure-aks-aso
3+
helm.sh/chart: {{ $.Chart.Name }}-{{ $.Chart.Version | replace "+" "_" }}
4+
app.kubernetes.io/managed-by: {{ $.Release.Service }}
5+
app.kubernetes.io/instance: {{ $.Release.Name }}
6+
{{- end }}
7+
8+
{{- define "capz.clusterName" -}}
9+
{{ default $.Release.Name $.Values.clusterName }}
10+
{{- end }}
11+
12+
{{- define "capz.azureResourceAnnotations" -}}
13+
serviceoperator.azure.com/credential-from: {{ $.Values.credentialSecretName }}
14+
{{- end }}
15+
16+
{{- define "capz.azureASOManagedClusterSpec" -}}
17+
{{- $ := index . 0 -}}
18+
{{- $clusterName := index . 1 -}}
19+
resources:
20+
- apiVersion: resources.azure.com/v1api20200601
21+
kind: ResourceGroup
22+
metadata:
23+
name: {{ quote $clusterName }}
24+
annotations:
25+
{{- include "capz.azureResourceAnnotations" $ | nindent 6 }}
26+
spec:
27+
location: {{ $.Values.location }}
28+
{{- end }}
29+
30+
{{- define "capz.azureASOManagedControlPlaneSpec" -}}
31+
{{- $ := index . 0 -}}
32+
{{- $clusterName := index . 1 -}}
33+
version: {{ $.Values.kubernetesVersion | quote }}
34+
resources:
35+
- apiVersion: "containerservice.azure.com/{{ $.Values.managedClusterAPIVersion }}"
36+
kind: ManagedCluster
37+
metadata:
38+
name: {{ $clusterName | quote }}
39+
annotations:
40+
{{- include "capz.azureResourceAnnotations" $ | nindent 6 }}
41+
spec:
42+
owner:
43+
name: {{ quote $clusterName }}
44+
dnsPrefix: {{ quote $clusterName }}
45+
location: {{ default $.Values.location $.Values.managedClusterSpec.location | quote }}
46+
{{- toYaml (unset $.Values.managedClusterSpec "location") | nindent 4 }}
47+
{{- end }}
48+
49+
{{- define "capz.azureASOManagedMachinePoolSpec" -}}
50+
{{- $ := index . 0 -}}
51+
{{- $clusterName := index . 1 -}}
52+
{{- $mpName := index . 2 -}}
53+
{{- $mp := index . 3 -}}
54+
resources:
55+
- apiVersion: "containerservice.azure.com/{{ $.Values.managedMachinePoolAPIVersion }}"
56+
kind: ManagedClustersAgentPool
57+
metadata:
58+
name: {{ printf "%s-%s" $clusterName $mpName | quote }}
59+
annotations:
60+
{{- include "capz.azureResourceAnnotations" $ | nindent 6 }}
61+
spec:
62+
azureName: {{ $mpName | quote }}
63+
{{- if $mp.owner }}
64+
{{- fail (printf ".Values.managedMachinePoolSpecs.%s.owner is not allowed to be set." $mpName) }}
65+
{{- end }}
66+
owner:
67+
name: {{ quote $clusterName }}
68+
{{- toYaml (unset $mp "count") | nindent 4 }}
69+
{{- end }}
Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
apiVersion: cluster.x-k8s.io/v1beta1
2+
kind: Cluster
3+
metadata:
4+
name: {{ include "capz.clusterName" . | quote }}
5+
labels:
6+
{{- include "capz.commonLabels" . | nindent 4 }}
7+
spec:
8+
{{- if .Values.withClusterTopology }}
9+
topology:
10+
class: {{ .Values.clusterClassName | quote }}
11+
version: {{ .Values.kubernetesVersion | quote }}
12+
workers:
13+
machinePools:
14+
{{- range $mpName, $mp := .Values.managedMachinePoolSpecs }}
15+
- class: {{ quote $mpName }}
16+
name: {{ quote $mpName }}
17+
{{- if (not $mp.enableAutoScaling) }}
18+
replicas: {{ default 1 $mp.count}}
19+
{{- end }}
20+
{{- end }}
21+
{{- else }}
22+
controlPlaneRef:
23+
apiVersion: infrastructure.cluster.x-k8s.io/v1beta1
24+
kind: AzureASOManagedControlPlane
25+
name: {{ include "capz.clusterName" . | quote }}
26+
infrastructureRef:
27+
apiVersion: infrastructure.cluster.x-k8s.io/v1beta1
28+
kind: AzureASOManagedCluster
29+
name: {{ include "capz.clusterName" . | quote }}
30+
---
31+
apiVersion: infrastructure.cluster.x-k8s.io/v1beta1
32+
kind: AzureASOManagedCluster
33+
metadata:
34+
name: {{ include "capz.clusterName" . | quote }}
35+
labels:
36+
{{- include "capz.commonLabels" . | nindent 4 }}
37+
annotations:
38+
helm.sh/resource-policy: keep
39+
spec:
40+
{{- include "capz.azureASOManagedClusterSpec" (list $ (include "capz.clusterName" $)) | nindent 2 }}
41+
---
42+
apiVersion: infrastructure.cluster.x-k8s.io/v1beta1
43+
kind: AzureASOManagedControlPlane
44+
metadata:
45+
name: {{ include "capz.clusterName" . | quote }}
46+
annotations:
47+
helm.sh/resource-policy: keep
48+
spec:
49+
{{- include "capz.azureASOManagedControlPlaneSpec" (list $ (include "capz.clusterName" $)) | nindent 2 }}
50+
{{- range $mpName, $mp := .Values.managedMachinePoolSpecs }}
51+
---
52+
apiVersion: cluster.x-k8s.io/v1beta1
53+
kind: MachinePool
54+
metadata:
55+
name: {{ printf "%s-%s" (include "capz.clusterName" $) $mpName | quote }}
56+
labels:
57+
{{- include "capz.commonLabels" $ | nindent 4 }}
58+
annotations:
59+
helm.sh/resource-policy: keep
60+
spec:
61+
clusterName: {{ include "capz.clusterName" $ | quote }}
62+
{{- if (ne nil $mp.count) }}
63+
replicas: {{ $mp.count }}
64+
{{- end }}
65+
template:
66+
spec:
67+
bootstrap:
68+
dataSecretName: ""
69+
clusterName: {{ include "capz.clusterName" $ }}
70+
infrastructureRef:
71+
apiVersion: infrastructure.cluster.x-k8s.io/v1beta1
72+
kind: AzureASOManagedMachinePool
73+
name: {{ printf "%s-%s" (include "capz.clusterName" $) $mpName | quote }}
74+
version: {{ default $.Values.kubernetesVersion $mp.orchestratorVersion | quote }}
75+
---
76+
apiVersion: infrastructure.cluster.x-k8s.io/v1beta1
77+
kind: AzureASOManagedMachinePool
78+
metadata:
79+
name: {{ printf "%s-%s" (include "capz.clusterName" $) $mpName | quote }}
80+
labels:
81+
{{- include "capz.commonLabels" $ | nindent 4 }}
82+
annotations:
83+
helm.sh/resource-policy: keep
84+
spec:
85+
{{- include "capz.azureASOManagedMachinePoolSpec" (list $ (include "capz.clusterName" $) $mpName $mp) | nindent 2 }}
86+
{{- end }}
87+
{{- end }}{{/* if .Values.withClusterTopology */}}
Lines changed: 123 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,123 @@
1+
{{- if .Values.withClusterClass }}
2+
apiVersion: cluster.x-k8s.io/v1beta1
3+
kind: ClusterClass
4+
metadata:
5+
name: {{ required "value clusterClassName must be set" .Values.clusterClassName | quote }}
6+
labels:
7+
{{- include "capz.commonLabels" . | nindent 4 }}
8+
spec:
9+
controlPlane:
10+
ref:
11+
apiVersion: infrastructure.cluster.x-k8s.io/v1beta1
12+
kind: AzureASOManagedControlPlaneTemplate
13+
name: {{ .Values.clusterClassName | quote }}
14+
infrastructure:
15+
ref:
16+
apiVersion: infrastructure.cluster.x-k8s.io/v1beta1
17+
kind: AzureASOManagedClusterTemplate
18+
name: {{ .Values.clusterClassName | quote }}
19+
workers:
20+
machinePools:
21+
{{- range $mpName, $mp := .Values.managedMachinePoolSpecs }}
22+
- class: {{ quote $mpName }}
23+
template:
24+
bootstrap:
25+
ref:
26+
apiVersion: bootstrap.cluster.x-k8s.io/v1beta1
27+
kind: KubeadmConfigTemplate
28+
name: {{ $.Values.clusterClassName | quote }}
29+
infrastructure:
30+
ref:
31+
apiVersion: infrastructure.cluster.x-k8s.io/v1beta1
32+
kind: AzureASOManagedMachinePoolTemplate
33+
name: {{ printf "%s-%s" $.Values.clusterClassName $mpName | quote }}
34+
{{- end }}
35+
patches:
36+
- name: azureasomanagedcluster-spec
37+
definitions:
38+
- selector:
39+
apiVersion: infrastructure.cluster.x-k8s.io/v1beta1
40+
kind: AzureASOManagedClusterTemplate
41+
matchResources:
42+
infrastructureCluster: true
43+
jsonPatches:
44+
- op: replace
45+
path: /spec/template/spec
46+
valueFrom:
47+
template: |
48+
{{- include "capz.azureASOManagedClusterSpec" (list $ "{{ .builtin.cluster.name }}") | nindent 12 }}
49+
- name: azureasomanagedcontrolplane-spec
50+
definitions:
51+
- selector:
52+
apiVersion: infrastructure.cluster.x-k8s.io/v1beta1
53+
kind: AzureASOManagedControlPlaneTemplate
54+
matchResources:
55+
controlPlane: true
56+
jsonPatches:
57+
- op: replace
58+
path: /spec/template/spec
59+
valueFrom:
60+
template: |
61+
{{- include "capz.azureASOManagedControlPlaneSpec" (list $ "{{ .builtin.cluster.name }}") | nindent 12 }}
62+
{{- range $mpName, $mp := .Values.managedMachinePoolSpecs }}
63+
- name: azureasomanagedmachinepool-{{ $mpName }}-spec
64+
definitions:
65+
- selector:
66+
apiVersion: infrastructure.cluster.x-k8s.io/v1beta1
67+
kind: AzureASOManagedMachinePoolTemplate
68+
matchResources:
69+
machinePoolClass:
70+
names:
71+
- {{ quote $mpName }}
72+
jsonPatches:
73+
- op: replace
74+
path: /spec/template/spec
75+
valueFrom:
76+
template: |
77+
{{- include "capz.azureASOManagedMachinePoolSpec" (list $ "{{ .builtin.cluster.name }}" $mpName $mp) | nindent 12 }}
78+
{{- end }}
79+
---
80+
apiVersion: infrastructure.cluster.x-k8s.io/v1beta1
81+
kind: AzureASOManagedClusterTemplate
82+
metadata:
83+
name: {{ .Values.clusterClassName | quote }}
84+
labels:
85+
{{- include "capz.commonLabels" . | nindent 4 }}
86+
annotations:
87+
helm.sh/resource-policy: keep
88+
spec:
89+
template:
90+
spec: {} # this gets patched in by the ClusterClass
91+
---
92+
apiVersion: infrastructure.cluster.x-k8s.io/v1beta1
93+
kind: AzureASOManagedControlPlaneTemplate
94+
metadata:
95+
name: {{ .Values.clusterClassName | quote }}
96+
annotations:
97+
helm.sh/resource-policy: keep
98+
spec:
99+
template:
100+
spec: {} # this gets patched in by the ClusterClass
101+
---
102+
apiVersion: bootstrap.cluster.x-k8s.io/v1beta1
103+
kind: KubeadmConfigTemplate
104+
metadata:
105+
name: {{ .Values.clusterClassName | quote }}
106+
spec:
107+
template:
108+
spec: {}
109+
{{- range $mpName, $mp := .Values.managedMachinePoolSpecs }}
110+
---
111+
apiVersion: infrastructure.cluster.x-k8s.io/v1beta1
112+
kind: AzureASOManagedMachinePoolTemplate
113+
metadata:
114+
name: {{ printf "%s-%s" $.Values.clusterClassName $mpName | quote }}
115+
labels:
116+
{{- include "capz.commonLabels" $ | nindent 4 }}
117+
annotations:
118+
helm.sh/resource-policy: keep
119+
spec:
120+
template:
121+
spec: {} # this gets patched in by the ClusterClass
122+
{{- end }}
123+
{{- end }}{{/* if .Values.withClusterClass */}}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
{{- if .Values.createCredentials }}
2+
apiVersion: v1
3+
kind: Secret
4+
metadata:
5+
name: {{ .Values.credentialSecretName | quote }}
6+
labels:
7+
{{- include "capz.commonLabels" . | nindent 4 }}
8+
annotations:
9+
helm.sh/resource-policy: keep # credentials have to be available throughout a delete operation
10+
stringData:
11+
{{- if .Values.subscriptionID }}
12+
AZURE_SUBSCRIPTION_ID: {{ .Values.subscriptionID | quote }}
13+
{{- end }}
14+
{{- if .Values.tenantID }}
15+
AZURE_TENANT_ID: {{ .Values.tenantID | quote }}
16+
{{- end }}
17+
{{- if .Values.clientID }}
18+
AZURE_CLIENT_ID: {{ .Values.clientID | quote }}
19+
{{- end }}
20+
{{- if .Values.clientSecret }}
21+
AZURE_CLIENT_SECRET: {{ .Values.clientSecret | quote }}
22+
{{- end }}
23+
{{- if .Values.authMode }}
24+
AUTH_MODE: {{ .Values.authMode | quote }}
25+
{{- end }}
26+
{{- end }}

charts/azure-aks-aso/values.yaml

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
credentialSecretName: "aso-credentials"
2+
createCredentials: true
3+
subscriptionID: ""
4+
tenantID: ""
5+
clientID: ""
6+
clientSecret: ""
7+
authMode: ""
8+
9+
# clusterName defaults to the name of the Helm release
10+
clusterName: ""
11+
location: eastus
12+
clusterNetwork: null
13+
kubernetesVersion: v1.28.3
14+
15+
managedClusterAPIVersion: v1api20231001
16+
managedClusterSpec:
17+
identity:
18+
type: SystemAssigned
19+
servicePrincipalProfile:
20+
clientId: msi
21+
22+
managedMachinePoolAPIVersion: v1api20231001
23+
managedMachinePoolSpecs:
24+
pool0:
25+
count: 1
26+
mode: System
27+
vmSize: Standard_DS2_v2
28+
type: VirtualMachineScaleSets
29+
pool1:
30+
count: 1
31+
mode: User
32+
vmSize: Standard_DS2_v2
33+
type: VirtualMachineScaleSets
34+
35+
clusterClassName: ""
36+
withClusterClass: false
37+
withClusterTopology: false

0 commit comments

Comments
 (0)