Skip to content

Commit

Permalink
Added EKS template (k0rdent#430)
Browse files Browse the repository at this point in the history
  • Loading branch information
slysunkin authored Oct 11, 2024
1 parent 359b099 commit aba826a
Show file tree
Hide file tree
Showing 16 changed files with 360 additions and 0 deletions.
2 changes: 2 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -319,6 +319,8 @@ dev-azure-creds: envsubst
dev-vsphere-creds: envsubst
@NAMESPACE=$(NAMESPACE) $(ENVSUBST) -no-unset -i config/dev/vsphere-credentials.yaml | $(KUBECTL) apply -f -

dev-eks-creds: dev-aws-creds

.PHONY: dev-apply ## Apply the development environment by deploying the kind cluster, local registry and the HMC helm chart.
dev-apply: kind-deploy registry-deploy dev-push dev-deploy dev-templates dev-release

Expand Down
11 changes: 11 additions & 0 deletions config/dev/eks-managedcluster.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
apiVersion: hmc.mirantis.com/v1alpha1
kind: ManagedCluster
metadata:
name: eks-dev
namespace: ${NAMESPACE}
spec:
config:
region: us-east-2
workersNumber: 1
template: aws-eks-0-0-1
credential: "aws-cluster-identity-cred"
8 changes: 8 additions & 0 deletions docs/dev.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,14 @@ full explanation for each parameter visit
[vSphere cluster parameters](cluster-parameters.md) and
[vSphere machine parameters](machine-parameters.md).

### EKS Provider Setup

To properly deploy dev cluster you need to have the following variable set:

- `DEV_PROVIDER` - should be "eks"

The rest of deployment procedure is the same as for other providers.

## Deploy HMC

Default provider which will be used to deploy cluster is AWS, if you want to use
Expand Down
23 changes: 23 additions & 0 deletions templates/cluster/aws-eks/.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/
13 changes: 13 additions & 0 deletions templates/cluster/aws-eks/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
apiVersion: v2
name: aws-eks
description: |
An HMC template to deploy a cluster on EKS with bootstrapped control plane nodes.
type: application
# This is the chart version. This version number should be incremented each time you make changes
# to the chart and its templates, including the app version.
# Versions are expected to follow Semantic Versioning (https://semver.org/)
version: 0.0.1
annotations:
hmc.mirantis.com/infrastructure-providers: aws
hmc.mirantis.com/controlplane-providers: eks
hmc.mirantis.com/bootstrap-providers: eks
19 changes: 19 additions & 0 deletions templates/cluster/aws-eks/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{{- define "cluster.name" -}}
{{- .Release.Name | trunc 63 | trimSuffix "-" }}
{{- end }}

{{- define "awsmachinetemplate.worker.name" -}}
{{- include "cluster.name" . }}-worker-mt
{{- end }}

{{- define "machinedeployment.name" -}}
{{- include "cluster.name" . }}-md
{{- end }}

{{- define "awsmanagedcontrolplane.name" -}}
{{- include "cluster.name" . }}-cp
{{- end }}

{{- define "eksconfigtemplate.name" -}}
{{- include "cluster.name" . }}-machine-config
{{- end }}
22 changes: 22 additions & 0 deletions templates/cluster/aws-eks/templates/awsmachinetemplate-worker.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
apiVersion: infrastructure.cluster.x-k8s.io/v1beta2
kind: AWSMachineTemplate
metadata:
name: {{ include "awsmachinetemplate.worker.name" . }}
spec:
template:
spec:
{{- if not (quote .Values.worker.amiID | empty) }}
ami:
id: {{ .Values.worker.amiID }}
{{- end }}
imageLookupFormat: {{ .Values.worker.imageLookup.format }}
imageLookupOrg: {{ .Values.worker.imageLookup.org }}
imageLookupBaseOS: {{ .Values.worker.imageLookup.baseOS }}
instanceType: {{ .Values.worker.instanceType }}
iamInstanceProfile: {{ .Values.worker.iamInstanceProfile }}
publicIP: {{ .Values.publicIP }}
rootVolume:
size: {{ .Values.worker.rootVolumeSize }}
{{- if not (quote .Values.sshKeyName | empty) }}
sshKeyName: {{ .Values.sshKeyName | quote }}
{{- end }}
7 changes: 7 additions & 0 deletions templates/cluster/aws-eks/templates/awsmanagedcluster.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
apiVersion: infrastructure.cluster.x-k8s.io/v1beta2
kind: AWSManagedCluster
metadata:
name: {{ include "cluster.name" . }}
annotations:
aws.cluster.x-k8s.io/external-resource-gc: "true"
spec: {}
14 changes: 14 additions & 0 deletions templates/cluster/aws-eks/templates/awsmanagedcontrolplane.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
apiVersion: controlplane.cluster.x-k8s.io/v1beta2
kind: AWSManagedControlPlane
metadata:
name: {{ include "awsmanagedcontrolplane.name" . }}
namespace: hmc-system
spec:
region: {{ .Values.region }}
{{- if not (quote .Values.sshKeyName | empty) }}
sshKeyName: {{ .Values.sshKeyName | quote }}
{{- end }}
version: {{ .Values.kubernetes.version }}
identityRef:
kind: {{ .Values.clusterIdentity.kind }}
name: {{ .Values.clusterIdentity.name }}
17 changes: 17 additions & 0 deletions templates/cluster/aws-eks/templates/cluster.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
apiVersion: cluster.x-k8s.io/v1beta1
kind: Cluster
metadata:
name: {{ include "cluster.name" . }}
spec:
{{- with .Values.clusterNetwork }}
clusterNetwork:
{{- toYaml . | nindent 4 }}
{{- end }}
controlPlaneRef:
apiVersion: controlplane.cluster.x-k8s.io/v1beta2
kind: AWSManagedControlPlane
name: {{ include "awsmanagedcontrolplane.name" . }}
infrastructureRef:
apiVersion: infrastructure.cluster.x-k8s.io/v1beta2
kind: AWSManagedCluster
name: {{ include "cluster.name" . }}
6 changes: 6 additions & 0 deletions templates/cluster/aws-eks/templates/eksconfigtemplate.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
apiVersion: bootstrap.cluster.x-k8s.io/v1beta2
kind: EKSConfigTemplate
metadata:
name: {{ include "eksconfigtemplate.name" . }}
spec:
template: {}
26 changes: 26 additions & 0 deletions templates/cluster/aws-eks/templates/machinedeployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
apiVersion: cluster.x-k8s.io/v1beta1
kind: MachineDeployment
metadata:
name: {{ include "machinedeployment.name" . }}
spec:
clusterName: {{ include "cluster.name" . }}
replicas: {{ .Values.workersNumber }}
selector:
matchLabels:
cluster.x-k8s.io/cluster-name: {{ include "cluster.name" . }}
template:
metadata:
labels:
cluster.x-k8s.io/cluster-name: {{ include "cluster.name" . }}
spec:
version: {{ .Values.kubernetes.version }}
clusterName: {{ include "cluster.name" . }}
bootstrap:
configRef:
apiVersion: bootstrap.cluster.x-k8s.io/v1beta2
kind: EKSConfigTemplate
name: {{ include "eksconfigtemplate.name" . }}
infrastructureRef:
apiVersion: infrastructure.cluster.x-k8s.io/v1beta2
kind: AWSMachineTemplate
name: {{ include "awsmachinetemplate.worker.name" . }}
146 changes: 146 additions & 0 deletions templates/cluster/aws-eks/values.schema.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,146 @@
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"description": "An HMC template to deploy a ManagedCluster on EKS.",
"type": "object",
"required": [
"workersNumber",
"region",
"clusterIdentity"
],
"properties": {
"workersNumber": {
"description": "The number of the worker machines",
"type": "number",
"minimum": 1
},
"clusterNetwork": {
"type": "object",
"properties": {
"pods": {
"type": "object",
"properties": {
"cidrBlocks": {
"type": "array",
"items": {
"type": "string"
},
"minItems": 1,
"uniqueItems": true
}
}
},
"services": {
"type": "object",
"properties": {
"cidrBlocks": {
"type": "array",
"items": {
"type": "string"
},
"minItems": 1,
"uniqueItems": true
}
}
}
}
},
"region": {
"description": "AWS region to deploy the cluster in",
"type": "string"
},
"sshKeyName": {
"description": "The name of the key pair to securely connect to your instances. Valid values are empty string (do not use SSH keys), a valid SSH key name, or omitted (use the default SSH key name)",
"type": [
"string",
"null"
]
},
"publicIP": {
"description": "Specifies whether the instance should get a public IP",
"type": "boolean"
},
"clusterIdentity": {
"type": "object",
"description": "AWS Cluster Identity object reference",
"required": [
"name",
"kind"
],
"properties": {
"name": {
"description": "AWS ClusterIdentity object name",
"type": "string"
},
"kind": {
"description": "AWS ClusterIdentity object kind",
"type": "string"
}
}
},
"worker": {
"description": "The configuration of the worker machines",
"type": "object",
"required": [
"iamInstanceProfile",
"instanceType"
],
"properties": {
"amiID": {
"description": "The ID of Amazon Machine Image",
"type": "string"
},
"iamInstanceProfile": {
"description": "The name of an IAM instance profile to assign to the instance",
"type": "string"
},
"instanceType": {
"description": "The type of instance to create",
"type": "string"
},
"additionalSecurityGroupIDs": {
"description": "An array of references to security groups that should be applied to the instance",
"type": "array"
},
"rootVolumeSize": {
"description": "The size of the root volume of the instance (GB)",
"type": "integer"
},
"imageLookup": {
"description": "AMI lookup parameters",
"type": "object",
"required": [
"format",
"org"
],
"properties": {
"format": {
"description": "Format string which will be used for image lookup",
"type": "string"
},
"org": {
"description": "AWS org ID which owns the AMI",
"type": "string"
},
"baseOS": {
"description": "OS name which can be used in format string",
"type": "string"
}
}
}
}
},
"kubernetes": {
"description": "Kubernetes parameters",
"type": "object",
"required": [
"version"
],
"properties": {
"version": {
"description": "Kubernetes version to use",
"type": "string"
}
}
}
}
}
34 changes: 34 additions & 0 deletions templates/cluster/aws-eks/values.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# Cluster parameters
workersNumber: 1

clusterNetwork:
pods:
cidrBlocks:
- "10.244.0.0/16"
services:
cidrBlocks:
- "10.96.0.0/12"

# EKS cluster parameters
region: ""
sshKeyName: ""
publicIP: false

clusterIdentity:
name: "aws-cluster-identity"
kind: "AWSClusterStaticIdentity"

# EKS machines parameters
worker:
amiID: ""
iamInstanceProfile: nodes.cluster-api-provider-aws.sigs.k8s.io
instanceType: "t3.small"
rootVolumeSize: 30
imageLookup:
format: ""
org: ""
baseOS: ""

# Kubernetes version
kubernetes:
version: v1.30.4
2 changes: 2 additions & 0 deletions templates/provider/cluster-api-provider-aws/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,5 @@ version: 0.0.1
appVersion: "2.6.1"
annotations:
hmc.mirantis.com/infrastructure-providers: aws
hmc.mirantis.com/controlplane-providers: eks
hmc.mirantis.com/bootstrap-providers: eks
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
apiVersion: hmc.mirantis.com/v1alpha1
kind: ClusterTemplate
metadata:
name: aws-eks-0-0-1
annotations:
helm.sh/resource-policy: keep
spec:
helm:
chartName: aws-eks
chartVersion: 0.0.1

0 comments on commit aba826a

Please sign in to comment.