Skip to content
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
154 changes: 154 additions & 0 deletions examples/clusterclasses/aws/eks/clusterclass-eks-example.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,154 @@
apiVersion: cluster.x-k8s.io/v1beta1
kind: ClusterClass
metadata:
name: aws-eks-example
spec:
controlPlane:
ref:
apiVersion: controlplane.cluster.x-k8s.io/v1beta2
kind: AWSManagedControlPlaneTemplate
name: "eks-control-plane"
infrastructure:
ref:
apiVersion: infrastructure.cluster.x-k8s.io/v1beta2
kind: AWSManagedClusterTemplate
name: "eks-cluster"
workers:
machineDeployments:
- class: default-worker
template:
bootstrap:
ref:
name: "eks-md-0"
apiVersion: bootstrap.cluster.x-k8s.io/v1beta2
kind: EKSConfigTemplate
infrastructure:
ref:
name: "eks-md-0"
apiVersion: infrastructure.cluster.x-k8s.io/v1beta2
kind: AWSMachineTemplate
variables:
- name: region
required: true
schema:
openAPIV3Schema:
description: "The AWS region where the Cluster will be created"
type: string
- name: sshKeyName
required: false
schema:
openAPIV3Schema:
description: "AWS SSH key name to use"
type: string
default: ''
- name: instanceType
required: false
schema:
openAPIV3Schema:
description: "AWS instance type to use"
type: string
default: "t3.xlarge"
- name: eksClusterName
required: false
schema:
openAPIV3Schema:
description: "EKS cluster name"
type: string
default: ''
- name: awsClusterIdentityName
required: true
schema:
openAPIV3Schema:
description: The AWSClusterStaticIdentity resource name referencing the credentials to create the Cluster.
type: string
default: cluster-identity
patches:
- name: awsManagedControlPlaneTemplate
definitions:
- selector:
apiVersion: controlplane.cluster.x-k8s.io/v1beta2
kind: AWSManagedControlPlaneTemplate
matchResources:
controlPlane: true
jsonPatches:
- op: add
enabledIf: '{{ ne .eksClusterName }}'
path: /spec/template/spec/eksClusterName
valueFrom:
variable: eksClusterName
- op: add
path: /spec/template/spec/region
valueFrom:
variable: region
- op: add
enabledIf: '{{ ne .sshKeyName }}'
path: /spec/template/spec/sshKeyName
valueFrom:
variable: sshKeyName
- op: add
path: /spec/template/spec/identityRef/name
valueFrom:
variable: awsClusterIdentityName
# Builtins
- op: add
path: "/spec/template/spec/version"
valueFrom:
variable: builtin.cluster.topology.version
- name: awsMachineTemplate
definitions:
- selector:
apiVersion: infrastructure.cluster.x-k8s.io/v1beta2
kind: AWSMachineTemplate
matchResources:
machineDeploymentClass:
names:
- default-worker
jsonPatches:
- op: add
enabledIf: '{{ ne .sshKeyName }}'
path: /spec/template/spec/sshKeyName
valueFrom:
variable: sshKeyName
- op: add
path: /spec/template/spec/instanceType
valueFrom:
variable: instanceType
---
kind: AWSManagedClusterTemplate
apiVersion: infrastructure.cluster.x-k8s.io/v1beta2
metadata:
name: "eks-cluster"
spec:
template:
spec: {}
---
kind: AWSManagedControlPlaneTemplate
apiVersion: controlplane.cluster.x-k8s.io/v1beta2
metadata:
name: "eks-control-plane"
spec:
template:
spec:
region: "replaced_by_patch"
version: "v0.0.0" # To be replaced by patch
identityRef:
kind: AWSClusterStaticIdentity
name: cluster-identity
---
apiVersion: infrastructure.cluster.x-k8s.io/v1beta2
kind: AWSMachineTemplate
metadata:
name: "eks-md-0"
spec:
template:
spec:
instanceType: "replaced_by_patch"
iamInstanceProfile: "nodes.cluster-api-provider-aws.sigs.k8s.io"
---
apiVersion: bootstrap.cluster.x-k8s.io/v1beta2
kind: EKSConfigTemplate
metadata:
name: "eks-md-0"
spec:
template:
spec: {}
4 changes: 2 additions & 2 deletions test/e2e/const.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,8 @@ var (
//go:embed data/cluster-templates/docker-rke2-topology.yaml
CAPIDockerRKE2Topology []byte

//go:embed data/cluster-templates/aws-eks-mmp.yaml
CAPIAwsEKSMMP []byte
//go:embed data/cluster-templates/aws-eks-topology.yaml
CAPIAwsEKSTopology []byte

//go:embed data/cluster-templates/aws-ec2-rke2-topology.yaml
CAPIAwsEC2RKE2Topology []byte
Expand Down
77 changes: 0 additions & 77 deletions test/e2e/data/cluster-templates/aws-eks-mmp.yaml

This file was deleted.

38 changes: 38 additions & 0 deletions test/e2e/data/cluster-templates/aws-eks-topology.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
apiVersion: infrastructure.cluster.x-k8s.io/v1beta2
kind: AWSClusterStaticIdentity
metadata:
name: cluster-identity
spec:
secretRef: cluster-identity
allowedNamespaces: {}
---
apiVersion: cluster.x-k8s.io/v1beta1
kind: Cluster
metadata:
name: ${CLUSTER_NAME}
namespace: "${NAMESPACE}"
labels:
cluster-api.cattle.io/rancher-auto-import: "true"
spec:
clusterNetwork:
pods:
cidrBlocks:
- 192.168.0.0/16
topology:
class: aws-eks-example
classNamespace: ${TOPOLOGY_NAMESPACE}
version: ${AWS_KUBERNETES_VERSION}
variables:
- name: region
value: ${AWS_REGION}
- name: sshKeyName
value: ${AWS_SSH_KEY_NAME}
- name: instanceType
value: t3.xlarge
- name: awsClusterIdentityName
value: cluster-identity
workers:
machineDeployments:
- class: default-worker
name: md-0
replicas: ${WORKER_MACHINE_COUNT}
20 changes: 18 additions & 2 deletions test/e2e/suites/import-gitops/import_gitops_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -261,17 +261,21 @@ var _ = Describe("[Azure] [RKE2] Create and delete CAPI cluster from cluster cla
})
})

var _ = Describe("[AWS] [EKS] Create and delete CAPI cluster functionality should work with namespace auto-import", Label(e2e.FullTestLabel), func() {
var _ = Describe("[AWS] [EKS] Create and delete CAPI cluster from cluster class", Label(e2e.FullTestLabel), func() {
var topologyNamespace string

BeforeEach(func() {
komega.SetClient(bootstrapClusterProxy.GetClient())
komega.SetContext(ctx)

topologyNamespace = "creategitops-aws-eks"
})

specs.CreateUsingGitOpsSpec(ctx, func() specs.CreateUsingGitOpsSpecInput {
return specs.CreateUsingGitOpsSpecInput{
E2EConfig: e2e.LoadE2EConfig(),
BootstrapClusterProxy: bootstrapClusterProxy,
ClusterTemplate: e2e.CAPIAwsEKSMMP,
ClusterTemplate: e2e.CAPIAwsEKSTopology,
ClusterName: "cluster-eks",
ControlPlaneMachineCount: ptr.To(1),
WorkerMachineCount: ptr.To(1),
Expand All @@ -282,6 +286,18 @@ var _ = Describe("[AWS] [EKS] Create and delete CAPI cluster functionality shoul
CapiClusterOwnerLabel: e2e.CapiClusterOwnerLabel,
CapiClusterOwnerNamespaceLabel: e2e.CapiClusterOwnerNamespaceLabel,
OwnedLabelName: e2e.OwnedLabelName,
TopologyNamespace: topologyNamespace,
AdditionalTemplateVariables: map[string]string{
e2e.KubernetesVersionVar: e2e.LoadE2EConfig().GetVariableOrEmpty(e2e.AWSKubernetesVersionVar), // override the default k8s version
},
AdditionalFleetGitRepos: []turtlesframework.FleetCreateGitRepoInput{
{
Name: "aws-cluster-classes-eks",
Paths: []string{"examples/clusterclasses/aws/eks"},
ClusterProxy: bootstrapClusterProxy,
TargetNamespace: topologyNamespace,
},
},
}
})
})
Expand Down