Initial version of spring demo1

This commit is contained in:
Tomasz Półgrabia 2024-07-02 00:38:58 +02:00
parent 4213a9edc6
commit 401b03a247
22 changed files with 645 additions and 67 deletions

View file

@ -1,63 +1,70 @@
#!/bin/sh
apt-get update
apt-get install -y vim
cat << EOF | tee /etc/modules-load.d/k8s.conf
overlay
br_netfilter
EOF
modprobe overlay
modprobe br_netfilter
cat <<EOF | sudo tee /etc/sysctl.d/k8s.conf
net.bridge.bridge-nf-call-iptables = 1
net.bridge.bridge-nf-call-ip6tables = 1
net.ipv4.ip_forward = 1
EOF
sysctl --system
cd /tmp
test -f containerd-1.7.11-linux-amd64.tar.gz || wget https://github.com/containerd/containerd/releases/download/v1.7.11/containerd-1.7.11-linux-amd64.tar.gz
tar Cxzvf /usr/local containerd-1.7.11-linux-amd64.tar.gz
mkdir -p /etc/containerd
containerd config default > config.toml
cp config.toml /etc/containerd
test -f containerd.service || wget https://raw.githubusercontent.com/containerd/containerd/main/containerd.service
cp containerd.service /etc/systemd/system/
systemctl daemon-reload
systemctl enable --now containerd
test -f runc.amd64 || wget https://github.com/opencontainers/runc/releases/download/v1.1.10/runc.amd64
install -m 755 runc.amd64 /usr/local/sbin/runc
test -f cni-plugins-linux-amd64-v1.4.0.tgz || wget https://github.com/containernetworking/plugins/releases/download/v1.4.0/cni-plugins-linux-amd64-v1.4.0.tgz
mkdir -p /opt/cni/bin
tar Cxzvf /opt/cni/bin cni-plugins-linux-amd64-v1.4.0.tgz
sed -i.bak "s/SystemdCgroup.*$/SystemdCgroup = true/g" /etc/containerd/config.toml
systemctl restart containerd
apt-get update
apt-get install -y apt-transport-https ca-certificates curl gpg
mkdir -p /etc/apt/keyrings
test -f /etc/apt/keyrings/kubernetes-apt-keyring.gpg || ( curl -fsSL https://pkgs.k8s.io/core:/stable:/v1.28/deb/Release.key | gpg --dearmor -o /etc/apt/keyrings/kubernetes-apt-keyring.gpg )
echo 'deb [signed-by=/etc/apt/keyrings/kubernetes-apt-keyring.gpg] https://pkgs.k8s.io/core:/stable:/v1.28/deb/ /' | sudo tee /etc/apt/sources.list.d/kubernetes.list
apt-get update
apt-get install -y kubelet=1.28.4-1.1 kubeadm=1.28.4-1.1 kubectl=1.28.4-1.1
swapoff -a
sed -i.bak -E "s/^.*swap.*//g" /etc/fstab
#!/bin/sh
apt-get update
apt-get install -y vim
cat << EOF | tee /etc/modules-load.d/k8s.conf
overlay
br_netfilter
EOF
modprobe overlay
modprobe br_netfilter
cat <<EOF | sudo tee /etc/sysctl.d/k8s.conf
net.bridge.bridge-nf-call-iptables = 1
net.bridge.bridge-nf-call-ip6tables = 1
net.ipv4.ip_forward = 1
EOF
sysctl --system
cd /tmp
test -f containerd-1.7.11-linux-amd64.tar.gz || wget https://github.com/containerd/containerd/releases/download/v1.7.11/containerd-1.7.11-linux-amd64.tar.gz
tar Cxzvf /usr/local containerd-1.7.11-linux-amd64.tar.gz
mkdir -p /etc/containerd
containerd config default > config.toml
cp config.toml /etc/containerd
test -f containerd.service || wget https://raw.githubusercontent.com/containerd/containerd/main/containerd.service
cp containerd.service /etc/systemd/system/
systemctl daemon-reload
systemctl enable --now containerd
test -f runc.amd64 || wget https://github.com/opencontainers/runc/releases/download/v1.1.10/runc.amd64
install -m 755 runc.amd64 /usr/local/sbin/runc
test -f cni-plugins-linux-amd64-v1.4.0.tgz || wget https://github.com/containernetworking/plugins/releases/download/v1.4.0/cni-plugins-linux-amd64-v1.4.0.tgz
mkdir -p /opt/cni/bin
tar Cxzvf /opt/cni/bin cni-plugins-linux-amd64-v1.4.0.tgz
sed -i.bak "s/SystemdCgroup.*$/SystemdCgroup = true/g" /etc/containerd/config.toml
systemctl restart containerd
apt-get update
apt-get install -y apt-transport-https ca-certificates curl gpg
mkdir -p /etc/apt/keyrings
test -f /etc/apt/keyrings/kubernetes-apt-keyring.gpg || ( curl -fsSL https://pkgs.k8s.io/core:/stable:/v1.28/deb/Release.key | gpg --dearmor -o /etc/apt/keyrings/kubernetes-apt-keyring.gpg )
echo 'deb [signed-by=/etc/apt/keyrings/kubernetes-apt-keyring.gpg] https://pkgs.k8s.io/core:/stable:/v1.28/deb/ /' | sudo tee /etc/apt/sources.list.d/kubernetes.list
apt-get update
apt-get install -y kubelet=1.28.4-1.1 kubeadm=1.28.4-1.1 kubectl=1.28.4-1.1
swapoff -a
sed -i.bak -E "s/^.*swap.*//g" /etc/fstab
apt-get install -y libnss-mdns
sed -i.bak 's/#DNS=.*$/DNS=8.8.8.8 8.8.4.4/g' /etc/systemd/resolved.conf
systemctl enable systemd-resolved
systemctl start systemd-resolved
mv /etc/resolv.conf /etc/resolv.conf.old
ln -s /run/systemd/resolve/stub-resolv.conf /etc/resolv.conf

View file

@ -16,7 +16,7 @@ Vagrant.configure("2") do |config|
config.vm.hostname = "master.local"
config.vm.network :private_network, ip: "10.1.0.2"
config.vm.network :public_network, ip: "10.1.0.2"
# Disable automatic box update checking. If you disable this, then
# boxes will only be checked for updates when the user runs
@ -78,7 +78,7 @@ end
config.vm.provision "shell", inline: <<-SHELL
apt-get update
grep "master.local" /etc/hosts || cat /vagrant/hosts.txt >> /etc/hosts
test -f /etc/kubernetes/manifests/kube-scheduler.yaml || \\
test -f init.log || \\
( kubeadm init --control-plane-endpoint master.local:6443 --pod-network-cidr 10.2.0.0/22 | tee init.log )
export KUBECONFIG=/etc/kubernetes/admin.conf
test -f tigera-operator.yaml || ( wget https://raw.githubusercontent.com/projectcalico/calico/v3.27.0/manifests/tigera-operator.yaml \\
@ -86,6 +86,8 @@ end
test -f custom-resources.yaml || wget https://raw.githubusercontent.com/projectcalico/calico/v3.27.0/manifests/custom-resources.yaml
sed -i.bak -E "s#cidr.*#cidr: 10\.2\.0\.0/22#g" custom-resources.yaml
kubectl apply -f custom-resources.yaml
grep "\-\-token" sample.txt | awk '{ print ($5) }' | tail -n 1 >> /vagrant/token.secret
grep "discovery:" init.log | awk '{print($2)}' | tail -n 1 >> /vagrant/discovery.secret
cat init.log
SHELL
end

View file

@ -16,7 +16,7 @@ Vagrant.configure("2") do |config|
config.vm.hostname = "worker.local"
config.vm.network :private_network, ip: "10.1.0.3"
config.vm.network :public_network, ip: "10.1.0.3"
# Disable automatic box update checking. If you disable this, then
# boxes will only be checked for updates when the user runs
@ -78,6 +78,6 @@ end
config.vm.provision "shell", inline: <<-SHELL
apt-get update
grep "master.local" /etc/hosts || cat /vagrant/hosts.txt >> /etc/hosts
kubeadm join master.local:6443 --token TBD --discovery-token-ca-cert-hash TBD
kubeadm join master.local:6443 --token $(cat /vagrant/token.secret) --discovery-token-ca-cert-hash $(cat /vagrant/discovery.secret)
SHELL
end