Skip to content

Commit 4e1b638

Browse files
authored
Merge pull request #5960 from ykakarap/dryrun-improvements
✨ improvements to `clusterctl alpha topology plan`
2 parents 128b957 + 07b5e0a commit 4e1b638

15 files changed

+964
-542
lines changed

cmd/clusterctl/client/client.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,8 +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)
92+
// TopologyPlan dry runs the topology reconciler
93+
TopologyPlan(options TopologyPlanOptions) (*TopologyPlanOutput, error)
9494
}
9595

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

cmd/clusterctl/client/client_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -148,8 +148,8 @@ 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)
151+
func (f fakeClient) TopologyPlan(options TopologyPlanOptions) (*cluster.TopologyPlanOutput, error) {
152+
return f.internalClient.TopologyPlan(options)
153153
}
154154

155155
// newFakeClient returns a clusterctl client that allows to execute tests on a set of fake config, fake repositories and fake clusters.
Lines changed: 0 additions & 126 deletions
Original file line numberDiff line numberDiff line change
@@ -1,129 +1,3 @@
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-
---
1271
apiVersion: cluster.x-k8s.io/v1beta1
1282
kind: Cluster
1293
metadata:
Lines changed: 142 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,142 @@
1+
---
2+
apiVersion: cluster.x-k8s.io/v1beta1
3+
kind: Cluster
4+
metadata:
5+
name: "my-second-cluster"
6+
namespace: default
7+
labels:
8+
cni: kindnet
9+
spec:
10+
clusterNetwork:
11+
services:
12+
cidrBlocks: ["10.128.0.0/12"]
13+
pods:
14+
cidrBlocks: ["192.168.0.0/16"]
15+
serviceDomain: "cluster.local"
16+
controlPlaneEndpoint:
17+
host: 172.19.0.4
18+
port: 6443
19+
controlPlaneRef:
20+
apiVersion: controlplane.cluster.x-k8s.io/v1beta1
21+
kind: KubeadmControlPlane
22+
name: my-second-cluster-fwbpf
23+
namespace: default
24+
infrastructureRef:
25+
apiVersion: infrastructure.cluster.x-k8s.io/v1beta1
26+
kind: DockerCluster
27+
name: my-second-cluster-zrq96
28+
namespace: default
29+
topology:
30+
class: my-cluster-class
31+
version: v1.21.2
32+
controlPlane:
33+
metadata: {}
34+
replicas: 1
35+
---
36+
apiVersion: infrastructure.cluster.x-k8s.io/v1beta1
37+
kind: DockerCluster
38+
metadata:
39+
annotations:
40+
cluster.x-k8s.io/cloned-from-groupkind: DockerClusterTemplate.infrastructure.cluster.x-k8s.io
41+
cluster.x-k8s.io/cloned-from-name: my-cluster
42+
finalizers:
43+
- dockercluster.infrastructure.cluster.x-k8s.io
44+
labels:
45+
cluster.x-k8s.io/cluster-name: my-cluster
46+
topology.cluster.x-k8s.io/owned: ""
47+
name: my-second-cluster-zrq96
48+
namespace: default
49+
spec:
50+
controlPlaneEndpoint:
51+
host: 172.19.0.4
52+
port: 6443
53+
loadBalancer: {}
54+
---
55+
apiVersion: controlplane.cluster.x-k8s.io/v1beta1
56+
kind: KubeadmControlPlane
57+
metadata:
58+
annotations:
59+
cluster.x-k8s.io/cloned-from-groupkind: KubeadmControlPlaneTemplate.controlplane.cluster.x-k8s.io
60+
cluster.x-k8s.io/cloned-from-name: control-plane
61+
finalizers:
62+
- kubeadm.controlplane.cluster.x-k8s.io
63+
labels:
64+
cluster.x-k8s.io/cluster-name: my-cluster
65+
topology.cluster.x-k8s.io/owned: ""
66+
name: my-second-cluster-fwbpf
67+
namespace: default
68+
ownerReferences:
69+
- apiVersion: cluster.x-k8s.io/v1beta1
70+
blockOwnerDeletion: true
71+
controller: true
72+
kind: Cluster
73+
name: my-second-cluster
74+
uid: 3ba5ce4f-d279-4edb-8ade-62a2381d11a9
75+
spec:
76+
kubeadmConfigSpec:
77+
clusterConfiguration:
78+
apiServer:
79+
certSANs:
80+
- localhost
81+
- 127.0.0.1
82+
controllerManager:
83+
extraArgs:
84+
enable-hostpath-provisioner: "true"
85+
dns: {}
86+
etcd: {}
87+
networking: {}
88+
scheduler: {}
89+
initConfiguration:
90+
localAPIEndpoint: {}
91+
nodeRegistration:
92+
criSocket: /var/run/containerd/containerd.sock
93+
kubeletExtraArgs:
94+
cgroup-driver: cgroupfs
95+
eviction-hard: nodefs.available<0%,nodefs.inodesFree<0%,imagefs.available<0%
96+
joinConfiguration:
97+
discovery: {}
98+
nodeRegistration:
99+
criSocket: /var/run/containerd/containerd.sock
100+
kubeletExtraArgs:
101+
cgroup-driver: cgroupfs
102+
eviction-hard: nodefs.available<0%,nodefs.inodesFree<0%,imagefs.available<0%
103+
machineTemplate:
104+
infrastructureRef:
105+
apiVersion: infrastructure.cluster.x-k8s.io/v1beta1
106+
kind: DockerMachineTemplate
107+
name: my-cluster-control-plane-44cd4
108+
namespace: default
109+
metadata:
110+
labels:
111+
cluster.x-k8s.io/cluster-name: my-cluster
112+
topology.cluster.x-k8s.io/owned: ""
113+
nodeDrainTimeout: 1s
114+
replicas: 1
115+
rolloutStrategy:
116+
rollingUpdate:
117+
maxSurge: 1
118+
type: RollingUpdate
119+
version: v1.21.2
120+
---
121+
apiVersion: infrastructure.cluster.x-k8s.io/v1beta1
122+
kind: DockerMachineTemplate
123+
metadata:
124+
annotations:
125+
cluster.x-k8s.io/cloned-from-groupkind: DockerMachineTemplate.infrastructure.cluster.x-k8s.io
126+
cluster.x-k8s.io/cloned-from-name: control-plane
127+
labels:
128+
cluster.x-k8s.io/cluster-name: my-cluster
129+
topology.cluster.x-k8s.io/owned: ""
130+
name: my-second-cluster-control-plane-44cd4
131+
namespace: default
132+
ownerReferences:
133+
- apiVersion: cluster.x-k8s.io/v1beta1
134+
kind: Cluster
135+
name: my-second-cluster
136+
uid: 3ba5ce4f-d279-4edb-8ade-62a2381d11a9
137+
spec:
138+
template:
139+
spec:
140+
extraMounts:
141+
- containerPath: /var/run/docker.sock
142+
hostPath: /var/run/docker.sock
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
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
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
apiVersion: infrastructure.cluster.x-k8s.io/v1beta1
2+
kind: DockerMachineTemplate
3+
metadata:
4+
name: "control-plane"
5+
namespace: default
6+
spec:
7+
template:
8+
metadata:
9+
labels:
10+
docker-machine-template: test-template-control-plane
11+
spec:
12+
extraMounts:
13+
- containerPath: "/var/run/docker.sock"
14+
hostPath: "/var/run/docker.sock"

cmd/clusterctl/client/cluster/assets/topology-test/modified-cluster.yaml renamed to cmd/clusterctl/client/cluster/assets/topology-test/modified-my-cluster.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,4 @@ spec:
1717
version: v1.21.2
1818
controlPlane:
1919
metadata: {}
20-
replicas: 3
20+
replicas: 3

0 commit comments

Comments
 (0)