-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #182 from kinvolk/tormath1/kubeadm-add-flannel
kola/kubeadm: test various CNIs
- Loading branch information
Showing
6 changed files
with
405 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,120 @@ | ||
#!/bin/bash | ||
set -euo pipefail | ||
|
||
export RELEASE_VERSION=v0.4.0 | ||
export DOWNLOAD_DIR=/opt/bin | ||
export PATH="${PATH}:${DOWNLOAD_DIR}" | ||
|
||
# create the required directory | ||
mkdir --parent \ | ||
/etc/systemd/system/kubelet.service.d \ | ||
${HOME}/.kube \ | ||
/home/core/.kube | ||
|
||
# we download and install the various requirements: | ||
# * kubelet service and kubeadm dropin | ||
|
||
curl --retry-delay 1 \ | ||
--retry 60 \ | ||
--retry-connrefused \ | ||
--retry-max-time 60 \ | ||
--connect-timeout 20 \ | ||
--fail \ | ||
-sSL \ | ||
"https://raw.githubusercontent.com/kubernetes/release/${RELEASE_VERSION}/cmd/kubepkg/templates/latest/deb/kubelet/lib/systemd/system/kubelet.service" | | ||
sed "s:/usr/bin:${DOWNLOAD_DIR}:g" > /etc/systemd/system/kubelet.service | ||
|
||
curl --retry-delay 1 \ | ||
--retry 60 \ | ||
--retry-connrefused \ | ||
--retry-max-time 60 \ | ||
--connect-timeout 20 \ | ||
--fail \ | ||
-sSL \ | ||
"https://raw.githubusercontent.com/kubernetes/release/${RELEASE_VERSION}/cmd/kubepkg/templates/latest/deb/kubeadm/10-kubeadm.conf" | | ||
sed "s:/usr/bin:${DOWNLOAD_DIR}:g" > /etc/systemd/system/kubelet.service.d/10-kubeadm.conf | ||
|
||
# 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 | ||
# (permission denied with /var/lib/etcd) so it can't boot properly | ||
cat << EOF > kubeadm-config.yaml | ||
apiVersion: kubeadm.k8s.io/v1beta2 | ||
kind: InitConfiguration | ||
nodeRegistration: | ||
kubeletExtraArgs: | ||
volume-plugin-dir: "/opt/libexec/kubernetes/kubelet-plugins/volume/exec/" | ||
--- | ||
apiVersion: kubeadm.k8s.io/v1beta2 | ||
kind: ClusterConfiguration | ||
networking: | ||
podSubnet: 192.168.0.0/17 | ||
controllerManager: | ||
extraArgs: | ||
flex-volume-plugin-dir: "/opt/libexec/kubernetes/kubelet-plugins/volume/exec/" | ||
etcd: | ||
external: | ||
endpoints: | ||
- http://1.2.3.4:2379 | ||
EOF | ||
|
||
|
||
cat << EOF > calico.yaml | ||
# Source: https://docs.projectcalico.org/manifests/custom-resources.yaml | ||
apiVersion: operator.tigera.io/v1 | ||
kind: Installation | ||
metadata: | ||
name: default | ||
spec: | ||
# Configures Calico networking. | ||
calicoNetwork: | ||
# Note: The ipPools section cannot be modified post-install. | ||
ipPools: | ||
- blockSize: 26 | ||
cidr: 192.168.0.0/17 | ||
encapsulation: VXLANCrossSubnet | ||
natOutgoing: Enabled | ||
nodeSelector: all() | ||
flexVolumePath: /opt/libexec/kubernetes/kubelet-plugins/volume/exec/ | ||
EOF | ||
|
||
|
||
{ | ||
systemctl enable --quiet --now kubelet | ||
kubeadm config images pull | ||
kubeadm init --config kubeadm-config.yaml | ||
cp /etc/kubernetes/admin.conf $HOME/.kube/config | ||
cp /etc/kubernetes/admin.conf /home/core/.kube/config | ||
chown -R core:core /home/core/.kube; chmod a+r /home/core/.kube/config; | ||
|
||
|
||
kubectl create -f https://docs.projectcalico.org/manifests/tigera-operator.yaml | ||
kubectl apply -f calico.yaml | ||
|
||
|
||
|
||
} 1>&2 | ||
|
||
|
||
URL=$(kubectl config view -o jsonpath='{.clusters[0].cluster.server}') | ||
prefix="https://" | ||
short_url=${URL#"${prefix}"} | ||
token=$(kubeadm token create) | ||
certHashes=$(openssl x509 -pubkey -in /etc/kubernetes/pki/ca.crt | openssl rsa -pubin -outform der 2>/dev/null | openssl dgst -sha256 -hex | sed 's/^.* //') | ||
|
||
cat << EOF | ||
apiVersion: kubeadm.k8s.io/v1beta2 | ||
kind: JoinConfiguration | ||
discovery: | ||
bootstrapToken: | ||
apiServerEndpoint: ${short_url} | ||
token: ${token} | ||
caCertHashes: | ||
- sha256:${certHashes} | ||
controlPlane: | ||
nodeRegistration: | ||
kubeletExtraArgs: | ||
volume-plugin-dir: "/opt/libexec/kubernetes/kubelet-plugins/volume/exec/" | ||
EOF |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,105 @@ | ||
#!/bin/bash | ||
set -euo pipefail | ||
|
||
export RELEASE_VERSION=v0.4.0 | ||
export DOWNLOAD_DIR=/opt/bin | ||
export PATH="${PATH}:${DOWNLOAD_DIR}" | ||
|
||
# create the required directory | ||
mkdir --parent \ | ||
/etc/systemd/system/kubelet.service.d \ | ||
${HOME}/.kube \ | ||
/home/core/.kube | ||
|
||
# we download and install the various requirements: | ||
# * kubelet service and kubeadm dropin | ||
|
||
curl --retry-delay 1 \ | ||
--retry 60 \ | ||
--retry-connrefused \ | ||
--retry-max-time 60 \ | ||
--connect-timeout 20 \ | ||
--fail \ | ||
-sSL \ | ||
"https://raw.githubusercontent.com/kubernetes/release/${RELEASE_VERSION}/cmd/kubepkg/templates/latest/deb/kubelet/lib/systemd/system/kubelet.service" | | ||
sed "s:/usr/bin:${DOWNLOAD_DIR}:g" > /etc/systemd/system/kubelet.service | ||
|
||
curl --retry-delay 1 \ | ||
--retry 60 \ | ||
--retry-connrefused \ | ||
--retry-max-time 60 \ | ||
--connect-timeout 20 \ | ||
--fail \ | ||
-sSL \ | ||
"https://raw.githubusercontent.com/kubernetes/release/${RELEASE_VERSION}/cmd/kubepkg/templates/latest/deb/kubeadm/10-kubeadm.conf" | | ||
sed "s:/usr/bin:${DOWNLOAD_DIR}:g" > /etc/systemd/system/kubelet.service.d/10-kubeadm.conf | ||
|
||
# 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 | ||
# (permission denied with /var/lib/etcd) so it can't boot properly | ||
cat << EOF > kubeadm-config.yaml | ||
apiVersion: kubeadm.k8s.io/v1beta2 | ||
kind: InitConfiguration | ||
nodeRegistration: | ||
kubeletExtraArgs: | ||
volume-plugin-dir: "/opt/libexec/kubernetes/kubelet-plugins/volume/exec/" | ||
--- | ||
apiVersion: kubeadm.k8s.io/v1beta2 | ||
kind: ClusterConfiguration | ||
networking: | ||
podSubnet: 192.168.0.0/17 | ||
controllerManager: | ||
extraArgs: | ||
flex-volume-plugin-dir: "/opt/libexec/kubernetes/kubelet-plugins/volume/exec/" | ||
etcd: | ||
external: | ||
endpoints: | ||
- http://1.2.3.4:2379 | ||
EOF | ||
|
||
|
||
|
||
{ | ||
systemctl enable --quiet --now kubelet | ||
kubeadm config images pull | ||
kubeadm init --config kubeadm-config.yaml | ||
cp /etc/kubernetes/admin.conf $HOME/.kube/config | ||
cp /etc/kubernetes/admin.conf /home/core/.kube/config | ||
chown -R core:core /home/core/.kube; chmod a+r /home/core/.kube/config; | ||
|
||
|
||
|
||
|
||
sudo tar -xf /opt/bin/cilium.tar.gz -C /opt/bin | ||
/opt/bin/cilium install \ | ||
--config enable-endpoint-routes=true \ | ||
--config cluster-pool-ipv4-cidr=192.168.0.0/17 | ||
# --wait will wait for status to report success | ||
/opt/bin/cilium status --wait | ||
|
||
} 1>&2 | ||
|
||
|
||
URL=$(kubectl config view -o jsonpath='{.clusters[0].cluster.server}') | ||
prefix="https://" | ||
short_url=${URL#"${prefix}"} | ||
token=$(kubeadm token create) | ||
certHashes=$(openssl x509 -pubkey -in /etc/kubernetes/pki/ca.crt | openssl rsa -pubin -outform der 2>/dev/null | openssl dgst -sha256 -hex | sed 's/^.* //') | ||
|
||
cat << EOF | ||
apiVersion: kubeadm.k8s.io/v1beta2 | ||
kind: JoinConfiguration | ||
discovery: | ||
bootstrapToken: | ||
apiServerEndpoint: ${short_url} | ||
token: ${token} | ||
caCertHashes: | ||
- sha256:${certHashes} | ||
controlPlane: | ||
nodeRegistration: | ||
kubeletExtraArgs: | ||
volume-plugin-dir: "/opt/libexec/kubernetes/kubelet-plugins/volume/exec/" | ||
EOF |
Oops, something went wrong.