Skip to content

Commit

Permalink
cluster-api-aws: add EKS support
Browse files Browse the repository at this point in the history
  • Loading branch information
zugwan committed Feb 1, 2023
1 parent e5cf05a commit 839ecde
Show file tree
Hide file tree
Showing 9 changed files with 89 additions and 27 deletions.
2 changes: 1 addition & 1 deletion cluster-api-aws/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ description: A chart to install Kubernetes cluster using Cluster API Provider AW

type: application

version: 0.7.0
version: 0.8.0

appVersion: "1.0.0"
2 changes: 2 additions & 0 deletions cluster-api-aws/templates/aws-cluster.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{{- if not .Values.cluster.eksEnabled }}
apiVersion: {{ .Values.api.group.infrastructure }}/v1beta2
kind: AWSCluster
metadata:
Expand All @@ -23,3 +24,4 @@ spec:
{{- if .Values.cluster.baseOS }}
imageLookupBaseOS: {{ .Values.cluster.baseOS }}
{{- end }}
{{- end }}
20 changes: 0 additions & 20 deletions cluster-api-aws/templates/aws-machinetemplates-control-plane.yaml

This file was deleted.

11 changes: 11 additions & 0 deletions cluster-api-aws/templates/aws-managed-control-plane.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{{- if .Values.cluster.eksEnabled }}
apiVersion: {{ .Values.api.group.controlplane }}/{{ .Values.api.version }}
kind: AWSManagedControlPlane
metadata:
name: "{{ .Values.cluster.name }}-eks-control-plane"
namespace: {{ .Release.Namespace }}
spec:
region: {{ .Values.cluster.region }}
sshKeyName: {{ .Values.sshKeyName }}
version: {{ .Values.cluster.kubernetesVersion }}
{{- end }}
13 changes: 12 additions & 1 deletion cluster-api-aws/templates/cluster.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,21 @@ spec:
cidrBlocks: {{ .Values.cluster.podCidrBlocks }}
{{- end }}
infrastructureRef:
{{- if .Values.cluster.eksEnabled }}
apiVersion: {{ .Values.api.group.controlplane }}/{{ .Values.api.version }}
kind: AWSManagedControlPlane
name: "{{ .Values.cluster.name }}-eks-control-plane"
{{- else }}
apiVersion: {{ .Values.api.group.infrastructure }}/v1beta2
kind: AWSCluster
name: {{ .Values.cluster.name }}
{{- end }}
controlPlaneRef:
kind: KubeadmControlPlane
apiVersion: {{ .Values.api.group.controlplane }}/{{ .Values.api.version }}
name: "{{ .Values.cluster.name }}-control-plane"
{{- if .Values.cluster.eksEnabled }}
kind: AWSManagedControlPlane
name: "{{ .Values.cluster.name }}-eks-control-plane"
{{- else }}
kind: KubeadmControlPlane
{{- end }}
21 changes: 20 additions & 1 deletion cluster-api-aws/templates/kubeadm-control-plane.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{{- if .Values.kubeadmControlPlane.enabled }}
{{- if not .Values.cluster.eksEnabled }}
kind: KubeadmControlPlane
apiVersion: {{ .Values.api.group.controlplane }}/{{ .Values.api.version }}
metadata:
Expand Down Expand Up @@ -30,4 +30,23 @@ spec:
kubeletExtraArgs:
cloud-provider: aws
version: {{ .Values.cluster.kubernetesVersion }}
---
apiVersion: {{ .Values.api.group.infrastructure }}/v1beta2
kind: AWSMachineTemplate
metadata:
name: {{ .Values.cluster.name }}-control-plane
namespace: {{ .Release.Namespace }}
spec:
template:
spec:
iamInstanceProfile: control-plane.cluster-api-provider-aws.sigs.k8s.io
instanceType: {{ .Values.kubeadmControlPlane.controlPlaneMachineType }}
sshKeyName: {{ .Values.sshKeyName }}
rootVolume:
size: {{ .Values.kubeadmControlPlane.rootVolume.size }}
type: {{ .Values.kubeadmControlPlane.rootVolume.type }}
{{- if .Values.kubeadmControlPlane.ami }}
ami:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- end }}
20 changes: 19 additions & 1 deletion cluster-api-aws/templates/machine-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,11 @@
apiVersion: {{ $envAll.Values.api.group.cluster }}/{{ $envAll.Values.api.version }}
kind: MachineDeployment
metadata:
{{- if $envAll.Values.cluster.eksEnabled }}
name: {{ $envAll.Values.cluster.name }}-eks-md-{{ $mdName }}-{{ . }}
{{- else }}
name: {{ $envAll.Values.cluster.name }}-md-{{ $mdName }}-{{ . }}
{{- end }}
namespace: {{ $envAll.Release.Namespace }}
annotations:
cluster.x-k8s.io/cluster-api-autoscaler-node-group-min-size: "{{ $minSizePerAZ }}"
Expand All @@ -27,8 +31,13 @@ spec:
bootstrap:
configRef:
apiVersion: {{ $envAll.Values.api.group.bootstrap }}/{{ $envAll.Values.api.version }}
{{- if $envAll.Values.cluster.eksEnabled }}
kind: EKSConfigTemplate
name: {{ $envAll.Values.cluster.name }}-eks-md-{{ $mdName }}
{{- else }}
kind: KubeadmConfigTemplate
name: {{ $envAll.Values.cluster.name }}-md-{{ $mdName }}
{{- end }}
clusterName: {{ $envAll.Values.cluster.name }}
failureDomain: {{ $envAll.Values.cluster.region }}{{ index $azPostfixList . }}
infrastructureRef:
Expand Down Expand Up @@ -70,6 +79,15 @@ spec:
values:
- "*{{ $envAll.Values.cluster.name }}*"
---
{{- if $envAll.Values.cluster.eksEnabled }}
apiVersion: {{ $envAll.Values.api.group.bootstrap }}/{{ $envAll.Values.api.version }}
kind: EKSConfigTemplate
metadata:
name: {{ $envAll.Values.cluster.name }}-eks-md-{{ $mdName }}
namespace: {{ $envAll.Release.Namespace }}
spec:
template: {}
{{- else }}
apiVersion: {{ $envAll.Values.api.group.bootstrap }}/{{ $envAll.Values.api.version }}
kind: KubeadmConfigTemplate
metadata:
Expand All @@ -83,5 +101,5 @@ spec:
kubeletExtraArgs:
cloud-provider: aws
name: '{{`{{ ds.meta_data.local_hostname }}`}}'
---
{{- end }}
{{- end }}
23 changes: 23 additions & 0 deletions cluster-api-aws/templates/machine-pool.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,20 +17,42 @@ spec:
{{- end }}
spec:
bootstrap:
{{- if $envAll.Values.cluster.eksEnabled }}
dataSecretName: ""
{{- else }}
configRef:
apiVersion: {{ $envAll.Values.api.group.bootstrap }}/{{ $envAll.Values.api.version }}
kind: KubeadmConfig
name: {{ $envAll.Values.cluster.name }}-mp-{{ .name }}
namespace: {{ $envAll.Release.Namespace }}
{{- end }}
clusterName: {{ $envAll.Values.cluster.name }}
infrastructureRef:
apiVersion: {{ $envAll.Values.api.group.infrastructure }}/v1beta2
{{- if $envAll.Values.cluster.eksEnabled }}
kind: AWSManagedMachinePool
{{- else }}
kind: AWSMachinePool
{{- end }}
name: {{ $envAll.Values.cluster.name }}-mp-{{ .name }}
namespace: {{ $envAll.Release.Namespace }}
version: {{ $envAll.Values.cluster.kubernetesVersion }}
---
apiVersion: {{ $envAll.Values.api.group.infrastructure }}/v1beta2
{{- if $envAll.Values.cluster.eksEnabled }}
kind: AWSManagedMachinePool
metadata:
name: {{ $envAll.Values.cluster.name }}-mp-{{ .name }}
namespace: {{ $envAll.Release.Namespace }}
spec:
instanceType: {{ .machineType }}
diskSize: {{ .rootVolume.size }}
scaling:
maxSize: {{ .maxSize }}
minSize: {{ .minSize }}
remoteAccess:
sshKeyName: {{ $envAll.Values.sshKeyName }}
{{- else }}
kind: AWSMachinePool
metadata:
name: {{ $envAll.Values.cluster.name }}-mp-{{ .name }}
Expand Down Expand Up @@ -70,3 +92,4 @@ spec:
cloud-provider: aws
name: '{{`{{ ds.meta_data.local_hostname }}`}}'
{{- end }}
{{- end }}
4 changes: 1 addition & 3 deletions cluster-api-aws/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ sshKeyName: default
cluster:
name: capi-quickstart
region: ap-northeast-2
eksEnabled: false
# networkSpec:
# vpc:
# id: vpc-id
Expand Down Expand Up @@ -44,7 +45,6 @@ api:
version: v1beta1

kubeadmControlPlane:
enabled: true
replicas: 3
controlPlaneMachineType: t3.large
rootVolume:
Expand All @@ -66,7 +66,6 @@ machinePool: []
# maxSize: 10
# rootVolume:
# size: 200
# type: gp2
# subnets: []
# labels: []
# **this version dosen't support the spot instance, because the aws cluster api provider doesn't support it in awsmachinpool**
Expand All @@ -81,7 +80,6 @@ machinePool: []
# maxSize: 10
# rootVolume:
# size: 8
# type: gp2
# subnets: []
# labels: []

Expand Down

0 comments on commit 839ecde

Please sign in to comment.