@@ -43,19 +43,34 @@ Vagrant.configure("2") do |config|
4343 echo -e "${ETC_HOSTS}" | while read -r hline; do
4444 sudo echo ${hline} >> /etc/hosts
4545 done
46+
4647 # Create Cluster Init Script:
47- echo "#!/bin/bash" > cluster_init.sh
48- echo "echo 'Pulling k8s Images'" >> cluster_init.sh
49- echo "sudo kubeadm config images pull" >> cluster_init.sh
50- echo "echo ''" >> cluster_init.sh
51- echo "echo 'Initializing Cluster'" >> cluster_init.sh
48+ echo "#!/bin/bash" > cluster_init.sh
49+ echo "echo 'Pulling k8s Images'" >> cluster_init.sh
50+ echo "sudo kubeadm config images pull" >> cluster_init.sh
51+ echo "echo ''" >> cluster_init.sh
52+ echo "echo 'Initializing Cluster'" >> cluster_init.sh
5253 echo "sudo kubeadm init --pod-network-cidr=${BASE_CIDR}/16 --apiserver-advertise-address=${API_SERVER_IP}" >> cluster_init.sh
54+ echo "if [ -f /etc/kubernetes/admin.conf ] ; then" >> cluster_init.sh
55+ echo " echo ''" >> cluster_init.sh
56+ echo " echo 'Create local .kube/config'" >> cluster_init.sh
57+ echo " mkdir -p \\ \$ {HOME}/.kube" >> cluster_init.sh
58+ echo " sudo cp -i /etc/kubernetes/admin.conf \\ \$ {HOME}/.kube/config" >> cluster_init.sh
59+ echo " sudo chown \\ \$ (id -u):\\ \$ (id -g) \\ \$ {HOME}/.kube/config" >> cluster_init.sh
60+ echo " echo ''" >> cluster_init.sh
61+ echo " echo 'Install Weave'" >> cluster_init.sh
62+ echo " kubectl apply -f https://github.com/weaveworks/weave/releases/download/v2.8.1/weave-daemonset-k8s.yaml" >> cluster_init.sh
63+ echo "fi" >> cluster_init.sh
5364 chmod a+rx cluster_init.sh
54- # Create Weave Install Script:
55- sudo echo "#!/bin/bash" > weave_install.sh
56- sudo echo "echo 'Install Weave'" >> weave_install.sh
57- sudo echo "kubectl apply -f https://github.com/weaveworks/weave/releases/download/v2.8.1/weave-daemonset-k8s.yaml" >> weave_install.sh
58- sudo chmod a+rx weave_install.sh
65+
66+ # Show the k8s join command:
67+ echo "#!/bin/bash" > join_cmd.sh
68+ echo "echo 'k8s worker join command (may need sudo):'" >> join_cmd.sh
69+ echo "echo ''" >> join_cmd.sh
70+ echo "kubeadm token create --print-join-command" >> join_cmd.sh
71+ echo "echo ''" >> join_cmd.sh
72+ sudo chmod a+rx join_cmd.sh
73+
5974 # Apt Stuff:
6075 sudo apt update
6176 sudo apt install ca-certificates curl
@@ -76,6 +91,7 @@ Vagrant.configure("2") do |config|
7691 sudo apt update && sudo apt install -y apt-transport-https
7792 curl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo apt-key add -
7893 sudo apt update
94+
7995 # apt-transport-https may be a dummy package; if so, you can skip that package
8096 sudo apt install -y apt-transport-https ca-certificates curl gpg
8197 curl -fsSL https://pkgs.k8s.io/core:/stable:/v1.30/deb/Release.key | sudo gpg --dearmor -o /etc/apt/keyrings/kubernetes-apt-keyring.gpg
0 commit comments