Skip to content

Commit

Permalink
kubeadm: on digital ocean, use public IP
Browse files Browse the repository at this point in the history
Signed-off-by: Mathieu Tortuyaux <[email protected]>
  • Loading branch information
tormath1 committed Nov 29, 2023
1 parent b99dea6 commit 05ae425
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 1 deletion.
17 changes: 16 additions & 1 deletion kola/tests/kubeadm/templates.go
Original file line number Diff line number Diff line change
Expand Up @@ -365,6 +365,11 @@ curl --retry-delay 1 \
# kubelet config for both controller and worker
cgroup=$(docker info | awk '/Cgroup Driver/ { print $3}')
{{ if eq .Platform "do" }}
systemctl start --quiet coreos-metadata
ipv4=$(cat /run/metadata/flatcar | grep -v -E '(IPV6|GATEWAY)' | grep IP | grep -E '(PUBLIC|LOCAL|DYNAMIC)' | cut -d = -f 2)
{{ end }}
# we create the kubeadm config
# plugin-volume-dir and flex-volume-plugin-dir are required since /usr is read-only mounted
# etcd is also defined as external. The provided one has some issues with docker and selinux
Expand All @@ -379,6 +384,10 @@ kind: InitConfiguration
nodeRegistration:
kubeletExtraArgs:
volume-plugin-dir: "/opt/libexec/kubernetes/kubelet-plugins/volume/exec/"
{{ if eq .Platform "do" }}
# On Digital Ocean, the private node IP is not reachable from one node to the other - let's use the public one.
node-ip: "${ipv4}"
{{ end }}
---
apiVersion: kubeadm.k8s.io/v1beta3
kind: ClusterConfiguration
Expand Down Expand Up @@ -412,6 +421,12 @@ spec:
imagePath: flatcar/calico
# Configures Calico networking.
calicoNetwork:
{{ if eq .Platform "do" }}
# On Digital Ocean, there is two network interfaces: eth0 and eth1
# We use the one with a public IP (eth0)
nodeAddressAutodetectionV4:
interface: eth0
{{ end }}
# Note: The ipPools section cannot be modified post-install.
ipPools:
- blockSize: 26
Expand Down Expand Up @@ -537,7 +552,7 @@ cat << EOF > worker-config.yaml
EOF
systemctl start --quiet coreos-metadata
ipv4=$(cat /run/metadata/flatcar | grep -v -E '(IPV6|GATEWAY)' | grep IP | grep -E '(PRIVATE|LOCAL|DYNAMIC)' | cut -d = -f 2)
ipv4=$(cat /run/metadata/flatcar | grep -v -E '(IPV6|GATEWAY)' | grep IP | grep -E '({{ if eq .Platform "do" }}PUBLIC{{ else }}PRIVATE{{ end }}|LOCAL|DYNAMIC)' | cut -d = -f 2)
kubeadm join --config worker-config.yaml --node-name "${ipv4}"
`
Expand Down
4 changes: 4 additions & 0 deletions kola/tests/kubeadm/testdata/master-calico-script.sh
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ curl --retry-delay 1 \
# kubelet config for both controller and worker
cgroup=$(docker info | awk '/Cgroup Driver/ { print $3}')



# we create the kubeadm config
# plugin-volume-dir and flex-volume-plugin-dir are required since /usr is read-only mounted
# etcd is also defined as external. The provided one has some issues with docker and selinux
Expand All @@ -54,6 +56,7 @@ kind: InitConfiguration
nodeRegistration:
kubeletExtraArgs:
volume-plugin-dir: "/opt/libexec/kubernetes/kubelet-plugins/volume/exec/"
---
apiVersion: kubeadm.k8s.io/v1beta3
kind: ClusterConfiguration
Expand Down Expand Up @@ -87,6 +90,7 @@ spec:
imagePath: flatcar/calico
# Configures Calico networking.
calicoNetwork:
# Note: The ipPools section cannot be modified post-install.
ipPools:
- blockSize: 26
Expand Down
3 changes: 3 additions & 0 deletions kola/tests/kubeadm/testdata/master-cilium-script.sh
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ curl --retry-delay 1 \
# kubelet config for both controller and worker
cgroup=$(docker info | awk '/Cgroup Driver/ { print $3}')



# we create the kubeadm config
# plugin-volume-dir and flex-volume-plugin-dir are required since /usr is read-only mounted
# etcd is also defined as external. The provided one has some issues with docker and selinux
Expand All @@ -54,6 +56,7 @@ kind: InitConfiguration
nodeRegistration:
kubeletExtraArgs:
volume-plugin-dir: "/opt/libexec/kubernetes/kubelet-plugins/volume/exec/"
---
apiVersion: kubeadm.k8s.io/v1beta3
kind: ClusterConfiguration
Expand Down
3 changes: 3 additions & 0 deletions kola/tests/kubeadm/testdata/master-flannel-script.sh
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ curl --retry-delay 1 \
# kubelet config for both controller and worker
cgroup=$(docker info | awk '/Cgroup Driver/ { print $3}')



# we create the kubeadm config
# plugin-volume-dir and flex-volume-plugin-dir are required since /usr is read-only mounted
# etcd is also defined as external. The provided one has some issues with docker and selinux
Expand All @@ -54,6 +56,7 @@ kind: InitConfiguration
nodeRegistration:
kubeletExtraArgs:
volume-plugin-dir: "/opt/libexec/kubernetes/kubelet-plugins/volume/exec/"
---
apiVersion: kubeadm.k8s.io/v1beta3
kind: ClusterConfiguration
Expand Down

0 comments on commit 05ae425

Please sign in to comment.