Last active
October 17, 2019 14:28
-
-
Save moondev/650bbcc4d5b6e65ef360020b44c38b32 to your computer and use it in GitHub Desktop.
instakube-user-data
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
local-hostname: my-servername |
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
#!/bin/bash | |
# if [ -z "$1" ] | |
# then | |
# touch /manual_run | |
# else | |
# touch /boot_run | |
# exit 2; | |
# fi | |
# vmtoolsd --cmd "info-get guestinfo.ovfEnv" | |
export K8SV="1.16.2-00" | |
export ORIGINAL_HOSTNAME=`hostname` | |
export IP=`hostname -I | awk '{ print $1 }'` | |
export HOST="${ORIGINAL_HOSTNAME}.${IP}.nip.io" | |
export CRI="docker-ce" | |
export CIDR="192.168.0.0/16" | |
export CNI="https://docs.projectcalico.org/v3.8/manifests/calico.yaml" | |
export CRITOOLS="1.13.0-00" | |
export KCNI="0.7.5-00" | |
hostnamectl set-hostname ${HOST} | |
sleep 5 | |
apt-get update | |
apt-get update | |
apt-get install -y apt-transport-https ca-certificates curl software-properties-common | |
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | apt-key add - | |
add-apt-repository \ | |
"deb [arch=amd64] https://download.docker.com/linux/ubuntu \ | |
$(lsb_release -cs) \ | |
stable" | |
apt-get update | |
curl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | apt-key add - | |
cat <<EOF >/etc/apt/sources.list.d/kubernetes.list | |
deb https://apt.kubernetes.io/ kubernetes-xenial main | |
EOF | |
apt-get update | |
apt-get install -y ${CRI} | |
cat > /etc/docker/daemon.json <<EOF | |
{ | |
"exec-opts": ["native.cgroupdriver=systemd"], | |
"log-driver": "json-file", | |
"log-opts": { | |
"max-size": "100m" | |
}, | |
"storage-driver": "overlay2" | |
} | |
EOF | |
mkdir -p /etc/systemd/system/docker.service.d | |
# Restart docker. | |
systemctl daemon-reload | |
systemctl restart docker | |
apt-get install -y kubeadm=${K8SV} kubelet=${K8SV} kubectl=${K8SV} kubernetes-cni=${KCNI} cri-tools=${CRITOOLS} | |
sleep 5 | |
kubeadm init --pod-network-cidr=${CIDR} --node-name=${HOST} | |
sleep 30 | |
mkdir -p /root/.kube | |
cp -i /etc/kubernetes/admin.conf /root/.kube/config | |
chown $(id -u):$(id -g) /root/.kube/config | |
export KUBECONFIG=/etc/kubernetes/admin.conf | |
kubectl taint nodes --all node-role.kubernetes.io/master- | |
sleep 60 | |
kubectl apply -f ${CNI} | |
sleep 60 | |
kubectl get nodes -o wide | |
kubectl get pods -A | |
kubectl get pods -A -o yaml | grep image: | |
kubectl cluster-info | |
kubeadm token create --print-join-command > /JOIN | |
kubectl config view --flatten > /KUBECONFIG |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment