Skip to content

Commit

Permalink
Add mp to quickstart templates
Browse files Browse the repository at this point in the history
  • Loading branch information
willie-yao committed Sep 12, 2023
1 parent 321096f commit 670d3b9
Show file tree
Hide file tree
Showing 3 changed files with 91 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,26 @@ spec:
rollingUpdate:
maxSurge: "20%"
maxUnavailable: 0
machinePools:
- class: "default-worker"
name: "mp-0"
metadata:
labels:
Cluster.topology.machinePool.label: "Cluster.topology.machinePool.labelValue"
# Note: this label is propagated to Nodes.
Cluster.topology.machinePool.label.node.cluster.x-k8s.io: "Cluster.topology.machinePool.nodeLabelValue"
annotations:
Cluster.topology.machinePool.annotation: "Cluster.topology.machinePool.annotationValue"
nodeDeletionTimeout: "30s"
nodeVolumeDetachTimeout: "5m"
minReadySeconds: 5
replicas: ${WORKER_MACHINE_COUNT}
failureDomains:
- fd4
- fd5
- fd6
- fd7
- fd8
variables:
# We set an empty value to use the default tag kubeadm init is using.
- name: etcdImageTag
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,24 @@ spec:
- type: e2e.remediation.condition
status: "False"
timeout: 20s
machinePools:
- class: default-worker
template:
metadata:
labels:
ClusterClass.machinePool.label: "ClusterClass.machinePool.labelValue"
annotations:
ClusterClass.machinePool.annotation: "ClusterClass.machinePool.annotationValue"
bootstrap:
ref:
apiVersion: bootstrap.cluster.x-k8s.io/v1beta1
kind: KubeadmConfigTemplate
name: quick-start-default-worker-bootstraptemplate
infrastructure:
ref:
apiVersion: infrastructure.cluster.x-k8s.io/v1beta1
kind: DockerMachinePoolTemplate
name: quick-start-default-worker-machinepooltemplate
variables:
- name: lbImageRepository
required: true
Expand Down Expand Up @@ -182,6 +200,19 @@ spec:
valueFrom:
template: |
kindest/node:{{ .builtin.controlPlane.version | replace "+" "_" }}
- selector:
apiVersion: infrastructure.cluster.x-k8s.io/v1beta1
kind: DockerMachinePoolTemplate
matchResources:
machinePoolClass:
names:
- default-worker
jsonPatches:
- op: add
path: "/spec/template/spec/template/customImage"
valueFrom:
template: |
kindest/node:{{ .builtin.machinePool.version | replace "+" "_" }}
- name: preloadImages
description: |
Sets the container images to preload to the node that is used for running dockerMachines.
Expand Down Expand Up @@ -264,6 +295,18 @@ spec:
path: "/spec/template/spec/joinConfiguration/nodeRegistration/kubeletExtraArgs"
value:
cloud-provider: "external"
- selector:
apiVersion: bootstrap.cluster.x-k8s.io/v1beta1
kind: KubeadmConfigTemplate
matchResources:
machinePoolClass:
names:
- '*-worker'
jsonPatches:
- op: add
path: "/spec/template/spec/joinConfiguration/nodeRegistration/kubeletExtraArgs"
value:
cloud-provider: "external"
- name: localEndpointIPv6
enabledIf: "{{ .ipv6Primary }}"
description: "Configures KCP to use IPv6 for its localAPIEndpoint."
Expand Down Expand Up @@ -440,21 +483,38 @@ spec:
- containerPath: "/var/run/docker.sock"
hostPath: "/var/run/docker.sock"
---
apiVersion: infrastructure.cluster.x-k8s.io/v1beta1
kind: DockerMachinePoolTemplate
metadata:
name: quick-start-default-worker-machinepooltemplate
labels:
InfraMachineTemplate.machinePool.label: "InfraMachineTemplate.machinePool.labelValue"
annotations:
InfraMachineTemplate.machinePool.annotation: "InfraMachineTemplate.machinePool.annotationValue"
spec:
template:
spec:
template: {}
---
apiVersion: bootstrap.cluster.x-k8s.io/v1beta1
kind: KubeadmConfigTemplate
metadata:
name: quick-start-default-worker-bootstraptemplate
labels:
BootstrapConfigTemplate.machineDeployment.label: "BootstrapConfigTemplate.machineDeployment.labelValue"
BootstrapConfigTemplate.machinePool.label: "BootstrapConfigTemplate.machinePool.labelValue"
annotations:
BootstrapConfigTemplate.machineDeployment.annotation: "BootstrapConfigTemplate.machineDeployment.annotationValue"
BootstrapConfigTemplate.machinePool.annotation: "BootstrapConfigTemplate.machinePool.annotationValue"
spec:
template:
metadata:
labels:
BootstrapConfigTemplate.machineDeployment.template.label: "BootstrapConfigTemplate.machineDeployment.template.labelValue"
BootstrapConfigTemplate.machinePool.label: "BootstrapConfigTemplate.machinePool.labelValue"
annotations:
BootstrapConfigTemplate.machineDeployment.template.annotation: "BootstrapConfigTemplate.machineDeployment.template.annotationValue"
BootstrapConfigTemplate.machinePool.annotation: "BootstrapConfigTemplate.machinePool.annotationValue"
spec:
joinConfiguration:
nodeRegistration: # node registration parameters are automatically injected by CAPD according to the kindest/node image in use.
Expand Down
17 changes: 11 additions & 6 deletions test/framework/ownerreference_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -280,11 +280,12 @@ var KubeadmBootstrapOwnerReferenceAssertions = map[string]func([]metav1.OwnerRef

// Kinds for types in the Docker infrastructure package.
var (
dockerMachineKind = "DockerMachine"
dockerMachineTemplateKind = "DockerMachineTemplate"
dockerMachinePoolKind = "DockerMachinePool"
dockerClusterKind = "DockerCluster"
dockerClusterTemplateKind = "DockerClusterTemplate"
dockerMachineKind = "DockerMachine"
dockerMachineTemplateKind = "DockerMachineTemplate"
dockerMachinePoolKind = "DockerMachinePool"
dockerMachinePoolTemplateKind = "DockerMachinePoolTemplate"
dockerClusterKind = "DockerCluster"
dockerClusterTemplateKind = "DockerClusterTemplate"
)

// DockerInfraOwnerReferenceAssertions maps Docker Infrastructure types to functions which return an error if the passed
Expand Down Expand Up @@ -313,6 +314,10 @@ var DockerInfraOwnerReferenceAssertions = map[string]func([]metav1.OwnerReferenc
// DockerMachinePool must be owned by a MachinePool.
return HasExactOwners(owners, machinePoolOwner)
},
dockerMachinePoolTemplateKind: func(owners []metav1.OwnerReference) error {
// DockerMachinePoolTemplate must be owned by a ClusterClass.
return HasExactOwners(owners, clusterClassOwner)
},
}

func HasExactOwners(gotOwners []metav1.OwnerReference, wantOwners ...metav1.OwnerReference) error {
Expand All @@ -328,7 +333,7 @@ func HasExactOwners(gotOwners []metav1.OwnerReference, wantOwners ...metav1.Owne
sort.Strings(wantComparable)

if !reflect.DeepEqual(gotComparable, wantComparable) {
return fmt.Errorf("wanted %v, actual %v", wantOwners, gotOwners)
return fmt.Errorf("wanted %v, actual %v", wantComparable, gotComparable)
}
return nil
}
Expand Down

0 comments on commit 670d3b9

Please sign in to comment.