-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support Cluster API - Cluster AutoScaler integration
Signed-off-by: Archisman <archisman@obmondo.com>
- Loading branch information
Archisman
authored and
Klavs Klavsen
committed
Nov 11, 2024
1 parent
4af97fd
commit 726a1c6
Showing
11 changed files
with
154 additions
and
64 deletions.
There are no files selected for viewing
18 changes: 9 additions & 9 deletions
18
argocd-helm-charts/capi-cluster/charts/aws/templates/AWSMachinePool.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,20 @@ | ||
{{- if (.Values.global.capa).autoScaler }} | ||
{{- range $index, $machinePool := $.Values.machinePools }} | ||
{{- if (.Values.global.capa).enableMachinePools }} | ||
{{- range $index, $nodeGroup := $.Values.nodeGroups }} | ||
--- | ||
apiVersion: infrastructure.cluster.x-k8s.io/v1beta2 | ||
kind: AWSMachinePool | ||
metadata: | ||
name: {{ printf "%s-%s" $.Values.global.clusterName $machinePool.name }} | ||
name: {{ printf "%s-%s" $.Values.global.clusterName $nodeGroup.name }} | ||
spec: | ||
minSize: {{ $machinePool.minSize | default 1 }} | ||
maxSize: {{ $machinePool.maxSize | default 3 }} | ||
minSize: {{ $nodeGroup.minSize | default 1 }} | ||
maxSize: {{ $nodeGroup.maxSize | default 3 }} | ||
awsLaunchTemplate: | ||
ami: {{ toYaml $machinePool.ami | nindent 6 }} | ||
ami: {{ toYaml $nodeGroup.ami | nindent 6 }} | ||
iamInstanceProfile: nodes.cluster-api-provider-aws.sigs.k8s.io | ||
instanceType: {{ $machinePool.instanceType }} | ||
sshKeyName: {{ $machinePool.sshKeyName }} | ||
instanceType: {{ $nodeGroup.instanceType }} | ||
sshKeyName: {{ $nodeGroup.sshKeyName }} | ||
imageLookupBaseOS: ubuntu-20.04 | ||
rootVolume: | ||
size: {{ $machinePool.rootVolumeSize | default 35 }} | ||
size: {{ $nodeGroup.rootVolumeSize | default 35 }} | ||
{{- end }} | ||
{{- end }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 4 additions & 4 deletions
8
argocd-helm-charts/capi-cluster/charts/aws/templates/KubeadmConfig.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,18 @@ | ||
{{- if (.Values.global.capa).autoScaler }} | ||
{{- range $index, $machinePool := $.Values.machinePools }} | ||
{{- range $index, $nodeGroup := $.Values.nodeGroups }} | ||
--- | ||
apiVersion: bootstrap.cluster.x-k8s.io/v1beta1 | ||
kind: KubeadmConfig | ||
metadata: | ||
name: {{ printf "%s-%s" $.Values.global.clusterName $machinePool.name }} | ||
name: {{ printf "%s-%s" $.Values.global.clusterName $nodeGroup.name }} | ||
spec: | ||
joinConfiguration: | ||
nodeRegistration: | ||
kubeletExtraArgs: | ||
cloud-provider: external | ||
name: '{{"{{"}} ds.meta_data.local_hostname {{"}}"}}' | ||
{{- if $machinePool.taints }} | ||
taints: {{- toYaml $machinePool.taints | nindent 8 }} | ||
{{- if $nodeGroup.taints }} | ||
taints: {{- toYaml $nodeGroup.taints | nindent 8 }} | ||
{{- end }} | ||
{{- end }} | ||
{{- end }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 26 additions & 8 deletions
34
argocd-helm-charts/capi-cluster/charts/aws/templates/MachineDeployment.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,40 @@ | ||
{{- if (not (.Values.global.capa).autoScaler) }} | ||
{{- if (.Values.global).enableClusterAutoscaler }} | ||
{{- range $index, $nodeGroup := $.Values.nodeGroups }} | ||
--- | ||
apiVersion: cluster.x-k8s.io/v1beta1 | ||
kind: MachineDeployment | ||
metadata: | ||
name: {{ .Values.global.clusterName }}-md-0 | ||
name: {{ printf "%s-%s" $.Values.global.clusterName $nodeGroup.name }} | ||
annotations: | ||
cluster.x-k8s.io/cluster-api-autoscaler-node-group-min-size: {{ $nodeGroup.minSize | default 1 | quote }} | ||
cluster.x-k8s.io/cluster-api-autoscaler-node-group-max-size: {{ $nodeGroup.maxSize | default 3 | quote }} | ||
spec: | ||
clusterName: {{ .Values.global.clusterName }} | ||
replicas: {{ .Values.workerNodes.replicas }} | ||
clusterName: {{ $.Values.global.clusterName }} | ||
replicas: {{ $nodeGroup.replicas | default 2 }} | ||
template: | ||
{{- if $nodeGroup.labels }} | ||
metadata: | ||
# Label should meet one of the following criterias to propagate to Node : | ||
# | ||
# (1) Has node-role.kubernetes.io as prefix. | ||
# (2) Belongs to node-restriction.kubernetes.io domain. | ||
# (3) Belongs to node.cluster.x-k8s.io domain. | ||
# | ||
# REFER : https://cluster-api.sigs.k8s.io/developer/architecture/controllers/metadata-propagation#machine | ||
labels: {{- toYaml $nodeGroup.labels | nindent 8 }} | ||
{{- end }} | ||
|
||
spec: | ||
clusterName: {{ $.Values.global.clusterName }} | ||
bootstrap: | ||
configRef: | ||
apiVersion: bootstrap.cluster.x-k8s.io/v1beta1 | ||
kind: KubeadmConfigTemplate | ||
name: {{ .Values.global.clusterName }} | ||
clusterName: {{ .Values.global.clusterName }} | ||
name: {{ printf "%s-%s" $.Values.global.clusterName $nodeGroup.name }} | ||
infrastructureRef: | ||
apiVersion: infrastructure.cluster.x-k8s.io/v1beta2 | ||
kind: AWSMachineTemplate | ||
name: {{ .Values.global.clusterName }}-md-0 | ||
version: {{ .Values.global.kubernetes.version }} | ||
name: {{ printf "%s-%s" $.Values.global.clusterName $nodeGroup.name }} | ||
version: {{ $.Values.global.kubernetes.version }} | ||
{{- end }} | ||
{{- end }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 40 additions & 0 deletions
40
argocd-helm-charts/capi-cluster/examples/aws/cluster-autoscaler.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
global: | ||
clusterName: kubeaid-demo | ||
kubeaidConfig: | ||
repo: https://github.com/Archisman-Mridha/kubeaid-config | ||
|
||
provider: | ||
aws: true | ||
|
||
aws: | ||
secretName: cloud-credentials | ||
sshKeyName: kubeaid-demo | ||
region: us-east-1 | ||
bastion: | ||
enabled: true | ||
vpc: | ||
cidrBlock: 10.14.0.0/22 | ||
pods: | ||
cidrBlock: 10.244.0.0/16 | ||
controlPlane: | ||
loadBalancer: | ||
loadBalancerType: nlb | ||
region: us-east-1 | ||
replicas: 1 | ||
instanceType: t4g.medium | ||
ami: | ||
id: ami-0fc044fa0d061d18d | ||
nodeGroups: | ||
- name: primary | ||
# minSize: 1 | ||
# maxSize: 3 | ||
# replicas: 2 | ||
instanceType: t4g.medium | ||
sshKeyName: kubeaid-demo | ||
ami: | ||
id: ami-0fc044fa0d061d18d | ||
rootVolumeSize: 35 | ||
labels: | ||
node.cluster.x-k8s.io/nodegroup: primary | ||
node-role.kubernetes.io/bootstrapper: "" | ||
taints: [] |
43 changes: 43 additions & 0 deletions
43
argocd-helm-charts/capi-cluster/examples/aws/machinepools.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
global: | ||
clusterName: kubeaid-demo | ||
enableClusterAutoscaler: false | ||
capa: | ||
enableMachinePools: true | ||
kubeaidConfig: | ||
repo: https://github.com/Archisman-Mridha/kubeaid-config | ||
|
||
provider: | ||
aws: true | ||
|
||
aws: | ||
secretName: cloud-credentials | ||
sshKeyName: kubeaid-demo | ||
region: us-east-1 | ||
bastion: | ||
enabled: true | ||
vpc: | ||
cidrBlock: 10.14.0.0/22 | ||
pods: | ||
cidrBlock: 10.244.0.0/16 | ||
controlPlane: | ||
loadBalancer: | ||
loadBalancerType: nlb | ||
region: us-east-1 | ||
replicas: 1 | ||
instanceType: t4g.medium | ||
ami: | ||
id: ami-0fc044fa0d061d18d | ||
nodeGroups: | ||
- name: primary | ||
# minSize: 1 | ||
# maxSize: 3 | ||
# replicas: 2 | ||
instanceType: t4g.medium | ||
sshKeyName: kubeaid-demo | ||
ami: | ||
id: ami-0fc044fa0d061d18d | ||
rootVolumeSize: 35 | ||
labels: | ||
node.cluster.x-k8s.io/nodegroup: primary | ||
node-role.kubernetes.io/bootstrapper: "" | ||
taints: [] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters