Skip to content

Commit

Permalink
Added SelfManaged azureClusterAPi
Browse files Browse the repository at this point in the history
Signed-off-by: Devesh Sharma <[email protected]>
  • Loading branch information
Devesh Sharma committed Aug 27, 2024
1 parent 7c970c3 commit 9b9dedf
Show file tree
Hide file tree
Showing 18 changed files with 442 additions and 43 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
{{- if .Values.selfManagedCluster.enabled }}
apiVersion: infrastructure.cluster.x-k8s.io/v1beta1
kind: AzureCluster
metadata:
name: {{ .Values.global.clusterName }}
namespace: {{ .Release.Namespace }}
spec:
location: {{ .Values.location }}
resourceGroup: {{ .Values.resourceGroup }}
subscriptionID: {{ .Values.subscriptionID }}
identityRef:
apiVersion: infrastructure.cluster.x-k8s.io/v1beta1
kind: AzureClusterIdentity
name: {{ .Values.global.clusterName }}-cluster-identity
bastionSpec:
azureBastion:
enableTunneling: true
name: bastion
publicIP:
name: bastion
sku: Standard
subnet:
name: AzureBastionSubnet

networkSpec:
apiServerLB:
type: {{ .Values.selfManagedCluster.apiLoadbalancer }}
vnet:
name: {{ .Values.global.virtualNetwork.name }}
{{- if ne .Values.global.virtualNetwork.cidrBlock "" }}
cidrBlocks:
- {{ .Values.global.virtualNetwork.cidrBlock | toString }}
{{- end }}
subnets:
- name: {{ .Values.global.virtualNetwork.subnet.name }}
role: node
{{- if ne .Values.global.virtualNetwork.subnet.cidrBlock "" }}
cidrBlocks:
- {{ .Values.global.virtualNetwork.subnet.cidrBlock | toString }}
{{- end }}
{{- end }}
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ metadata:
name: {{ .Values.global.clusterName }}-cluster-identity
namespace: {{ .Release.Namespace }}
spec:
type: WorkloadIdentity
allowedNamespaces:
list:
- {{ .Release.Namespace }}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{{- if .Values.selfManagedCluster.enabled }}
apiVersion: infrastructure.cluster.x-k8s.io/v1beta1
kind: AzureMachinePool
metadata:
name: spool1
namespace: {{ .Release.Namespace }}
spec:
location: {{ .Values.location }}
template:
osDisk:
diskSizeGB: {{ .Values.systemPool.osDiskSizeGB }}
managedDisk:
storageAccountType: Standard_LRS
vmSize: {{ .Values.systemPool.sku }}
sshPublicKey: {{ .Values.sshPublicKey | b64enc }}
strategy:
strategy:
rollingUpdate:
maxSurge: 1
maxUnavailable: 0
additionalTags:
{{- with .Values.additionalTags }}
{{ toYaml . | indent 6 }}
{{- end }}
{{- end }}
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{{- if .Values.selfManagedCluster.enabled }}
apiVersion: infrastructure.cluster.x-k8s.io/v1beta1
kind: AzureMachineTemplate
metadata:
name: {{ .Values.global.clusterName }}-system
namespace: {{ .Release.Namespace }}
spec:
template:
spec:
vmSize: {{ .Values.systemPool.sku }}
osDisk:
diskSizeGB: {{ .Values.systemPool.osDiskSizeGB }}
osType: Linux
sshPublicKey: {{ .Values.sshPublicKey | b64enc }}
{{- end }}
---
{{- if .Values.selfManagedCluster.enabled }}
apiVersion: infrastructure.cluster.x-k8s.io/v1beta1
kind: AzureMachineTemplate
metadata:
name: {{ .Values.global.clusterName }}-user
namespace: {{ .Release.Namespace }}
spec:
template:
spec:
vmSize: {{ .Values.userPool.sku }}
osDisk:
diskSizeGB: {{ .Values.userPool.osDiskSizeGB }}
osType: Linux
sshPublicKey: {{ .Values.sshPublicKey | b64enc }}
{{- end }}
---
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
{{- if .Values.managedCluster }}
apiVersion: infrastructure.cluster.x-k8s.io/v1beta1
kind: AzureManagedCluster
metadata:
name: {{ .Values.global.clusterName }}
namespace: {{ .Release.Namespace }}
{{- end }}
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{{- if .Values.managedCluster }}
apiVersion: infrastructure.cluster.x-k8s.io/v1beta1
kind: AzureManagedControlPlane
metadata:
Expand Down Expand Up @@ -32,3 +33,4 @@ spec:
identityRef:
name: {{ .Values.global.clusterName }}-cluster-identity
kind: AzureClusterIdentity
{{- end }}
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
{{- if .Values.selfManagedCluster.enabled }}
apiVersion: cluster.x-k8s.io/v1beta1
kind: MachineDeployment
metadata:
name: {{ .Values.global.clusterName }}-md-0
namespace: {{ .Release.Namespace }}
spec:
clusterName: {{ .Values.global.clusterName }}
replicas: 1
selector:
matchLabels: null
template:
spec:
bootstrap:
configRef:
apiVersion: bootstrap.cluster.x-k8s.io/v1beta1
kind: KubeadmConfigTemplate
name: {{ .Values.global.clusterName }}-md-0
clusterName: {{ .Values.global.clusterName }}
infrastructureRef:
apiVersion: infrastructure.cluster.x-k8s.io/v1beta1
kind: AzureMachineTemplate
name: {{ .Values.global.clusterName }}-system
version: {{ .Values.global.kubernetes.version }}
failureDomain: "1"
{{- end }}
---
{{- if .Values.selfManagedCluster.enabled }}
apiVersion: cluster.x-k8s.io/v1beta1
kind: MachineDeployment
metadata:
name: {{ .Values.global.clusterName }}-md-1
namespace: {{ .Release.Namespace }}
spec:
clusterName: {{ .Values.global.clusterName }}
replicas: 1
selector:
matchLabels: null
template:
spec:
bootstrap:
configRef:
apiVersion: bootstrap.cluster.x-k8s.io/v1beta1
kind: KubeadmConfigTemplate
name: {{ .Values.global.clusterName }}-md-0
clusterName: {{ .Values.global.clusterName }}
infrastructureRef:
apiVersion: infrastructure.cluster.x-k8s.io/v1beta1
kind: AzureMachineTemplate
name: {{ .Values.global.clusterName }}-system
version: {{ .Values.global.kubernetes.version }}
failureDomain: "2"
{{- end }}
---
{{- if .Values.selfManagedCluster.enabled }}
apiVersion: cluster.x-k8s.io/v1beta1
kind: MachineDeployment
metadata:
name: {{ .Values.global.clusterName }}-md-2
namespace: {{ .Release.Namespace }}
spec:
clusterName: {{ .Values.global.clusterName }}
replicas: 1
selector:
matchLabels: null
template:
spec:
bootstrap:
configRef:
apiVersion: bootstrap.cluster.x-k8s.io/v1beta1
kind: KubeadmConfigTemplate
name: {{ .Values.global.clusterName }}-md-0
clusterName: {{ .Values.global.clusterName }}
infrastructureRef:
apiVersion: infrastructure.cluster.x-k8s.io/v1beta1
kind: AzureMachineTemplate
name: {{ .Values.global.clusterName }}-system
version: {{ .Values.global.kubernetes.version }}
failureDomain: "3"
{{- end }}
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
{{- if .Values.selfManagedCluster.enabled }}
apiVersion: cluster.x-k8s.io/v1beta1
kind: MachinePool
metadata:
labels:
cluster.x-k8s.io/cluster-name: {{ .Values.global.clusterName }}
name: {{ .Values.global.clusterName }}-vmu-0
namespace: {{ .Release.Namespace }}
spec:
clusterName: {{ .Values.global.clusterName }}
failureDomains:
- "1"
- "3"
replicas: 3
template:
spec:
clusterName: {{ .Values.global.clusterName }}
bootstrap:
configRef:
apiVersion: bootstrap.cluster.x-k8s.io/v1beta1
kind: KubeadmConfigTemplate
name: {{ .Values.global.clusterName }}-md-0
clusterName: {{ .Values.global.clusterName }}
infrastructureRef:
apiVersion: infrastructure.cluster.x-k8s.io/v1beta1
kind: AzureMachinePool
name: spool1
version: {{ .Values.global.kubernetes.version }}
{{- end }}
---
{{- if .Values.selfManagedCluster.enabled }}
apiVersion: cluster.x-k8s.io/v1beta1
kind: MachinePool
metadata:
labels:
cluster.x-k8s.io/cluster-name: {{ .Values.global.clusterName }}
name: {{ .Values.global.clusterName }}-vmus-0
namespace: {{ .Release.Namespace }}
spec:
clusterName: {{ .Values.global.clusterName }}
failureDomains:
- "1"
- "3"
replicas: 3
template:
spec:
clusterName: {{ .Values.global.clusterName }}
bootstrap:
configRef:
apiVersion: bootstrap.cluster.x-k8s.io/v1beta1
kind: KubeadmConfigTemplate
name: {{ .Values.global.clusterName }}-md-0
clusterName: {{ .Values.global.clusterName }}
infrastructureRef:
apiVersion: infrastructure.cluster.x-k8s.io/v1beta1
kind: AzureMachinePool
name: spool1
version: {{ .Values.global.kubernetes.version }}
{{- end }}
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{{- if .Values.selfManagedCluster.enabled }}
apiVersion: cluster.x-k8s.io/v1beta1
kind: MachinePool
metadata:
labels:
cluster.x-k8s.io/cluster-name: {{ .Values.global.clusterName }}
name: {{ .Values.global.clusterName }}-vmu-0
namespace: {{ .Release.Namespace }}
spec:
clusterName: {{ .Values.global.clusterName }}
failureDomains:
- "1"
- "3"
replicas: 3
template:
spec:
clusterName: {{ .Values.global.clusterName }}
bootstrap:
configRef:
apiVersion: bootstrap.cluster.x-k8s.io/v1beta1
kind: KubeadmConfigTemplate
name: {{ .Values.global.clusterName }}-md-0
clusterName: {{ .Values.global.clusterName }}
infrastructureRef:
apiVersion: infrastructure.cluster.x-k8s.io/v1beta1
kind: AzureMachineTemplate
name: {{ .Values.global.clusterName }}-user
version: {{ .Values.global.kubernetes.version }}
{{- end }}
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{{- if .Values.managedCluster }}
apiVersion: cluster.x-k8s.io/v1beta1
kind: MachinePool
metadata:
Expand All @@ -17,3 +18,4 @@ spec:
version: {{ .Values.global.kubernetes.version }}
bootstrap:
dataSecretName: {{ .Values.global.clientSecret}}
{{- end }}
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{{- if .Values.managedCluster }}
apiVersion: infrastructure.cluster.x-k8s.io/v1beta1
kind: AzureManagedMachinePool
metadata:
Expand All @@ -6,3 +7,4 @@ spec:
mode: System
osDiskSizeGB: {{ .Values.systemPool.osDiskSizeGB }}
sku: {{ .Values.systemPool.sku }}
{{- end }}
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{{- if .Values.managedCluster }}
apiVersion: cluster.x-k8s.io/v1beta1
kind: MachinePool
metadata:
Expand All @@ -16,4 +17,5 @@ spec:
namespace: {{ .Release.Namespace }}
version: {{ .Values.global.kubernetes.version }}
bootstrap:
dataSecretName: {{ .Values.global.clientSecret}}
dataSecretName: {{ .Values.global.clientSecret}}
{{- end }}
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{{- if .Values.managedCluster }}
apiVersion: infrastructure.cluster.x-k8s.io/v1beta1
kind: AzureManagedMachinePool
metadata:
Expand All @@ -6,3 +7,4 @@ spec:
mode: User
osDiskSizeGB: {{ .Values.userPool.osDiskSizeGB }}
sku: {{ .Values.userPool.sku }}
{{- end }}
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{{- if .Values.managedCluster }}
apiVersion: cluster.x-k8s.io/v1beta1
kind: Cluster
metadata:
Expand All @@ -9,14 +10,11 @@ spec:
cidrBlocks:
- {{ .Values.global.clusterNetwork.services.cidrBlocks }}
controlPlaneRef:
{{- if .Values.managedCluster }}
apiVersion: infrastructure.cluster.x-k8s.io/v1beta1
kind: AzureManagedControlPlane
name: {{ .Values.global.clusterName }}-control-plane
{{- end }}
infrastructureRef:
{{- if .Values.managedCluster }}
apiVersion: infrastructure.cluster.x-k8s.io/v1beta1
kind: AzureManagedCluster
name: {{ .Values.global.clusterName }}
{{- end }}
{{- end }}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{{- if .Values.selfManagedCluster.enabled }}
apiVersion: bootstrap.cluster.x-k8s.io/v1beta1
kind: KubeadmConfigTemplate
metadata:
name: {{ .Values.global.clusterName }}-md-0
namespace: {{ .Release.Namespace }}
spec:
template:
spec:
files:
- contentFrom:
secret:
key: sp.json
name: {{ .Values.selfManagedCluster.clientSecret.workerNodeAzure }}
owner: root:root
path: /etc/kubernetes/azure.json
permissions: "0644"
joinConfiguration:
nodeRegistration:
kubeletExtraArgs:
cloud-provider: external
name: {{ .Values.selfManagedCluster.localHostname }}
{{- end }}
Loading

0 comments on commit 9b9dedf

Please sign in to comment.