Skip to content

Commit da03567

Browse files
authored
Merge pull request #5893 from ykakarap/clusterctl-dry-run
✨ clusterctl alpha topology-dryrun
2 parents 82ab810 + dcc22db commit da03567

File tree

21 files changed

+2198
-2
lines changed

21 files changed

+2198
-2
lines changed

cmd/clusterctl/client/client.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,8 @@ type AlphaClient interface {
8989
RolloutResume(options RolloutOptions) error
9090
// RolloutUndo provides rollout rollback of cluster-api resources
9191
RolloutUndo(options RolloutOptions) error
92+
// DryRunTopology dry runs the topology reconciler
93+
DryRunTopology(options DryRunOptions) (*cluster.DryRunOutput, error)
9294
}
9395

9496
// YamlPrinter exposes methods that prints the processed template and

cmd/clusterctl/client/client_test.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,10 @@ func (f fakeClient) RolloutUndo(options RolloutOptions) error {
148148
return f.internalClient.RolloutUndo(options)
149149
}
150150

151+
func (f fakeClient) DryRunTopology(options DryRunOptions) (*cluster.DryRunOutput, error) {
152+
return f.internalClient.DryRunTopology(options)
153+
}
154+
151155
// newFakeClient returns a clusterctl client that allows to execute tests on a set of fake config, fake repositories and fake clusters.
152156
// you can use WithCluster and WithRepository to prepare for the test case.
153157
func newFakeClient(configClient config.Client) *fakeClient {
@@ -318,6 +322,10 @@ func (f *fakeClusterClient) WorkloadCluster() cluster.WorkloadCluster {
318322
return f.internalclient.WorkloadCluster()
319323
}
320324

325+
func (f *fakeClusterClient) Topology() cluster.TopologyClient {
326+
return f.internalclient.Topology()
327+
}
328+
321329
func (f *fakeClusterClient) WithObjs(objs ...client.Object) *fakeClusterClient {
322330
f.fakeProxy.WithObjs(objs...)
323331
return f
Lines changed: 267 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,267 @@
1+
apiVersion: apiextensions.k8s.io/v1
2+
kind: CustomResourceDefinition
3+
metadata:
4+
labels:
5+
cluster.x-k8s.io/provider: infrastructure-docker
6+
cluster.x-k8s.io/v1beta1: v1beta1
7+
name: dockerclusters.infrastructure.cluster.x-k8s.io
8+
---
9+
apiVersion: apiextensions.k8s.io/v1
10+
kind: CustomResourceDefinition
11+
metadata:
12+
labels:
13+
cluster.x-k8s.io/provider: infrastructure-docker
14+
cluster.x-k8s.io/v1beta1: v1beta1
15+
name: dockerclustertemplates.infrastructure.cluster.x-k8s.io
16+
---
17+
apiVersion: apiextensions.k8s.io/v1
18+
kind: CustomResourceDefinition
19+
metadata:
20+
labels:
21+
cluster.x-k8s.io/provider: control-plane-kubeadm
22+
cluster.x-k8s.io/v1beta1: v1beta1
23+
name: kubeadmcontrolplanetemplates.controlplane.cluster.x-k8s.io
24+
---
25+
apiVersion: apiextensions.k8s.io/v1
26+
kind: CustomResourceDefinition
27+
metadata:
28+
labels:
29+
cluster.x-k8s.io/provider: control-plane-kubeadm
30+
cluster.x-k8s.io/v1beta1: v1beta1
31+
name: kubeadmcontrolplanes.controlplane.cluster.x-k8s.io
32+
---
33+
apiVersion: apiextensions.k8s.io/v1
34+
kind: CustomResourceDefinition
35+
metadata:
36+
labels:
37+
cluster.x-k8s.io/provider: infrastructure-docker
38+
cluster.x-k8s.io/v1beta1: v1beta1
39+
name: dockermachinetemplates.infrastructure.cluster.x-k8s.io
40+
---
41+
apiVersion: cluster.x-k8s.io/v1beta1
42+
kind: ClusterClass
43+
metadata:
44+
name: my-cluster-class
45+
namespace: default
46+
spec:
47+
controlPlane:
48+
ref:
49+
apiVersion: controlplane.cluster.x-k8s.io/v1beta1
50+
kind: KubeadmControlPlaneTemplate
51+
name: control-plane
52+
namespace: default
53+
machineInfrastructure:
54+
ref:
55+
kind: DockerMachineTemplate
56+
apiVersion: infrastructure.cluster.x-k8s.io/v1beta1
57+
name: "control-plane"
58+
namespace: default
59+
infrastructure:
60+
ref:
61+
apiVersion: infrastructure.cluster.x-k8s.io/v1beta1
62+
kind: DockerClusterTemplate
63+
name: my-cluster
64+
namespace: default
65+
---
66+
apiVersion: infrastructure.cluster.x-k8s.io/v1beta1
67+
kind: DockerClusterTemplate
68+
metadata:
69+
name: my-cluster
70+
namespace: default
71+
spec:
72+
template:
73+
spec: {}
74+
---
75+
kind: KubeadmControlPlaneTemplate
76+
apiVersion: controlplane.cluster.x-k8s.io/v1beta1
77+
metadata:
78+
name: "control-plane"
79+
namespace: default
80+
spec:
81+
template:
82+
spec:
83+
replicas: 1
84+
machineTemplate:
85+
nodeDrainTimeout: 1s
86+
infrastructureRef:
87+
kind: DockerMachineTemplate
88+
apiVersion: infrastructure.cluster.x-k8s.io/v1beta1
89+
name: "control-plane"
90+
namespace: default
91+
kubeadmConfigSpec:
92+
clusterConfiguration:
93+
controllerManager:
94+
extraArgs: { enable-hostpath-provisioner: 'true' }
95+
apiServer:
96+
certSANs: [ localhost, 127.0.0.1 ]
97+
initConfiguration:
98+
nodeRegistration:
99+
criSocket: /var/run/containerd/containerd.sock
100+
kubeletExtraArgs:
101+
# We have to pin the cgroupDriver to cgroupfs as kubeadm >=1.21 defaults to systemd
102+
# kind will implement systemd support in: https://github.com/kubernetes-sigs/kind/issues/1726
103+
cgroup-driver: cgroupfs
104+
eviction-hard: 'nodefs.available<0%,nodefs.inodesFree<0%,imagefs.available<0%'
105+
joinConfiguration:
106+
nodeRegistration:
107+
criSocket: /var/run/containerd/containerd.sock
108+
kubeletExtraArgs:
109+
# We have to pin the cgroupDriver to cgroupfs as kubeadm >=1.21 defaults to systemd
110+
# kind will implement systemd support in: https://github.com/kubernetes-sigs/kind/issues/1726
111+
cgroup-driver: cgroupfs
112+
eviction-hard: 'nodefs.available<0%,nodefs.inodesFree<0%,imagefs.available<0%'
113+
version: v1.21.2
114+
---
115+
apiVersion: infrastructure.cluster.x-k8s.io/v1beta1
116+
kind: DockerMachineTemplate
117+
metadata:
118+
name: "control-plane"
119+
namespace: default
120+
spec:
121+
template:
122+
spec:
123+
extraMounts:
124+
- containerPath: "/var/run/docker.sock"
125+
hostPath: "/var/run/docker.sock"
126+
---
127+
apiVersion: cluster.x-k8s.io/v1beta1
128+
kind: Cluster
129+
metadata:
130+
name: "my-cluster"
131+
namespace: default
132+
labels:
133+
cni: kindnet
134+
spec:
135+
clusterNetwork:
136+
services:
137+
cidrBlocks: ["10.128.0.0/12"]
138+
pods:
139+
cidrBlocks: ["192.168.0.0/16"]
140+
serviceDomain: "cluster.local"
141+
controlPlaneEndpoint:
142+
host: 172.19.0.4
143+
port: 6443
144+
controlPlaneRef:
145+
apiVersion: controlplane.cluster.x-k8s.io/v1beta1
146+
kind: KubeadmControlPlane
147+
name: my-cluster-fwbpf
148+
namespace: default
149+
infrastructureRef:
150+
apiVersion: infrastructure.cluster.x-k8s.io/v1beta1
151+
kind: DockerCluster
152+
name: my-cluster-zrq96
153+
namespace: default
154+
topology:
155+
class: my-cluster-class
156+
version: v1.21.2
157+
controlPlane:
158+
metadata: {}
159+
replicas: 1
160+
---
161+
apiVersion: infrastructure.cluster.x-k8s.io/v1beta1
162+
kind: DockerCluster
163+
metadata:
164+
annotations:
165+
cluster.x-k8s.io/cloned-from-groupkind: DockerClusterTemplate.infrastructure.cluster.x-k8s.io
166+
cluster.x-k8s.io/cloned-from-name: my-cluster
167+
finalizers:
168+
- dockercluster.infrastructure.cluster.x-k8s.io
169+
labels:
170+
cluster.x-k8s.io/cluster-name: my-cluster
171+
topology.cluster.x-k8s.io/owned: ""
172+
name: my-cluster-zrq96
173+
namespace: default
174+
spec:
175+
controlPlaneEndpoint:
176+
host: 172.19.0.4
177+
port: 6443
178+
loadBalancer: {}
179+
---
180+
apiVersion: controlplane.cluster.x-k8s.io/v1beta1
181+
kind: KubeadmControlPlane
182+
metadata:
183+
annotations:
184+
cluster.x-k8s.io/cloned-from-groupkind: KubeadmControlPlaneTemplate.controlplane.cluster.x-k8s.io
185+
cluster.x-k8s.io/cloned-from-name: control-plane
186+
finalizers:
187+
- kubeadm.controlplane.cluster.x-k8s.io
188+
labels:
189+
cluster.x-k8s.io/cluster-name: my-cluster
190+
topology.cluster.x-k8s.io/owned: ""
191+
name: my-cluster-fwbpf
192+
namespace: default
193+
ownerReferences:
194+
- apiVersion: cluster.x-k8s.io/v1beta1
195+
blockOwnerDeletion: true
196+
controller: true
197+
kind: Cluster
198+
name: my-cluster
199+
uid: 3ba5ce4f-d279-4edb-8ade-62a2381d11a8
200+
spec:
201+
kubeadmConfigSpec:
202+
clusterConfiguration:
203+
apiServer:
204+
certSANs:
205+
- localhost
206+
- 127.0.0.1
207+
controllerManager:
208+
extraArgs:
209+
enable-hostpath-provisioner: "true"
210+
dns: {}
211+
etcd: {}
212+
networking: {}
213+
scheduler: {}
214+
initConfiguration:
215+
localAPIEndpoint: {}
216+
nodeRegistration:
217+
criSocket: /var/run/containerd/containerd.sock
218+
kubeletExtraArgs:
219+
cgroup-driver: cgroupfs
220+
eviction-hard: nodefs.available<0%,nodefs.inodesFree<0%,imagefs.available<0%
221+
joinConfiguration:
222+
discovery: {}
223+
nodeRegistration:
224+
criSocket: /var/run/containerd/containerd.sock
225+
kubeletExtraArgs:
226+
cgroup-driver: cgroupfs
227+
eviction-hard: nodefs.available<0%,nodefs.inodesFree<0%,imagefs.available<0%
228+
machineTemplate:
229+
infrastructureRef:
230+
apiVersion: infrastructure.cluster.x-k8s.io/v1beta1
231+
kind: DockerMachineTemplate
232+
name: my-cluster-control-plane-44cd4
233+
namespace: default
234+
metadata:
235+
labels:
236+
cluster.x-k8s.io/cluster-name: my-cluster
237+
topology.cluster.x-k8s.io/owned: ""
238+
nodeDrainTimeout: 1s
239+
replicas: 1
240+
rolloutStrategy:
241+
rollingUpdate:
242+
maxSurge: 1
243+
type: RollingUpdate
244+
version: v1.21.2
245+
---
246+
apiVersion: infrastructure.cluster.x-k8s.io/v1beta1
247+
kind: DockerMachineTemplate
248+
metadata:
249+
annotations:
250+
cluster.x-k8s.io/cloned-from-groupkind: DockerMachineTemplate.infrastructure.cluster.x-k8s.io
251+
cluster.x-k8s.io/cloned-from-name: control-plane
252+
labels:
253+
cluster.x-k8s.io/cluster-name: my-cluster
254+
topology.cluster.x-k8s.io/owned: ""
255+
name: my-cluster-control-plane-44cd4
256+
namespace: default
257+
ownerReferences:
258+
- apiVersion: cluster.x-k8s.io/v1beta1
259+
kind: Cluster
260+
name: my-cluster
261+
uid: 3ba5ce4f-d279-4edb-8ade-62a2381d11a8
262+
spec:
263+
template:
264+
spec:
265+
extraMounts:
266+
- containerPath: /var/run/docker.sock
267+
hostPath: /var/run/docker.sock
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
apiVersion: cluster.x-k8s.io/v1beta1
2+
kind: Cluster
3+
metadata:
4+
name: "my-cluster"
5+
namespace: default
6+
labels:
7+
cni: kindnet
8+
spec:
9+
clusterNetwork:
10+
services:
11+
cidrBlocks: ["10.128.0.0/12"]
12+
pods:
13+
cidrBlocks: ["192.168.0.0/16"]
14+
serviceDomain: "cluster.local"
15+
topology:
16+
class: my-cluster-class
17+
version: v1.21.2
18+
controlPlane:
19+
metadata: {}
20+
replicas: 3

0 commit comments

Comments
 (0)