Skip to content

Commit 8106f22

Browse files
authored
Merge pull request #59 from aws/remove-ip-assignment-for-cp-in-shared-network
Remove IP assignment for CPs in a shared network
2 parents b3e79b6 + 9f8a69d commit 8106f22

File tree

7 files changed

+430
-9
lines changed

7 files changed

+430
-9
lines changed

pkg/cloud/instance.go

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ package cloud
1818

1919
import (
2020
"fmt"
21-
"net"
2221

2322
"strings"
2423

@@ -198,14 +197,6 @@ func (c *client) GetOrCreateVMInstance(
198197
setIfNotEmpty(csCluster.Spec.Account, p.SetAccount)
199198
setIfNotEmpty(csCluster.Status.DomainID, p.SetDomainid)
200199

201-
// If this VM instance is a control plane, consider setting its IP.
202-
_, isControlPlanceMachine := capiMachine.ObjectMeta.Labels["cluster.x-k8s.io/control-plane"]
203-
if isControlPlanceMachine && zone.Network.Type == NetworkTypeShared {
204-
// If the specified control plane endpoint is an IP address, specify the IP address of this VM instance.
205-
if net.ParseIP(csCluster.Spec.ControlPlaneEndpoint.Host) != nil {
206-
p.SetIpaddress(csCluster.Spec.ControlPlaneEndpoint.Host)
207-
}
208-
}
209200
if csMachine.Spec.Details != nil {
210201
p.SetDetails(csMachine.Spec.Details)
211202
}
Lines changed: 173 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,173 @@
1+
---
2+
apiVersion: cluster.x-k8s.io/v1beta1
3+
kind: Cluster
4+
metadata:
5+
name: ${CLUSTER_NAME}
6+
spec:
7+
clusterNetwork:
8+
pods:
9+
cidrBlocks:
10+
- 192.168.0.0/16
11+
serviceDomain: cluster.local
12+
infrastructureRef:
13+
apiVersion: infrastructure.cluster.x-k8s.io/v1beta1
14+
kind: CloudStackCluster
15+
name: ${CLUSTER_NAME}
16+
controlPlaneRef:
17+
kind: KubeadmControlPlane
18+
apiVersion: controlplane.cluster.x-k8s.io/v1beta1
19+
name: ${CLUSTER_NAME}-control-plane
20+
---
21+
apiVersion: infrastructure.cluster.x-k8s.io/v1beta1
22+
kind: CloudStackCluster
23+
metadata:
24+
name: ${CLUSTER_NAME}
25+
spec:
26+
controlPlaneEndpoint:
27+
host: ${CLUSTER_ENDPOINT_IP}
28+
port: ${CLUSTER_ENDPOINT_PORT}
29+
zones:
30+
- name : ${CLOUDSTACK_ZONE_NAME}
31+
network:
32+
name: ${CLOUDSTACK_NETWORK_NAME}
33+
---
34+
apiVersion: controlplane.cluster.x-k8s.io/v1beta1
35+
kind: KubeadmControlPlane
36+
metadata:
37+
name: "${CLUSTER_NAME}-control-plane"
38+
spec:
39+
kubeadmConfigSpec:
40+
clusterConfiguration:
41+
imageRepository: k8s.gcr.io
42+
initConfiguration:
43+
nodeRegistration:
44+
kubeletExtraArgs:
45+
provider-id: "cloudstack:///'{{ ds.meta_data.instance_id }}'"
46+
name: '{{ local_hostname }}'
47+
joinConfiguration:
48+
nodeRegistration:
49+
kubeletExtraArgs:
50+
provider-id: "cloudstack:///'{{ ds.meta_data.instance_id }}'"
51+
name: '{{ local_hostname }}'
52+
ignorePreflightErrors:
53+
- DirAvailable--etc-kubernetes-manifests
54+
preKubeadmCommands:
55+
- swapoff -a
56+
files:
57+
- content: |
58+
apiVersion: v1
59+
kind: Pod
60+
metadata:
61+
creationTimestamp: null
62+
name: kube-vip
63+
namespace: kube-system
64+
spec:
65+
containers:
66+
- args:
67+
- start
68+
env:
69+
- name: vip_arp
70+
value: "true"
71+
- name: vip_leaderelection
72+
value: "true"
73+
- name: vip_address
74+
value: ${CLUSTER_ENDPOINT_IP}
75+
- name: vip_interface
76+
value: ens3
77+
- name: vip_leaseduration
78+
value: "15"
79+
- name: vip_renewdeadline
80+
value: "10"
81+
- name: vip_retryperiod
82+
value: "2"
83+
image: public.ecr.aws/i3w0y7q3/plunder-app/kube-vip:v0.3.7-eks-a-v0.0.0-dev-build.0
84+
imagePullPolicy: IfNotPresent
85+
name: kube-vip
86+
resources: {}
87+
securityContext:
88+
capabilities:
89+
add:
90+
- NET_ADMIN
91+
- SYS_TIME
92+
volumeMounts:
93+
- mountPath: /etc/kubernetes/admin.conf
94+
name: kubeconfig
95+
hostNetwork: true
96+
volumes:
97+
- hostPath:
98+
path: /etc/kubernetes/admin.conf
99+
type: FileOrCreate
100+
name: kubeconfig
101+
status: {}
102+
owner: root:root
103+
path: /etc/kubernetes/manifests/kube-vip.yaml
104+
machineTemplate:
105+
infrastructureRef:
106+
kind: CloudStackMachineTemplate
107+
apiVersion: infrastructure.cluster.x-k8s.io/v1beta1
108+
name: "${CLUSTER_NAME}-control-plane"
109+
replicas: ${CONTROL_PLANE_MACHINE_COUNT}
110+
version: ${KUBERNETES_VERSION}
111+
---
112+
apiVersion: infrastructure.cluster.x-k8s.io/v1beta1
113+
kind: CloudStackMachineTemplate
114+
metadata:
115+
name: ${CLUSTER_NAME}-control-plane
116+
spec:
117+
template:
118+
spec:
119+
offering:
120+
name: ${CLOUDSTACK_CONTROL_PLANE_MACHINE_OFFERING}
121+
template:
122+
name: ${CLOUDSTACK_TEMPLATE_NAME}
123+
---
124+
apiVersion: cluster.x-k8s.io/v1beta1
125+
kind: MachineDeployment
126+
metadata:
127+
name: "${CLUSTER_NAME}-md-0"
128+
spec:
129+
clusterName: "${CLUSTER_NAME}"
130+
replicas: ${WORKER_MACHINE_COUNT}
131+
selector:
132+
matchLabels: null
133+
template:
134+
spec:
135+
bootstrap:
136+
configRef:
137+
apiVersion: bootstrap.cluster.x-k8s.io/v1beta1
138+
kind: KubeadmConfigTemplate
139+
name: "${CLUSTER_NAME}-md-0"
140+
clusterName: "${CLUSTER_NAME}"
141+
infrastructureRef:
142+
name: "${CLUSTER_NAME}-md-0"
143+
apiVersion: infrastructure.cluster.x-k8s.io/v1beta1
144+
kind: CloudStackMachineTemplate
145+
version: ${KUBERNETES_VERSION}
146+
---
147+
apiVersion: infrastructure.cluster.x-k8s.io/v1beta1
148+
kind: CloudStackMachineTemplate
149+
metadata:
150+
name: ${CLUSTER_NAME}-md-0
151+
spec:
152+
template:
153+
spec:
154+
offering:
155+
name: ${CLOUDSTACK_WORKER_MACHINE_OFFERING}
156+
template:
157+
name: ${CLOUDSTACK_TEMPLATE_NAME}
158+
---
159+
apiVersion: bootstrap.cluster.x-k8s.io/v1beta1
160+
kind: KubeadmConfigTemplate
161+
metadata:
162+
name: ${CLUSTER_NAME}-md-0
163+
spec:
164+
template:
165+
spec:
166+
joinConfiguration:
167+
nodeRegistration:
168+
kubeletExtraArgs:
169+
provider-id: "cloudstack:///'{{ ds.meta_data.instance_id }}'"
170+
name: '{{ local_hostname }}'
171+
preKubeadmCommands:
172+
- swapoff -a
173+

test/e2e/config/cloudstack.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ providers:
8686
- sourcePath: "../data/infrastructure-cloudstack/v1beta1/cluster-template-affinity-group-anti.yaml"
8787
- sourcePath: "../data/infrastructure-cloudstack/v1beta1/cluster-template-resource-cleanup.yaml"
8888
- sourcePath: "../data/infrastructure-cloudstack/v1beta1/cluster-template-second-cluster.yaml"
89+
- sourcePath: "../data/infrastructure-cloudstack/v1beta1/cluster-template-shared-network-kubevip.yaml"
8990
- sourcePath: "../data/shared/v1beta1/metadata.yaml"
9091
versions:
9192
- name: v1.0.0
@@ -111,6 +112,7 @@ variables:
111112
CLOUDSTACK_INVALID_DOMAIN_NAME: domainXXXX
112113
CLOUDSTACK_NETWORK_NAME: isolated-for-e2e-1
113114
CLOUDSTACK_NEW_NETWORK_NAME: isolated-for-e2e-new
115+
CLOUDSTACK_SHARED_NETWORK_NAME: Shared1
114116
CLUSTER_ENDPOINT_IP: 172.16.2.199
115117
CLUSTER_ENDPOINT_IP_2: 172.16.2.198
116118
CLUSTER_ENDPOINT_NEW_IP: 172.16.2.201
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,124 @@
1+
---
2+
apiVersion: cluster.x-k8s.io/v1beta1
3+
kind: Cluster
4+
metadata:
5+
name: ${CLUSTER_NAME}
6+
spec:
7+
clusterNetwork:
8+
pods:
9+
cidrBlocks:
10+
- 192.168.0.0/16
11+
serviceDomain: "cluster.local"
12+
infrastructureRef:
13+
apiVersion: infrastructure.cluster.x-k8s.io/v1beta1
14+
kind: CloudStackCluster
15+
name: ${CLUSTER_NAME}
16+
controlPlaneRef:
17+
kind: KubeadmControlPlane
18+
apiVersion: controlplane.cluster.x-k8s.io/v1beta1
19+
name: ${CLUSTER_NAME}-control-plane
20+
---
21+
apiVersion: infrastructure.cluster.x-k8s.io/v1beta1
22+
kind: CloudStackCluster
23+
metadata:
24+
name: ${CLUSTER_NAME}
25+
spec:
26+
zones:
27+
- name : ${CLOUDSTACK_ZONE_NAME}
28+
network:
29+
name: ${CLOUDSTACK_SHARED_NETWORK_NAME}
30+
controlPlaneEndpoint:
31+
host: ${CLUSTER_ENDPOINT_IP}
32+
port: ${CLUSTER_ENDPOINT_PORT}
33+
---
34+
kind: KubeadmControlPlane
35+
apiVersion: controlplane.cluster.x-k8s.io/v1beta1
36+
metadata:
37+
name: ${CLUSTER_NAME}-control-plane
38+
spec:
39+
kubeadmConfigSpec:
40+
initConfiguration:
41+
nodeRegistration:
42+
name: '{{ local_hostname }}'
43+
kubeletExtraArgs:
44+
provider-id: cloudstack:///'{{ ds.meta_data.instance_id }}'
45+
clusterConfiguration:
46+
imageRepository: k8s.gcr.io
47+
joinConfiguration:
48+
nodeRegistration:
49+
name: '{{ local_hostname }}'
50+
kubeletExtraArgs:
51+
provider-id: cloudstack:///'{{ ds.meta_data.instance_id }}'
52+
ignorePreflightErrors:
53+
- DirAvailable--etc-kubernetes-manifests
54+
preKubeadmCommands:
55+
- swapoff -a
56+
files:
57+
- content: |
58+
apiVersion: v1
59+
kind: Pod
60+
metadata:
61+
creationTimestamp: null
62+
name: kube-vip
63+
namespace: kube-system
64+
spec:
65+
containers:
66+
- args:
67+
- start
68+
env:
69+
- name: vip_arp
70+
value: "true"
71+
- name: vip_leaderelection
72+
value: "true"
73+
- name: vip_address
74+
value: ${CLUSTER_ENDPOINT_IP}
75+
- name: vip_interface
76+
value: ens3
77+
- name: vip_leaseduration
78+
value: "15"
79+
- name: vip_renewdeadline
80+
value: "10"
81+
- name: vip_retryperiod
82+
value: "2"
83+
image: public.ecr.aws/i3w0y7q3/plunder-app/kube-vip:v0.3.7-eks-a-v0.0.0-dev-build.0
84+
imagePullPolicy: IfNotPresent
85+
name: kube-vip
86+
resources: {}
87+
securityContext:
88+
capabilities:
89+
add:
90+
- NET_ADMIN
91+
- SYS_TIME
92+
volumeMounts:
93+
- mountPath: /etc/kubernetes/admin.conf
94+
name: kubeconfig
95+
hostNetwork: true
96+
volumes:
97+
- hostPath:
98+
path: /etc/kubernetes/admin.conf
99+
type: FileOrCreate
100+
name: kubeconfig
101+
status: {}
102+
owner: root:root
103+
path: /etc/kubernetes/manifests/kube-vip.yaml
104+
machineTemplate:
105+
infrastructureRef:
106+
apiVersion: infrastructure.cluster.x-k8s.io/v1beta1
107+
kind: CloudStackMachineTemplate
108+
name: ${CLUSTER_NAME}-control-plane
109+
replicas: ${CONTROL_PLANE_MACHINE_COUNT}
110+
version: ${KUBERNETES_VERSION}
111+
---
112+
apiVersion: infrastructure.cluster.x-k8s.io/v1beta1
113+
kind: CloudStackMachineTemplate
114+
metadata:
115+
name: ${CLUSTER_NAME}-control-plane
116+
spec:
117+
template:
118+
spec:
119+
offering:
120+
name: ${CLOUDSTACK_CONTROL_PLANE_MACHINE_OFFERING}
121+
template:
122+
name: ${CLOUDSTACK_TEMPLATE_NAME}
123+
sshKey: ${CLOUDSTACK_SSH_KEY_NAME}
124+
---
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
bases:
2+
- ./cluster-with-shared-network-and-kubevip.yaml
3+
- ../bases/md.yaml

0 commit comments

Comments
 (0)