Skip to content

Add E2E test for cluster class #2235

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 20, 2022
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
598 changes: 598 additions & 0 deletions templates/test/ci/cluster-template-prow-clusterclass-ci-default.yaml

Large diffs are not rendered by default.

4,762 changes: 4,762 additions & 0 deletions templates/test/ci/cluster-template-prow-topology.yaml

Large diffs are not rendered by default.

264 changes: 264 additions & 0 deletions templates/test/ci/prow-clusterclass-ci-default/base.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,264 @@
apiVersion: cluster.x-k8s.io/v1beta1
kind: ClusterClass
metadata:
name: ci-default
spec:
controlPlane:
ref:
apiVersion: controlplane.cluster.x-k8s.io/v1beta1
kind: KubeadmControlPlaneTemplate
name: ci-default-kubeadm-control-plane
machineInfrastructure:
ref:
kind: AzureMachineTemplate
apiVersion: infrastructure.cluster.x-k8s.io/v1beta1
name: ci-default-control-plane
infrastructure:
ref:
apiVersion: infrastructure.cluster.x-k8s.io/v1beta1
kind: AzureClusterTemplate
name: ci-default-azure-cluster
workers:
machineDeployments:
- class: ci-default-worker
template:
bootstrap:
ref:
apiVersion: bootstrap.cluster.x-k8s.io/v1beta1
kind: KubeadmConfigTemplate
name: ci-default-worker
infrastructure:
ref:
apiVersion: infrastructure.cluster.x-k8s.io/v1beta1
kind: AzureMachineTemplate
name: ci-default-worker
machineHealthCheck:
maxUnhealthy: 100%
unhealthyConditions:
- type: E2ENodeUnhealthy
status: "True"
timeout: 30s
- class: ci-default-worker-win
template:
bootstrap:
ref:
apiVersion: bootstrap.cluster.x-k8s.io/v1beta1
kind: KubeadmConfigTemplate
name: ci-default-worker-win
infrastructure:
ref:
apiVersion: infrastructure.cluster.x-k8s.io/v1beta1
kind: AzureMachineTemplate
name: ci-default-worker-win
machineHealthCheck:
maxUnhealthy: 100%
unhealthyConditions:
- type: E2ENodeUnhealthy
status: "True"
timeout: 30s
---
apiVersion: controlplane.cluster.x-k8s.io/v1beta1
kind: KubeadmControlPlaneTemplate
metadata:
name: ci-default-kubeadm-control-plane
spec:
template:
spec:
kubeadmConfigSpec:
clusterConfiguration:
apiServer:
extraArgs:
cloud-config: /etc/kubernetes/azure.json
cloud-provider: azure
extraVolumes:
- hostPath: /etc/kubernetes/azure.json
mountPath: /etc/kubernetes/azure.json
name: cloud-config
readOnly: true
timeoutForControlPlane: 20m
controllerManager:
extraArgs:
allocate-node-cidrs: "false"
cloud-config: /etc/kubernetes/azure.json
cloud-provider: azure
extraVolumes:
- hostPath: /etc/kubernetes/azure.json
mountPath: /etc/kubernetes/azure.json
name: cloud-config
readOnly: true
etcd:
local:
dataDir: /var/lib/etcddisk/etcd
extraArgs:
quota-backend-bytes: "8589934592"
diskSetup:
filesystems:
- device: /dev/disk/azure/scsi1/lun0
extraOpts:
- -E
- lazy_itable_init=1,lazy_journal_init=1
filesystem: ext4
label: etcd_disk
- device: ephemeral0.1
filesystem: ext4
label: ephemeral0
replaceFS: ntfs
partitions:
- device: /dev/disk/azure/scsi1/lun0
layout: true
overwrite: false
tableType: gpt
files:
- contentFrom:
secret:
key: control-plane-azure.json
name: replace_me
owner: root:root
path: /etc/kubernetes/azure.json
permissions: "0644"
initConfiguration:
nodeRegistration:
kubeletExtraArgs:
azure-container-registry-config: /etc/kubernetes/azure.json
cloud-config: /etc/kubernetes/azure.json
cloud-provider: azure
name: '{{ ds.meta_data["local_hostname"] }}'
joinConfiguration:
nodeRegistration:
kubeletExtraArgs:
azure-container-registry-config: /etc/kubernetes/azure.json
cloud-config: /etc/kubernetes/azure.json
cloud-provider: azure
name: '{{ ds.meta_data["local_hostname"] }}'
mounts:
- - LABEL=etcd_disk
- /var/lib/etcddisk
postKubeadmCommands: [ ]
preKubeadmCommands: [ ]
---
apiVersion: infrastructure.cluster.x-k8s.io/v1beta1
kind: AzureClusterTemplate
metadata:
name: ci-default-azure-cluster
spec:
template:
spec:
additionalTags:
replace_me_key: replace_me_val
identityRef:
apiVersion: infrastructure.cluster.x-k8s.io/v1beta1
kind: AzureClusterIdentity
location: replace_me
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just curious, is "replace_me" an arbitrary string or is it some agreed upon contract/pattern for required variables in clusterclass?

Copy link
Member

@sbueringer sbueringer May 27, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's unfortunately just a workaround for fields that have to be set for the validating webhook and are then later overwritten per cluster.

I think this workaround kind of becomes a pattern right now, but there is no standardization (yet).

Not sure how we can improve this, maybe it's an option that these fields should be optional when the resource is referenced in a ClusterClass. But not sure how feasible this is.

(as far as I'm aware CAPA is using a similar but not the same string)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CAPA is using REPLACEME. I don't particularly have a preference but I vaguely remember using replace_me being used in other places where a similar mechanism was involved.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm inferring from reading this history that empty string val doesn't suffice?

Copy link
Member

@sbueringer sbueringer Jun 20, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Afaik the validation webhook will complain

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a capi issue tracking how we might improve this? IMO this is a fairly significant bit of UX friction for users to deal with, we should do this work on behalf of them (happy to help).

Everything else here actually looks fine to me and test signal is green, I'm going to mark this as /lgtm.

Thanks so much @shysank, really happy to have ClusterClass coverage in capz!

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure, we probably have some guidance around cluster-specific fields and that they shouldn't be added to cluster templates (which was in general nicely done by CAPZ). But I"m not sure if that falls under the "cluster-specific" field category.

I think it makes sense to open an issue in CAPI and see what we have / need.

We can discuss documentation improvements or potential implementation changes to mitigate this issue (e.g. maybe some fields shouldn't be mandatory on a cluster template / machine template when it's used as template in a ClusterClass).

networkSpec:
subnets:
- role: control-plane
- natGateway:
name: node-natgateway
role: node
---
apiVersion: infrastructure.cluster.x-k8s.io/v1beta1
kind: AzureMachineTemplate
metadata:
name: ci-default-control-plane
spec:
template:
spec:
dataDisks:
- diskSizeGB: 256
lun: 0
nameSuffix: etcddisk
osDisk:
diskSizeGB: 128
osType: Linux
sshPublicKey: ""
vmSize: replace_me
---
apiVersion: bootstrap.cluster.x-k8s.io/v1beta1
kind: KubeadmConfigTemplate
metadata:
name: ci-default-worker
spec:
template:
spec:
files:
- contentFrom:
secret:
key: worker-node-azure.json
name: replace_me
owner: root:root
path: /etc/kubernetes/azure.json
permissions: "0644"
joinConfiguration:
nodeRegistration:
kubeletExtraArgs:
azure-container-registry-config: /etc/kubernetes/azure.json
cloud-config: /etc/kubernetes/azure.json
cloud-provider: azure
name: '{{ ds.meta_data["local_hostname"] }}'
preKubeadmCommands: [ ]
---
apiVersion: infrastructure.cluster.x-k8s.io/v1beta1
kind: AzureMachineTemplate
metadata:
name: ci-default-worker
spec:
template:
spec:
osDisk:
diskSizeGB: 128
osType: Linux
sshPublicKey: ""
vmSize: replace_me
---
apiVersion: bootstrap.cluster.x-k8s.io/v1beta1
kind: KubeadmConfigTemplate
metadata:
name: ci-default-worker-win
spec:
template:
spec:
preKubeadmCommands: []
postKubeadmCommands:
- nssm set kubelet start SERVICE_AUTO_START
- powershell C:/defender-exclude-calico.ps1
joinConfiguration:
nodeRegistration:
name: '{{ ds.meta_data["local_hostname"] }}'
criSocket: npipe:////./pipe/containerd-containerd
kubeletExtraArgs:
cloud-provider: azure
cloud-config: 'c:/k/azure.json'
azure-container-registry-config: 'c:/k/azure.json'
feature-gates: "WindowsHostProcessContainers=true"
v: "2"
windows-priorityclass: "ABOVE_NORMAL_PRIORITY_CLASS"
files:
- contentFrom:
secret:
key: worker-node-azure.json
name: replace_me
owner: root:root
path: c:/k/azure.json
permissions: "0644"
- path: C:/defender-exclude-calico.ps1
permissions: "0744"
content: |-
Add-MpPreference -ExclusionProcess C:/opt/cni/bin/calico.exe
Add-MpPreference -ExclusionProcess C:/opt/cni/bin/calico-ipam.exe
---
apiVersion: infrastructure.cluster.x-k8s.io/v1beta1
kind: AzureMachineTemplate
metadata:
name: ci-default-worker-win
annotations:
runtime: containerd
spec:
template:
spec:
osDisk:
osType: "Windows"
diskSizeGB: 128
managedDisk:
storageAccountType: "Premium_LRS"
sshPublicKey: ""
vmSize: replace_me
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
namespace: default
resources:
- base.yaml
- ../../../azure-cluster-identity
patchesStrategicMerge:
- patches.yaml
- variables.yaml
Loading