Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add aks-aso chart #3

Merged
merged 2 commits into from
May 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,28 @@

This project contains [Helm](https://helm.sh/) charts for [Cluster API](https://github.com/kubernetes-sigs/cluster-api) [infrastructure providers](https://cluster-api.sigs.k8s.io/reference/providers) to provision workload clusters. These charts enable a natural continuation to utilize only `helm` instead of `clusterctl generate` to provision clusters after utilizing the helm chart from the [Cluster API operator install](https://cluster-api.sigs.k8s.io/user/quick-start-operator). These helm charts are also convenient when paired with GitOps for provisioning numerous clusters.

## Installing CAPI Charts

### [azure-aks-aso](./charts/azure-aks-aso)

To install an AKS cluster for CAPZ using the ASO API, use the following commands:

```shell
clusterctl init --infrastructure azure
helm repo add capi https://mboersma.github.io/cluster-api-charts
helm install <name> capi/azure-aks-aso -f <my_values.yaml>
```

### [azure-managed-cluster](./charts/azure-managed-cluster)

To install an AKS cluster for CAPZ as a ManagedCluster, use the following commands:

```shell
clusterctl init --infrastructure azure
helm repo add capi https://mboersma.github.io/cluster-api-charts
helm install <name> capi/azure-managed-cluster -f <my_values.yaml>
```

## Community, discussion, contribution, and support

NOTE: This is not an official Kubernetes [sig-cluster-lifecycle](https://github.com/kubernetes/community/blob/master/sig-cluster-lifecycle/README.md) project, but it hopes to be if the community finds such a chart repository useful. This project complies with Kubernetes community standards and guidelines.
Expand Down
23 changes: 23 additions & 0 deletions charts/azure-aks-aso/.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-aks-aso/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
apiVersion: v2
name: azure-aks-aso
description: A chart describing an AKS cluster for CAPZ using the ASO API
type: application
version: 0.1.0
appVersion: 0.1.0
maintainers:
- name: mboersma
email: [email protected]
63 changes: 63 additions & 0 deletions charts/azure-aks-aso/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
# azure-aks-aso Chart

This Helm chart is used to deploy an Azure Kubernetes Service (AKS) Cluster using the Azure Service Operator (ASO) API.

## Prerequisites

Create a Kubernetes cluster to serve as a Cluster API management cluster. (For example, with `kind`.) Install the Cluster API Provider Azure (CAPZ) components on it with:

```shell
clusterctl init --infrastructure azure
```

## Add the cluster-api-charts repository to Helm

```shell
helm repo add capi https://mboersma.github.io/cluster-api-charts
```

## Specify values for the CAPZ AKS-ASO chart

Create a `values.yaml` file to specify credentials and other values for the CAPZ AKS-ASO chart. It can look like the following:

```yaml
credentialSecretName: "aso-credentials"
createCredentials: true
subscriptionID: ""
tenantID: ""
clientID: ""
clientSecret: ""
authMode: ""

# clusterName defaults to the name of the Helm release
clusterName: ""
location: eastus
clusterNetwork: null
kubernetesVersion: v1.28.9
subscriptionID: <subscription-id>
identity:
clientID: <client-id>
tenantID: <tenant-id>
type: WorkloadIdentity
cluster:
location: eastus
cidrBlocks:
- 192.168.0.0/16
controlplane:
sshPublicKey: <ssh-public-key>
networkPolicy: "calico"
networkPlugin: "kubenet"
networkPluginMode: null
```

## Install the CAPZ AKS-ASO Helm chart

```bash
helm install <name> capi/azure-aks-aso -f values.yaml
```

## Uninstall the CAPZ AKS-ASO Helm chart

```bash
helm uninstall <name>
```
69 changes: 69 additions & 0 deletions charts/azure-aks-aso/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
{{- define "capz.commonLabels" -}}
app.kubernetes.io/name: azure-aks-aso
helm.sh/chart: {{ $.Chart.Name }}-{{ $.Chart.Version | replace "+" "_" }}
app.kubernetes.io/managed-by: {{ $.Release.Service }}
app.kubernetes.io/instance: {{ $.Release.Name }}
{{- end }}

{{- define "capz.clusterName" -}}
{{ default $.Release.Name $.Values.clusterName }}
{{- end }}

{{- define "capz.azureResourceAnnotations" -}}
serviceoperator.azure.com/credential-from: {{ $.Values.credentialSecretName }}
{{- end }}

{{- define "capz.azureASOManagedClusterSpec" -}}
{{- $ := index . 0 -}}
{{- $clusterName := index . 1 -}}
resources:
- apiVersion: resources.azure.com/v1api20200601
kind: ResourceGroup
metadata:
name: {{ quote $clusterName }}
annotations:
{{- include "capz.azureResourceAnnotations" $ | nindent 6 }}
spec:
location: {{ $.Values.location }}
{{- end }}

{{- define "capz.azureASOManagedControlPlaneSpec" -}}
{{- $ := index . 0 -}}
{{- $clusterName := index . 1 -}}
version: {{ $.Values.kubernetesVersion | quote }}
resources:
- apiVersion: "containerservice.azure.com/{{ $.Values.managedClusterAPIVersion }}"
kind: ManagedCluster
metadata:
name: {{ $clusterName | quote }}
annotations:
{{- include "capz.azureResourceAnnotations" $ | nindent 6 }}
spec:
owner:
name: {{ quote $clusterName }}
dnsPrefix: {{ quote $clusterName }}
location: {{ default $.Values.location $.Values.managedClusterSpec.location | quote }}
{{- toYaml (unset $.Values.managedClusterSpec "location") | nindent 4 }}
{{- end }}

{{- define "capz.azureASOManagedMachinePoolSpec" -}}
{{- $ := index . 0 -}}
{{- $clusterName := index . 1 -}}
{{- $mpName := index . 2 -}}
{{- $mp := index . 3 -}}
resources:
- apiVersion: "containerservice.azure.com/{{ $.Values.managedMachinePoolAPIVersion }}"
kind: ManagedClustersAgentPool
metadata:
name: {{ printf "%s-%s" $clusterName $mpName | quote }}
annotations:
{{- include "capz.azureResourceAnnotations" $ | nindent 6 }}
spec:
azureName: {{ $mpName | quote }}
{{- if $mp.owner }}
{{- fail (printf ".Values.managedMachinePoolSpecs.%s.owner is not allowed to be set." $mpName) }}
{{- end }}
owner:
name: {{ quote $clusterName }}
{{- toYaml (unset $mp "count") | nindent 4 }}
{{- end }}
87 changes: 87 additions & 0 deletions charts/azure-aks-aso/templates/cluster.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
apiVersion: cluster.x-k8s.io/v1beta1
kind: Cluster
metadata:
name: {{ include "capz.clusterName" . | quote }}
labels:
{{- include "capz.commonLabels" . | nindent 4 }}
spec:
{{- if .Values.withClusterTopology }}
topology:
class: {{ .Values.clusterClassName | quote }}
version: {{ .Values.kubernetesVersion | quote }}
workers:
machinePools:
{{- range $mpName, $mp := .Values.managedMachinePoolSpecs }}
- class: {{ quote $mpName }}
name: {{ quote $mpName }}
{{- if (not $mp.enableAutoScaling) }}
replicas: {{ default 1 $mp.count}}
{{- end }}
{{- end }}
{{- else }}
controlPlaneRef:
apiVersion: infrastructure.cluster.x-k8s.io/v1beta1
kind: AzureASOManagedControlPlane
name: {{ include "capz.clusterName" . | quote }}
infrastructureRef:
apiVersion: infrastructure.cluster.x-k8s.io/v1beta1
kind: AzureASOManagedCluster
name: {{ include "capz.clusterName" . | quote }}
---
apiVersion: infrastructure.cluster.x-k8s.io/v1beta1
kind: AzureASOManagedCluster
metadata:
name: {{ include "capz.clusterName" . | quote }}
labels:
{{- include "capz.commonLabels" . | nindent 4 }}
annotations:
helm.sh/resource-policy: keep
spec:
{{- include "capz.azureASOManagedClusterSpec" (list $ (include "capz.clusterName" $)) | nindent 2 }}
---
apiVersion: infrastructure.cluster.x-k8s.io/v1beta1
kind: AzureASOManagedControlPlane
metadata:
name: {{ include "capz.clusterName" . | quote }}
annotations:
helm.sh/resource-policy: keep
spec:
{{- include "capz.azureASOManagedControlPlaneSpec" (list $ (include "capz.clusterName" $)) | nindent 2 }}
{{- range $mpName, $mp := .Values.managedMachinePoolSpecs }}
---
apiVersion: cluster.x-k8s.io/v1beta1
kind: MachinePool
metadata:
name: {{ printf "%s-%s" (include "capz.clusterName" $) $mpName | quote }}
labels:
{{- include "capz.commonLabels" $ | nindent 4 }}
annotations:
helm.sh/resource-policy: keep
spec:
clusterName: {{ include "capz.clusterName" $ | quote }}
{{- if (ne nil $mp.count) }}
replicas: {{ $mp.count }}
{{- end }}
template:
spec:
bootstrap:
dataSecretName: ""
clusterName: {{ include "capz.clusterName" $ }}
infrastructureRef:
apiVersion: infrastructure.cluster.x-k8s.io/v1beta1
kind: AzureASOManagedMachinePool
name: {{ printf "%s-%s" (include "capz.clusterName" $) $mpName | quote }}
version: {{ default $.Values.kubernetesVersion $mp.orchestratorVersion | quote }}
---
apiVersion: infrastructure.cluster.x-k8s.io/v1beta1
kind: AzureASOManagedMachinePool
metadata:
name: {{ printf "%s-%s" (include "capz.clusterName" $) $mpName | quote }}
labels:
{{- include "capz.commonLabels" $ | nindent 4 }}
annotations:
helm.sh/resource-policy: keep
spec:
{{- include "capz.azureASOManagedMachinePoolSpec" (list $ (include "capz.clusterName" $) $mpName $mp) | nindent 2 }}
{{- end }}
{{- end }}{{/* if .Values.withClusterTopology */}}
Loading