moved kubernetes directory to vagrant-templates repo
parent
ece76b25e5
commit
24e9eebe29
@ -1 +0,0 @@
|
||||
kubeadm_join.sh
|
@ -1,22 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
# vim:ts=4:sts=4:sw=4:et
|
||||
#
|
||||
# Author: Hari Sekhon
|
||||
# Date: 2020-08-29 09:19:22 +0100 (Sat, 29 Aug 2020)
|
||||
#
|
||||
# https://github.com/HariSekhon/DevOps-Bash-tools
|
||||
#
|
||||
# License: see accompanying Hari Sekhon LICENSE file
|
||||
#
|
||||
# If you're using my code you're welcome to connect with me on LinkedIn and optionally send me feedback to help steer this or other code I publish
|
||||
#
|
||||
# https://www.linkedin.com/in/HariSekhon
|
||||
#
|
||||
|
||||
set -euo pipefail
|
||||
[ -n "${DEBUG:-}" ] && set -x
|
||||
srcdir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
|
||||
cd "$srcdir"
|
||||
|
||||
vagrant up master1 worker1
|
@ -1,22 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
# vim:ts=4:sts=4:sw=4:et
|
||||
#
|
||||
# Author: Hari Sekhon
|
||||
# Date: 2020-08-29 09:19:22 +0100 (Sat, 29 Aug 2020)
|
||||
#
|
||||
# https://github.com/HariSekhon/DevOps-Bash-tools
|
||||
#
|
||||
# License: see accompanying Hari Sekhon LICENSE file
|
||||
#
|
||||
# If you're using my code you're welcome to connect with me on LinkedIn and optionally send me feedback to help steer this or other code I publish
|
||||
#
|
||||
# https://www.linkedin.com/in/HariSekhon
|
||||
#
|
||||
|
||||
set -euo pipefail
|
||||
[ -n "${DEBUG:-}" ] && set -x
|
||||
srcdir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
|
||||
cd "$srcdir"
|
||||
|
||||
vagrant up master1 worker1 worker2
|
@ -1,22 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
# vim:ts=4:sts=4:sw=4:et
|
||||
#
|
||||
# Author: Hari Sekhon
|
||||
# Date: 2020-08-29 09:19:22 +0100 (Sat, 29 Aug 2020)
|
||||
#
|
||||
# https://github.com/HariSekhon/DevOps-Bash-tools
|
||||
#
|
||||
# License: see accompanying Hari Sekhon LICENSE file
|
||||
#
|
||||
# If you're using my code you're welcome to connect with me on LinkedIn and optionally send me feedback to help steer this or other code I publish
|
||||
#
|
||||
# https://www.linkedin.com/in/HariSekhon
|
||||
#
|
||||
|
||||
set -euo pipefail
|
||||
[ -n "${DEBUG:-}" ] && set -x
|
||||
srcdir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
|
||||
cd "$srcdir"
|
||||
|
||||
vagrant up master1 master2 master3 worker1
|
@ -1,22 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
# vim:ts=4:sts=4:sw=4:et
|
||||
#
|
||||
# Author: Hari Sekhon
|
||||
# Date: 2020-08-29 09:19:22 +0100 (Sat, 29 Aug 2020)
|
||||
#
|
||||
# https://github.com/HariSekhon/DevOps-Bash-tools
|
||||
#
|
||||
# License: see accompanying Hari Sekhon LICENSE file
|
||||
#
|
||||
# If you're using my code you're welcome to connect with me on LinkedIn and optionally send me feedback to help steer this or other code I publish
|
||||
#
|
||||
# https://www.linkedin.com/in/HariSekhon
|
||||
#
|
||||
|
||||
set -euo pipefail
|
||||
[ -n "${DEBUG:-}" ] && set -x
|
||||
srcdir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
|
||||
cd "$srcdir"
|
||||
|
||||
vagrant up master1 master2 master3 worker1 worker2
|
@ -1,17 +0,0 @@
|
||||
#
|
||||
# Author: Hari Sekhon
|
||||
# Date: 2020-09-02 20:08:39 +0100 (Wed, 02 Sep 2020)
|
||||
#
|
||||
# vim:ts=4:sts=4:sw=4:noet
|
||||
#
|
||||
# https://github.com/HariSekhon/DevOps-Bash-tools
|
||||
#
|
||||
# If you're using my code you're welcome to connect with me on LinkedIn and optionally send me feedback
|
||||
#
|
||||
# https://www.linkedin.com/in/HariSekhon
|
||||
#
|
||||
|
||||
.PHONY: boot
|
||||
boot:
|
||||
./2nodes.sh
|
||||
exec vagrant ssh master1
|
@ -1,54 +0,0 @@
|
||||
Vagrant Kubernetes Lab
|
||||
======================
|
||||
|
||||
#### Quickstart
|
||||
|
||||
Boots a 2 node Kubernetes cluster (1 master + 1 worker) and drops you straight in to the master shell to run `kubectl` commands
|
||||
|
||||
`make`
|
||||
|
||||
#### Details
|
||||
|
||||
Builds a Kubernetes cluster using `kubeadm` with one of the following configurations:
|
||||
|
||||
- 2 nodes - 1 master, 1 worker
|
||||
- 3 nodes - 1 master, 2 workers
|
||||
- 4 nodes - 3 masters, 1 worker
|
||||
- 5 nodes - 3 masters, 2 workers
|
||||
|
||||
The hosts are intuitively named:
|
||||
|
||||
```
|
||||
master1
|
||||
master2
|
||||
master3
|
||||
worker1
|
||||
worker2
|
||||
```
|
||||
|
||||
You can boot whichever ones you want intuitively via
|
||||
|
||||
```
|
||||
vagrant up <selection of nodes>
|
||||
```
|
||||
|
||||
eg.
|
||||
|
||||
```
|
||||
vagrant up master1 worker1
|
||||
```
|
||||
|
||||
or use any one of the following script shortcuts to give you one of the above configurations:
|
||||
|
||||
```
|
||||
./2nodes.sh
|
||||
./3nodes.sh
|
||||
./4nodes.sh
|
||||
./5nodes.sh
|
||||
```
|
||||
|
||||
Tear down the lab in the usual vagrant way:
|
||||
|
||||
```
|
||||
vagrant destroy
|
||||
```
|
@ -1,208 +0,0 @@
|
||||
#
|
||||
# Author: Hari Sekhon
|
||||
# Date: 2020-08-14 13:16:04 +0100 (Fri, 14 Aug 2020)
|
||||
# (forked from private repo from 2013)
|
||||
# Original Date: 2013-03-18 16:38:04 +0000 (Mon, 18 Mar 2013)
|
||||
#
|
||||
# vim:ts=4:sts=4:sw=4:et:filetype=ruby
|
||||
#
|
||||
# https://github.com/HariSekhon/DevOps-Bash-tools
|
||||
#
|
||||
# License: see accompanying Hari Sekhon LICENSE file
|
||||
#
|
||||
# If you"re using my code you"re welcome to connect with me on LinkedIn and optionally send me feedback to help steer this or other code I publish
|
||||
#
|
||||
# https://www.linkedin.com/in/HariSekhon
|
||||
#
|
||||
|
||||
# https://www.vagrantup.com/docs/vagrantfile
|
||||
|
||||
Vagrant.configure("2") do |config|
|
||||
|
||||
# https://www.vagrantup.com/docs/boxes
|
||||
#
|
||||
# to get Hashicorp"s Ubuntu 18.04 base box:
|
||||
#
|
||||
# vagrant init hashicorp/bionic64
|
||||
#
|
||||
# or try one of the Bento boxes:
|
||||
#
|
||||
# https://app.vagrantup.com/bento
|
||||
#
|
||||
#config.vm.box = "hashicorp/bionic64"
|
||||
config.vm.box = "bento/ubuntu-18.04"
|
||||
|
||||
# root login doesn't work on hashicorp/bionic64 or bento/ubuntu-18.04 box with pw 'vagrant'
|
||||
#config.ssh.username = "root"
|
||||
#config.ssh.password = "vagrant"
|
||||
config.ssh.insert_key = true
|
||||
#config.ssh.private_key_path = "~/.ssh/id_rsa"
|
||||
# host_path guest_path
|
||||
config.vm.synced_folder "~/github", "/github"
|
||||
config.vm.synced_folder "../../", "/bash"
|
||||
config.ssh.forward_agent = false
|
||||
config.ssh.forward_x11 = false
|
||||
|
||||
config.vm.usable_port_range = 2250..2299
|
||||
#config.vm.boot_mode = "gui"
|
||||
|
||||
config.vm.provider "virtualbox" do |vb|
|
||||
vb.gui = false
|
||||
#vb.name = "default-vagrant-hostname" # overridden per VM
|
||||
vb.customize [
|
||||
"modifyvm", :id,
|
||||
"--name", "#{vb.name}",
|
||||
"--natdnsproxy1", "on",
|
||||
"--usb", "off",
|
||||
"--audio", "none"
|
||||
]
|
||||
# using the host's DNS is simple but less portable as it requires an extra step of adding the nodes to the host's /etc/hosts file, which is an easy step to miss, so just inject the hosts files in each VM instead
|
||||
#"--natdnshostresolver1", "on",
|
||||
|
||||
# evaluates too early and gets 'default-vagrant-hostname'
|
||||
#config.vm.hostname = "#{vb.name}"
|
||||
end
|
||||
|
||||
# generic provision for each VM
|
||||
config.vm.provision :shell, :path => "../provision.sh"
|
||||
|
||||
# Colocating Etcd cluster on masters to save RAM - uncomment these if you have RAM to burn and want them on separate hosts
|
||||
# ==================================
|
||||
# config.vm.define "etcd1" do |config|
|
||||
# config.vm.network "private_network", ip: "172.16.0.21"
|
||||
# config.vm.provider "virtualbox" do |vb|
|
||||
# # can't set vb.name at shared level, as it evaluates too early and gets 'default-vagrant-hostname'
|
||||
# vb.name = "etcd1"
|
||||
# vb.cpus = 1
|
||||
# vb.memory = 1024
|
||||
# vb.customize [
|
||||
# "modifyvm", :id, "--name", "#{vb.name}"
|
||||
# ]
|
||||
# # sets the guest OS hostname and /etc/hosts (edited by provision.sh as we want external IP and not 127.0.1.1)
|
||||
# config.vm.hostname = "#{vb.name}"
|
||||
# end
|
||||
# end
|
||||
#
|
||||
# config.vm.define "etcd2" do |config|
|
||||
# config.vm.network "private_network", ip: "172.16.0.22"
|
||||
# config.vm.provider "virtualbox" do |vb|
|
||||
# # can't set vb.name at shared level, as it evaluates too early and gets 'default-vagrant-hostname'
|
||||
# vb.name = "etcd2"
|
||||
# vb.cpus = 1
|
||||
# vb.memory = 1024
|
||||
# vb.customize [
|
||||
# "modifyvm", :id, "--name", "#{vb.name}"
|
||||
# ]
|
||||
# # sets the guest OS hostname and /etc/hosts (edited by provision.sh as we want external IP and not 127.0.1.1)
|
||||
# config.vm.hostname = "#{vb.name}"
|
||||
# end
|
||||
# end
|
||||
#
|
||||
# config.vm.define "etcd3" do |config|
|
||||
# config.vm.network "private_network", ip: "172.16.0.23"
|
||||
# config.vm.provider "virtualbox" do |vb|
|
||||
# # can't set vb.name at shared level, as it evaluates too early and gets 'default-vagrant-hostname'
|
||||
# vb.name = "etcd3"
|
||||
# vb.cpus = 1
|
||||
# vb.memory = 1024
|
||||
# vb.customize [
|
||||
# "modifyvm", :id, "--name", "#{vb.name}"
|
||||
# ]
|
||||
# # sets the guest OS hostname and /etc/hosts (edited by provision.sh as we want external IP and not 127.0.1.1)
|
||||
# config.vm.hostname = "#{vb.name}"
|
||||
# end
|
||||
# end
|
||||
|
||||
# ==================================
|
||||
config.vm.define "master1" do |config|
|
||||
config.vm.network "private_network", ip: "172.16.0.11"
|
||||
config.vm.provider "virtualbox" do |vb|
|
||||
# can't set vb.name at shared level, as it evaluates too early and gets 'default-vagrant-hostname'
|
||||
vb.name = "master1"
|
||||
vb.cpus = 2
|
||||
vb.memory = 4096
|
||||
vb.customize [
|
||||
"modifyvm", :id, "--name", "#{vb.name}"
|
||||
#"--cpus", 3,
|
||||
#"--memory", 7168
|
||||
]
|
||||
# sets the guest OS hostname and /etc/hosts (edited by provision.sh as we want external IP and not 127.0.1.1)
|
||||
config.vm.hostname = "#{vb.name}"
|
||||
end
|
||||
config.vm.provision :shell, :path => "provision-kube-master.sh"
|
||||
end
|
||||
|
||||
config.vm.define "master2" do |config|
|
||||
config.vm.network "private_network", ip: "172.16.0.12"
|
||||
config.vm.provider "virtualbox" do |vb|
|
||||
# can't set vb.name at shared level, as it evaluates too early and gets 'default-vagrant-hostname'
|
||||
vb.name = "master2"
|
||||
vb.cpus = 2
|
||||
vb.memory = 4096
|
||||
vb.customize [
|
||||
"modifyvm", :id, "--name", "#{vb.name}"
|
||||
]
|
||||
# sets the guest OS hostname and /etc/hosts (edited by provision.sh as we want external IP and not 127.0.1.1)
|
||||
config.vm.hostname = "#{vb.name}"
|
||||
end
|
||||
#config.vm.provision :shell, :path => "provision-kube-master.sh"
|
||||
end
|
||||
|
||||
config.vm.define "master3" do |config|
|
||||
config.vm.network "private_network", ip: "172.16.0.13"
|
||||
config.vm.provider "virtualbox" do |vb|
|
||||
# can't set vb.name at shared level, as it evaluates too early and gets 'default-vagrant-hostname'
|
||||
vb.name = "master3"
|
||||
vb.cpus = 1
|
||||
# Only Etcd on this one so less RAM needed
|
||||
vb.memory = 1024
|
||||
vb.customize [
|
||||
"modifyvm", :id, "--name", "#{vb.name}"
|
||||
]
|
||||
# sets the guest OS hostname and /etc/hosts (edited by provision.sh as we want external IP and not 127.0.1.1)
|
||||
config.vm.hostname = "#{vb.name}"
|
||||
end
|
||||
end
|
||||
|
||||
# ==================================
|
||||
config.vm.define "worker1" do |config|
|
||||
config.vm.network "private_network", ip: "172.16.0.14"
|
||||
config.vm.provider "virtualbox" do |vb|
|
||||
vb.name = "worker1"
|
||||
vb.memory = 2048
|
||||
vb.cpus = 1
|
||||
vb.customize [
|
||||
"modifyvm", :id, "--name", "#{vb.name}"
|
||||
]
|
||||
config.vm.hostname = "#{vb.name}"
|
||||
end
|
||||
config.vm.provision :shell, :path => "provision-kube-worker.sh"
|
||||
end
|
||||
# Enable if you have lots of ram and want more workers
|
||||
config.vm.define "worker2" do |config|
|
||||
config.vm.network "private_network", ip: "172.16.0.15"
|
||||
config.vm.provider "virtualbox" do |vb|
|
||||
vb.name = "worker2"
|
||||
vb.memory = 2048
|
||||
vb.cpus = 1
|
||||
vb.customize [
|
||||
"modifyvm", :id, "--name", "#{vb.name}"
|
||||
]
|
||||
config.vm.hostname = "#{vb.name}"
|
||||
end
|
||||
config.vm.provision :shell, :path => "provision-kube-worker.sh"
|
||||
end
|
||||
# config.vm.define "worker3" do |config|
|
||||
# config.vm.network "private_network", ip: "172.16.0.16"
|
||||
# config.vm.provider "virtualbox" do |vb|
|
||||
# vb.name = "worker3"
|
||||
# vb.memory = 2048
|
||||
# vb.cpus = 1
|
||||
# vb.customize [
|
||||
# "modifyvm", :id, "--name", "#{vb.name}"
|
||||
# ]
|
||||
# config.vm.hostname = "#{vb.name}"
|
||||
# end
|
||||
# config.vm.provision :shell, :path => "provision-kube-worker.sh"
|
||||
# end
|
||||
end
|
File diff suppressed because it is too large
Load Diff
@ -1,21 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
# vim:ts=2:sts=2:sw=2:et
|
||||
#
|
||||
# Author: Hari Sekhon
|
||||
# Date: 2020-08-14 13:16:04 +0100 (Fri, 14 Aug 2020)
|
||||
#
|
||||
# https://github.com/HariSekhon/DevOps-Bash-tools
|
||||
#
|
||||
# License: see accompanying Hari Sekhon LICENSE file
|
||||
#
|
||||
# If you're using my code you're welcome to connect with me on LinkedIn and optionally send me feedback to help steer this or other code I publish
|
||||
#
|
||||
# https://www.linkedin.com/in/HariSekhon
|
||||
#
|
||||
|
||||
apiVersion: kubeadm.k8s.io/v1beta2
|
||||
kind: ClusterConfiguration
|
||||
kubernetesVersion: 1.18.1 # Use the word stable for newest version
|
||||
controlPlaneEndpoint: "master1:6443" # Use the node alias not the IP so cert matches from LB
|
||||
networking:
|
||||
podSubnet: 192.168.0.0/16 # Match the IP range from the Calico config file
|
@ -1,59 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
# vim:ts=4:sts=4:sw=4:et
|
||||
#
|
||||
# Author: Hari Sekhon
|
||||
# Date: 2020-08-14 13:16:04 +0100 (Fri, 14 Aug 2020)
|
||||
#
|
||||
# https://github.com/HariSekhon/DevOps-Bash-tools
|
||||
#
|
||||
# License: see accompanying Hari Sekhon LICENSE file
|
||||
#
|
||||
# If you're using my code you're welcome to connect with me on LinkedIn and optionally send me feedback to help steer this or other code I publish
|
||||
#
|
||||
# https://www.linkedin.com/in/HariSekhon
|
||||
#
|
||||
|
||||
set -euo pipefail
|
||||
[ -n "${DEBUG:-}" ] && set -x
|
||||
|
||||
bash_tools="/bash"
|
||||
|
||||
# shellcheck disable=SC1090
|
||||
source "$bash_tools/lib/utils.sh"
|
||||
|
||||
section "Running Vagrant Shell Provisioner Script - Kubernetes Common"
|
||||
|
||||
pushd /vagrant
|
||||
|
||||
"$bash_tools/install_packages_if_absent.sh" docker.io
|
||||
|
||||
systemctl enable docker.service
|
||||
systemctl start docker.service
|
||||
|
||||
echo "deb http://apt.kubernetes.io/ kubernetes-xenial main" | "$bash_tools/bin/grep_or_append.sh" /etc/apt/sources.list.d/kubernetes.list
|
||||
|
||||
curl -sS https://packages.cloud.google.com/apt/doc/apt-key.gpg | apt-key add -
|
||||
|
||||
if ! dpkg -s kubeadm kubelet kubectl &>/dev/null; then
|
||||
/bash/install_packages_if_absent.sh \
|
||||
kubeadm=1.18.1-00 \
|
||||
kubelet=1.18.1-00 \
|
||||
kubectl=1.18.1-00
|
||||
|
||||
apt-mark hold \
|
||||
kubelet \
|
||||
kubeadm \
|
||||
kubectl
|
||||
fi
|
||||
|
||||
#source <(kubectl completion bash)
|
||||
timestamp "adding bash completion for kubectl:"
|
||||
echo "source <(kubectl completion bash)" | "$bash_tools/bin/grep_or_append.sh" ~/.bashrc
|
||||
echo >&2
|
||||
|
||||
if ! [ -d /templates ] &&
|
||||
[ -d /github/perl-tools/templates ]; then
|
||||
ln -sv -- /github/perl-tools/templates /
|
||||
fi
|
||||
|
||||
popd
|
@ -1,127 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
# vim:ts=4:sts=4:sw=4:et
|
||||
#
|
||||
# Author: Hari Sekhon
|
||||
# Date: 2020-08-14 13:16:04 +0100 (Fri, 14 Aug 2020)
|
||||
#
|
||||
# https://github.com/HariSekhon/DevOps-Bash-tools
|
||||
#
|
||||
# License: see accompanying Hari Sekhon LICENSE file
|
||||
#
|
||||
# If you're using my code you're welcome to connect with me on LinkedIn and optionally send me feedback to help steer this or other code I publish
|
||||
#
|
||||
# https://www.linkedin.com/in/HariSekhon
|
||||
#
|
||||
|
||||
set -euo pipefail
|
||||
[ -n "${DEBUG:-}" ] && set -x
|
||||
|
||||
# has to be before brace to set up logging path and logfile name
|
||||
mkdir -pv /vagrant/logs
|
||||
name="${0##*/}"
|
||||
log="/vagrant/logs/${name%.sh}.log"
|
||||
|
||||
{
|
||||
|
||||
bash_tools="/bash"
|
||||
|
||||
# shellcheck source=provision-kube-common.sh
|
||||
. "/vagrant/provision-kube-common.sh"
|
||||
|
||||
section "Running Vagrant Shell Provisioner Script - Kubernetes Master"
|
||||
|
||||
kubeadm_join="/vagrant/kubeadm_join.sh"
|
||||
|
||||
pushd /vagrant
|
||||
|
||||
flannel_yml=kube-flannel.yml
|
||||
calico_yaml=calico.yaml
|
||||
weavenet_yaml=weavenet.yaml
|
||||
|
||||
# XXX: one-line CNI deployment change right here :-)
|
||||
selected_cni="$calico_yaml"
|
||||
|
||||
# should already be in the vagrant dir
|
||||
if [ "$selected_cni" = "$flannel_yml" ]; then
|
||||
if ! [ -s "$flannel_yml" ]; then
|
||||
timestamp "Fetching $flannel_yml:"
|
||||
wget -O "$flannel_yml" https://raw.githubusercontent.com/coreos/flannel/master/Documentation/kube-flannel.yml
|
||||
fi
|
||||
elif [ "$selected_cni" = "$calico_yaml" ]; then
|
||||
if ! [ -s "$calico_yaml" ]; then
|
||||
timestamp "Fetching $calico_yaml:"
|
||||
wget -O "$calico_yaml" https://docs.projectcalico.org/manifests/calico.yaml
|
||||
fi
|
||||
elif [ "$selected_cni" = "$weavenet_yaml" ]; then
|
||||
if ! [ -s "$weavenet_yaml" ]; then
|
||||
timestamp "Fetching $weavenet_yaml:"
|
||||
#wget -O "weave.sh https://git.io/weave
|
||||
wget -O "$weavenet_yaml" "https://cloud.weave.works/k8s/net?k8s-version=$(kubectl version | base64 | tr -d '\n')"
|
||||
fi
|
||||
else
|
||||
echo "Selected CNI '$selected_cni' doesn't match one of: $flannel_yml, $calico_yaml, $weavenet_yaml"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo >&2
|
||||
|
||||
if ! netstat -lnt | grep -q :10248; then
|
||||
timestamp "Bootstrapping kubernetes master:"
|
||||
echo >&2
|
||||
# remove stale old generated join script so worker(s) awaits new one
|
||||
rm -fv -- "$kubeadm_join"
|
||||
echo >&2
|
||||
# kubeadm-config.yml is in vagrant dir mounted at /vagrant
|
||||
kubeadm init --node-name "$(hostname -f)" --config=kubeadm-config.yaml --upload-certs | tee /vagrant/logs/kubeadm-init.out # save output for review
|
||||
echo >&2
|
||||
fi
|
||||
|
||||
kubeadm token list
|
||||
|
||||
echo >&2
|
||||
|
||||
timestamp "Configuring kubectl:"
|
||||
mkdir -pv ~/.kube /home/vagrant/.kube /vagrant/.kube
|
||||
for kube_config in ~/.kube/config /home/vagrant/.kube/config; do
|
||||
if ! [ -f "$kube_config" ]; then
|
||||
cp -vf -- /etc/kubernetes/admin.conf "$kube_config"
|
||||
fi
|
||||
done
|
||||
chown -v "$(id -u):$(id -g)" ~/.kube/config
|
||||
chown -v vagrant:vagrant /home/vagrant/.kube/config
|
||||
cp -vf -- ~/.kube/config /vagrant/.kube/config
|
||||
echo >&2
|
||||
|
||||
timestamp "Applying CNI $selected_cni:"
|
||||
kubectl apply -f "$selected_cni"
|
||||
|
||||
echo >&2
|
||||
|
||||
timestamp "Kubernetes Node Taints:"
|
||||
kubectl describe nodes | grep -i -e '^Name:' -e '^Taints:'
|
||||
|
||||
echo >&2
|
||||
|
||||
timestamp "untainting master node for pod scheduling"
|
||||
kubectl taint nodes --all node-role.kubernetes.io/master- || :
|
||||
|
||||
echo >&2
|
||||
|
||||
kubectl describe nodes | grep -i -e '^Name:' -e '^Taints:'
|
||||
|
||||
echo >&2
|
||||
|
||||
kubectl taint nodes --all node.kubernetes.io/not-ready- || :
|
||||
|
||||
echo >&2
|
||||
|
||||
timestamp "Kubernetes Nodes:"
|
||||
kubectl get nodes
|
||||
|
||||
echo >&2
|
||||
|
||||
timestamp "(re)generating $kubeadm_join for workers to use"
|
||||
"$bash_tools/kubeadm_join_cmd.sh" > "$kubeadm_join"
|
||||
chmod +x "$kubeadm_join"
|
||||
|
||||
} 2>&1 | tee -a "$log"
|
@ -1,78 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
# vim:ts=4:sts=4:sw=4:et
|
||||
#
|
||||
# Author: Hari Sekhon
|
||||
# Date: 2020-08-14 13:16:04 +0100 (Fri, 14 Aug 2020)
|
||||
#
|
||||
# https://github.com/HariSekhon/DevOps-Bash-tools
|
||||
#
|
||||
# License: see accompanying Hari Sekhon LICENSE file
|
||||
#
|
||||
# If you're using my code you're welcome to connect with me on LinkedIn and optionally send me feedback to help steer this or other code I publish
|
||||
#
|
||||
# https://www.linkedin.com/in/HariSekhon
|
||||
#
|
||||
|
||||
set -euo pipefail
|
||||
[ -n "${DEBUG:-}" ] && set -x
|
||||
|
||||
# has to be before brace to set up logging path and logfile name
|
||||
mkdir -pv /vagrant/logs
|
||||
name="${0##*/}"
|
||||
log="/vagrant/logs/${name%.sh}.log"
|
||||
|
||||
{
|
||||
|
||||
# shellcheck source=provision-kube-common.sh
|
||||
. "/vagrant/provision-kube-common.sh"
|
||||
|
||||
section "Running Vagrant Shell Provisioner Script - Kubernetes Worker"
|
||||
|
||||
echo >&2
|
||||
|
||||
pushd /vagrant
|
||||
|
||||
kubeadm_join="/vagrant/kubeadm_join.sh"
|
||||
|
||||
if ! netstat -lnt | grep -q :10248; then
|
||||
timestamp "Bootstrapping kubernetes worker:"
|
||||
echo >&2
|
||||
|
||||
# happens after master anyway
|
||||
#timestamp "waiting for 15 secs to give master time to provision"
|
||||
#sleep 15
|
||||
|
||||
timestamp "Waiting for master to bootstrap and generate kubectl join command at $kubeadm_join"
|
||||
SECONDS=0
|
||||
while ! [ -f "$kubeadm_join" ]; do
|
||||
if [ $SECONDS -gt 600 ]; then
|
||||
timestamp "ERROR: max wait time for $kubeadm_join to appear exceeded, aborting worker node join. Check provisioner run on master has generated $kubeadm_join or re-run provisioner"
|
||||
exit 1
|
||||
fi
|
||||
sleep 1
|
||||
done
|
||||
echo >&2
|
||||
|
||||
# doesn't error out if already joined
|
||||
timestamp "Running $kubeadm_join"
|
||||
chmod +x "$kubeadm_join"
|
||||
"$kubeadm_join"
|
||||
|
||||
echo >&2
|
||||
fi
|
||||
|
||||
timestamp "Configuring kubectl:"
|
||||
mkdir -pv ~/.kube /home/vagrant/.kube
|
||||
for kube_config in ~/.kube/config /home/vagrant/.kube/config; do
|
||||
if ! [ -f "$kube_config" ]; then
|
||||
cp -vf -- /vagrant/.kube/config "$kube_config"
|
||||
fi
|
||||
done
|
||||
chown -v "$(id -u):$(id -g)" ~/.kube/config
|
||||
chown -v vagrant:vagrant /home/vagrant/.kube/config
|
||||
echo >&2
|
||||
|
||||
timestamp "Kubernetes Nodes:"
|
||||
kubectl get nodes
|
||||
|
||||
} 2>&1 | tee -a "$log"
|
Loading…
Reference in New Issue