Skip to content

Commit

Permalink
test: cover clusterclass in e2e tests
Browse files Browse the repository at this point in the history
Signed-off-by: Carlos Salas <carlos.salas@suse.com>
  • Loading branch information
salasberryfin committed Aug 29, 2024
1 parent 05ffb70 commit c4dca18
Show file tree
Hide file tree
Showing 7 changed files with 585 additions and 26 deletions.
2 changes: 2 additions & 0 deletions test/e2e/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ const (
KubernetesVersionUpgradeTo = "KUBERNETES_VERSION_UPGRADE_TO"
CPMachineTemplateUpgradeTo = "CONTROL_PLANE_MACHINE_TEMPLATE_UPGRADE_TO"
WorkersMachineTemplateUpgradeTo = "WORKERS_MACHINE_TEMPLATE_UPGRADE_TO"
ControlPlaneMachineCount = "CONTROL_PLANE_MACHINE_COUNT"
WorkerMachineCount = "WORKER_MACHINE_COUNT"
IPFamily = "IP_FAMILY"
KindImageVersion = "KIND_IMAGE_VERSION"
)
Expand Down
5 changes: 3 additions & 2 deletions test/e2e/config/e2e_conf.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -126,14 +126,15 @@ variables:
KUBERNETES_VERSION: "v1.28.1"
KIND_IMAGE_VERSION: "v1.28.0"
NODE_DRAIN_TIMEOUT: "60s"
CONFORMANCE_WORKER_MACHINE_COUNT: "2"
CONFORMANCE_CONTROL_PLANE_MACHINE_COUNT: "1"
WORKER_MACHINE_COUNT: "2"
CONTROL_PLANE_MACHINE_COUNT: "1"
KUBERNETES_VERSION_UPGRADE_TO: "v1.28.12"
KUBERNETES_UPGRADE_OCI_IMAGE_ID: "${KUBERNETES_UPGRADE_OCI_IMAGE_ID}"
IP_FAMILY: "IPv4"
EXP_CLUSTER_RESOURCE_SET: "true"
EXP_KUBEADM_BOOTSTRAP_FORMAT_IGNITION: "true"
EXP_MACHINE_POOL: "true"
CLUSTER_TOPOLOGY: "true"

intervals:
default/wait-controllers: ["3m", "10s"]
Expand Down
12 changes: 12 additions & 0 deletions test/e2e/const.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package e2e

import (
_ "embed"
)

var (
//go:embed data/infrastructure/clusterclass-template-docker.yaml

Check failure on line 8 in test/e2e/const.go

View workflow job for this annotation

GitHub Actions / lint

exported: comment on exported var ClusterClassDocker should be of the form "ClusterClassDocker ..." (revive)

Check failure on line 8 in test/e2e/const.go

View workflow job for this annotation

GitHub Actions / lint

exported: comment on exported var ClusterClassDocker should be of the form "ClusterClassDocker ..." (revive)

Check failure on line 8 in test/e2e/const.go

View workflow job for this annotation

GitHub Actions / lint

exported: comment on exported var ClusterClassDocker should be of the form "ClusterClassDocker ..." (revive)

Check failure on line 8 in test/e2e/const.go

View workflow job for this annotation

GitHub Actions / lint

exported: comment on exported var ClusterClassDocker should be of the form "ClusterClassDocker ..." (revive)
ClusterClassDocker []byte
//go:embed data/infrastructure/cluster-from-clusterclass-template-docker.yaml

Check failure on line 10 in test/e2e/const.go

View workflow job for this annotation

GitHub Actions / lint

exported: comment on exported var ClusterFromClusterClassDocker should be of the form "ClusterFromClusterClassDocker ..." (revive)

Check failure on line 10 in test/e2e/const.go

View workflow job for this annotation

GitHub Actions / lint

exported: comment on exported var ClusterFromClusterClassDocker should be of the form "ClusterFromClusterClassDocker ..." (revive)

Check failure on line 10 in test/e2e/const.go

View workflow job for this annotation

GitHub Actions / lint

exported: comment on exported var ClusterFromClusterClassDocker should be of the form "ClusterFromClusterClassDocker ..." (revive)

Check failure on line 10 in test/e2e/const.go

View workflow job for this annotation

GitHub Actions / lint

exported: comment on exported var ClusterFromClusterClassDocker should be of the form "ClusterFromClusterClassDocker ..." (revive)
ClusterFromClusterClassDocker []byte
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
---
apiVersion: cluster.x-k8s.io/v1beta1
kind: Cluster
metadata:
name: "${CLUSTER_NAME}"
namespace: "${NAMESPACE}"
spec:
clusterNetwork:
pods:
cidrBlocks:
- 10.45.0.0/16
serviceDomain: cluster.local
services:
cidrBlocks:
- 10.46.0.0/16
topology:
class: "${CLASS_NAME}"
version: ${KUBERNETES_VERSION}+rke2r1
controlPlane:
metadata: {}
replicas: ${CABPR_CP_REPLICAS}
workers:
machineDeployments:
- class: default-worker
name: md-0
replicas: ${CABPR_WK_REPLICAS}
variables:
- name: dockerKindImage
value: kindest/node:${KIND_IMAGE_VERSION}
206 changes: 206 additions & 0 deletions test/e2e/data/infrastructure/clusterclass-template-docker.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,206 @@
apiVersion: cluster.x-k8s.io/v1beta1
kind: ClusterClass
metadata:
name: "${CLASS_NAME}"
namespace: "${NAMESPACE}"
spec:
controlPlane:
ref:
apiVersion: controlplane.cluster.x-k8s.io/v1beta1
kind: RKE2ControlPlaneTemplate
name: ${CLASS_NAME}-control-plane
machineInfrastructure:
ref:
apiVersion: infrastructure.cluster.x-k8s.io/v1beta1
kind: DockerMachineTemplate
name: ${CLASS_NAME}-control-plane
infrastructure:
ref:
apiVersion: infrastructure.cluster.x-k8s.io/v1beta1
kind: DockerClusterTemplate
name: ${CLASS_NAME}-cluster
workers:
machineDeployments:
- class: default-worker
template:
bootstrap:
ref:
apiVersion: bootstrap.cluster.x-k8s.io/v1beta1
kind: RKE2ConfigTemplate
name: ${CLASS_NAME}-default-worker-bootstraptemplate
infrastructure:
ref:
apiVersion: infrastructure.cluster.x-k8s.io/v1beta1
kind: DockerMachineTemplate
name: ${CLASS_NAME}-default-worker-machinetemplate
variables:
- name: dockerKindImage
required: true
schema:
openAPIV3Schema:
type: string
default: kindest/node:v1.28.12
patches:
- name: controlPlaneDockerKindImage
definitions:
- selector:
apiVersion: infrastructure.cluster.x-k8s.io/v1beta1
kind: DockerMachineTemplate
matchResources:
controlPlane: true
jsonPatches:
- op: add
path: /spec/template/spec/customImage
valueFrom:
variable: dockerKindImage
- name: workerDockerKindImage
definitions:
- selector:
apiVersion: infrastructure.cluster.x-k8s.io/v1beta1
kind: DockerMachineTemplate
matchResources:
machineDeploymentClass:
names:
- default-worker
jsonPatches:
- op: add
path: "/spec/template/spec/customImage"
valueFrom:
variable: dockerKindImage
---
apiVersion: v1
data:
value: |-
# generated by kind
global
log /dev/log local0
log /dev/log local1 notice
daemon
# limit memory usage to approximately 18 MB
# (see https://github.com/kubernetes-sigs/kind/pull/3115)
maxconn 100000
resolvers docker
nameserver dns 127.0.0.11:53
defaults
log global
mode tcp
option dontlognull
# TODO: tune these
timeout connect 5000
timeout client 50000
timeout server 50000
# allow to boot despite dns don't resolve backends
default-server init-addr none
frontend stats
bind *:8404
stats enable
stats uri /
stats refresh 10s
frontend control-plane
bind *:{{ .FrontendControlPlanePort }}
{{ if .IPv6 -}}
bind :::{{ .FrontendControlPlanePort }};
{{- end }}
default_backend kube-apiservers
backend kube-apiservers
option httpchk GET /healthz
http-check expect status 401
# TODO: we should be verifying (!)
{{range $server, $address := .BackendServers}}
server {{ $server }} {{ JoinHostPort $address $.BackendControlPlanePort }} check check-ssl verify none resolvers docker resolve-prefer {{ if $.IPv6 -}} ipv6 {{- else -}} ipv4 {{- end }}
{{- end}}
frontend rke2-join
bind *:9345
{{ if .IPv6 -}}
bind :::9345;
{{- end }}
default_backend rke2-servers
backend rke2-servers
option httpchk GET /v1-rke2/readyz
http-check expect status 403
{{range $server, $address := .BackendServers}}
server {{ $server }} {{ $address }}:9345 check check-ssl verify none
{{- end}}
kind: ConfigMap
metadata:
name: ${CLASS_NAME}-lb-config
namespace: "${NAMESPACE}"
---
apiVersion: infrastructure.cluster.x-k8s.io/v1beta1
kind: DockerClusterTemplate
metadata:
name: ${CLASS_NAME}-cluster
namespace: "${NAMESPACE}"
spec:
template:
spec:
loadBalancer:
customHAProxyConfigTemplateRef:
name: ${CLASS_NAME}-lb-config
---
kind: RKE2ControlPlaneTemplate
apiVersion: controlplane.cluster.x-k8s.io/v1beta1
metadata:
name: ${CLASS_NAME}-control-plane
namespace: "${NAMESPACE}"
spec:
template:
spec:
infrastructureRef:
apiVersion: infrastructure.cluster.x-k8s.io/v1beta1
kind: DockerMachineTemplate
name: ${CLASS_NAME}-control-plane
serverConfig:
cni: calico
disableComponents:
kubernetesComponents: [ "cloudController"]
nodeDrainTimeout: 2m
registrationMethod: "control-plane-endpoint"
rolloutStrategy:
type: "RollingUpdate"
rollingUpdate:
maxSurge: 1
---
apiVersion: infrastructure.cluster.x-k8s.io/v1beta1
kind: DockerMachineTemplate
metadata:
name: ${CLASS_NAME}-control-plane
namespace: "${NAMESPACE}"
spec:
template:
spec:
customImage: kindest/node:v1.28.0 # will be replaced by the patch
extraMounts:
- containerPath: "/var/run/docker.sock"
hostPath: "/var/run/docker.sock"
bootstrapTimeout: 10m
---
apiVersion: infrastructure.cluster.x-k8s.io/v1beta1
kind: DockerMachineTemplate
metadata:
name: ${CLASS_NAME}-default-worker-machinetemplate
namespace: "${NAMESPACE}"
spec:
template:
spec:
customImage: kindest/node:v1.28.0 # will be replaced by the patch
extraMounts:
- containerPath: "/var/run/docker.sock"
hostPath: "/var/run/docker.sock"
bootstrapTimeout: 10m
---
apiVersion: bootstrap.cluster.x-k8s.io/v1beta1
kind: RKE2ConfigTemplate
metadata:
name: ${CLASS_NAME}-default-worker-bootstraptemplate
namespace: "${NAMESPACE}"
spec:
template:
spec: {}
Loading

0 comments on commit c4dca18

Please sign in to comment.