48
48
rm -rf ${WORKDIR} /s3
49
49
mkdir -p ${WORKDIR} /s3/
50
50
51
+ IPV4_PREFIX=10.123.45.
52
+
53
+ VM0_IP=${IPV4_PREFIX} 10
54
+ VM1_IP=${IPV4_PREFIX} 11
55
+ VM2_IP=${IPV4_PREFIX} 12
56
+
51
57
# Start our VMs
52
58
${REPO_ROOT} /tests/e2e/scenarios/bare-metal/start-vms
53
59
60
+ # Start an SSH agent; enroll assumes SSH connectivity to the VMs with the key in the agent
61
+ eval $( ssh-agent)
62
+ ssh-add ${REPO_ROOT} /.build/.ssh/id_ed25519
63
+
54
64
. hack/dev-build-metal.sh
55
65
56
66
echo " Waiting 10 seconds for VMs to start"
57
67
sleep 10
58
68
59
69
# Remove from known-hosts in case of reuse
60
- ssh-keygen -f ~ /.ssh/known_hosts -R 10.123.45.10 || true
61
- ssh-keygen -f ~ /.ssh/known_hosts -R 10.123.45.11 || true
62
- ssh-keygen -f ~ /.ssh/known_hosts -R 10.123.45.12 || true
70
+ ssh-keygen -f ~ /.ssh/known_hosts -R ${VM0_IP} || true
71
+ ssh-keygen -f ~ /.ssh/known_hosts -R ${VM1_IP} || true
72
+ ssh-keygen -f ~ /.ssh/known_hosts -R ${VM2_IP} || true
63
73
64
- ssh -o StrictHostKeyChecking=accept-new -i
${REPO_ROOT} /.build/.ssh/id_ed25519
[email protected] uptime
65
- ssh -o StrictHostKeyChecking=accept-new -i
${REPO_ROOT} /.build/.ssh/id_ed25519
[email protected] uptime
66
- ssh -o StrictHostKeyChecking=accept-new -i
${REPO_ROOT} /.build/.ssh/id_ed25519
[email protected] uptime
74
+ # Check SSH is working and accept the keys
75
+ ssh -o StrictHostKeyChecking=accept-new root@${VM0_IP} uptime
76
+ ssh -o StrictHostKeyChecking=accept-new root@${VM1_IP} uptime
77
+ ssh -o StrictHostKeyChecking=accept-new root@${VM2_IP} uptime
67
78
68
79
cd ${REPO_ROOT}
69
80
@@ -93,7 +104,7 @@ ${KOPS} create cluster --cloud=metal metal.k8s.local --zones main --networking c
93
104
94
105
# Set the IP ingress, required for metal cloud
95
106
# TODO: is this the best option?
96
- ${KOPS} edit cluster metal.k8s.local --set spec.api.publicName=10.123.45.10
107
+ ${KOPS} edit cluster metal.k8s.local --set spec.api.publicName=${VM0_IP}
97
108
98
109
# Use latest etcd-manager image (while we're adding features)
99
110
${KOPS} edit cluster metal.k8s.local --set ' spec.etcdClusters[*].manager.image=us-central1-docker.pkg.dev/k8s-staging-images/etcd-manager/etcd-manager-static:latest'
@@ -114,28 +125,24 @@ ${KOPS} get ig --name metal.k8s.local -oyaml
114
125
${KOPS} update cluster metal.k8s.local
115
126
${KOPS} update cluster metal.k8s.local --yes --admin
116
127
117
- # Start an SSH agent; enroll assumes SSH connectivity to the VMs with the key in the agent
118
- eval $( ssh-agent)
119
- ssh-add ${REPO_ROOT} /.build/.ssh/id_ed25519
120
-
121
128
# Enroll the control-plane VM
122
- ${KOPS} toolbox enroll --cluster metal.k8s.local --instance-group control-plane-main --host 10.123.45.10 --v=2
129
+ ${KOPS} toolbox enroll --cluster metal.k8s.local --instance-group control-plane-main --host ${VM0_IP} --v=2
123
130
124
131
# Manual creation of "volumes" for etcd, and setting up peer nodes
125
- cat
<< EOF | ssh -o StrictHostKeyChecking=accept-new -i ${REPO_ROOT} /.build/.ssh/id_ed25519 [email protected] tee -a /etc/hosts
132
+ cat << EOF | ssh root@ ${VM0_IP} tee -a /etc/hosts
126
133
127
134
# Hosts added for etcd discovery
128
- 10.123.45.10 node0.main.metal.k8s.local
129
- 10.123.45.10 node0.events.metal.k8s.local
135
+ ${VM0_IP} node0.main.metal.k8s.local
136
+ ${VM0_IP} node0.events.metal.k8s.local
130
137
EOF
131
138
132
- ssh
-o StrictHostKeyChecking=accept-new -i ${REPO_ROOT} /.build/.ssh/id_ed25519 [email protected] cat /etc/hosts
139
+ ssh root@ ${VM0_IP} cat /etc/hosts
133
140
134
- ssh
-o StrictHostKeyChecking=accept-new -i ${REPO_ROOT} /.build/.ssh/id_ed25519 [email protected] mkdir -p /mnt/disks/metal.k8s.local--main--0/mnt
135
- ssh
-o StrictHostKeyChecking=accept-new -i ${REPO_ROOT} /.build/.ssh/id_ed25519 [email protected] touch /mnt/disks/metal.k8s.local--main--0/mnt/please-create-new-cluster
141
+ ssh root@ ${VM0_IP} mkdir -p /mnt/disks/metal.k8s.local--main--0/mnt
142
+ ssh root@ ${VM0_IP} touch /mnt/disks/metal.k8s.local--main--0/mnt/please-create-new-cluster
136
143
137
- ssh
-o StrictHostKeyChecking=accept-new -i ${REPO_ROOT} /.build/.ssh/id_ed25519 [email protected] mkdir -p /mnt/disks/metal.k8s.local--events--0/mnt
138
- ssh
-o StrictHostKeyChecking=accept-new -i ${REPO_ROOT} /.build/.ssh/id_ed25519 [email protected] touch /mnt/disks/metal.k8s.local--events--0/mnt/please-create-new-cluster
144
+ ssh root@ ${VM0_IP} mkdir -p /mnt/disks/metal.k8s.local--events--0/mnt
145
+ ssh root@ ${VM0_IP} touch /mnt/disks/metal.k8s.local--events--0/mnt/please-create-new-cluster
139
146
140
147
141
148
echo " Waiting for kube to start"
@@ -204,18 +211,18 @@ function enroll_node() {
204
211
205
212
# Manual "discovery" for control-plane endpoints
206
213
# TODO: Replace with well-known IP
207
- cat << EOF | ssh -o StrictHostKeyChecking=accept-new -i ${REPO_ROOT} /.build/.ssh/id_ed25519 root@${node_ip} tee -a /etc/hosts
214
+ cat << EOF | ssh root@${node_ip} tee -a /etc/hosts
208
215
209
216
# Hosts added for leader discovery
210
- 10.123.45.10 kops-controller.internal.metal.k8s.local
211
- 10.123.45.10 api.internal.metal.k8s.local
217
+ ${VM0_IP} kops-controller.internal.metal.k8s.local
218
+ ${VM0_IP} api.internal.metal.k8s.local
212
219
EOF
213
220
214
221
timeout 10m ${KOPS} toolbox enroll --cluster metal.k8s.local --instance-group nodes-main --host ${node_ip} --v=2
215
222
}
216
223
217
- enroll_node 10.123.45.11
218
- enroll_node 10.123.45.12
224
+ enroll_node ${VM1_IP}
225
+ enroll_node ${VM2_IP}
219
226
220
227
echo " Waiting 30 seconds for nodes to be ready"
221
228
sleep 30
0 commit comments