Skip to content

Commit

Permalink
update some vagrant files
Browse files Browse the repository at this point in the history
  • Loading branch information
mmmarceleza committed Dec 19, 2023
1 parent 4c833bc commit 895332b
Show file tree
Hide file tree
Showing 6 changed files with 47 additions and 32 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
# devops

This is my personal repository to archive all my cheat sheets.
2 changes: 1 addition & 1 deletion kubernetes/deployment/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@ spec:
spec:
containers:
- image: nginx:alpine
name: nginx
name: nginx
8 changes: 4 additions & 4 deletions vagrant/kubernetes/Vagrantfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@

ENV['VAGRANT_NO_PARALLEL'] = 'yes'

#VAGRANT_BOX = "generic/ubuntu2204"
VAGRANT_BOX = "generic/rhel8"
#VAGRANT_BOX_VERSION = "4.2.8"
VAGRANT_BOX_VERSION = "4.2.16"
VAGRANT_BOX = "generic/ubuntu2204"
#VAGRANT_BOX = "generic/rhel8"
VAGRANT_BOX_VERSION = "4.2.8"
#VAGRANT_BOX_VERSION = "4.2.16"
CPUS_MASTER_NODE = 2
CPUS_WORKER_NODE = 1
MEMORY_MASTER_NODE = 2048
Expand Down
53 changes: 33 additions & 20 deletions vagrant/kubernetes/bootstrap.sh
Original file line number Diff line number Diff line change
Expand Up @@ -29,31 +29,44 @@ net.ipv4.ip_forward = 1
EOF
sysctl --system >/dev/null 2>&1

echo "[TASK 5] Install CRIO runtime"
VERSION=1.24
OS=xUbuntu_22.04
echo "[TASK 5] Install Containerd runtime"
sed -i 's/https:\/\/mirrors.edge.kernel.org\/ubuntu\//http:\/\/mirror.ufscar.br\/ubuntu\//' /etc/apt/sources.list
apt update -qq -y >/dev/null 2>&1
apt install containerd -qq -y >/dev/null 2>&1
mkdir /etc/containerd
containerd config default > /etc/containerd/config.toml
sed -i 's/SystemdCgroup = false/SystemdCgroup = true/g' /etc/containerd/config.toml
systemctl restart containerd

echo "deb [signed-by=/usr/share/keyrings/libcontainers-archive-keyring.gpg] https://download.opensuse.org/repositories/devel:/kubic:/libcontainers:/stable/$OS/ /" > /etc/apt/sources.list.d/devel:kubic:libcontainers:stable.list
echo "deb [signed-by=/usr/share/keyrings/libcontainers-crio-archive-keyring.gpg] https://download.opensuse.org/repositories/devel:/kubic:/libcontainers:/stable:/cri-o:/$VERSION/$OS/ /" > /etc/apt/sources.list.d/devel:kubic:libcontainers:stable:cri-o:$VERSION.list

mkdir -p /usr/share/keyrings
curl -L https://download.opensuse.org/repositories/devel:/kubic:/libcontainers:/stable/$OS/Release.key | gpg --dearmor -o /usr/share/keyrings/libcontainers-archive-keyring.gpg
curl -L https://download.opensuse.org/repositories/devel:/kubic:/libcontainers:/stable:/cri-o:/$VERSION/$OS/Release.key | gpg --dearmor -o /usr/share/keyrings/libcontainers-crio-archive-keyring.gpg

apt update -qq >/dev/null 2>&1
apt install -qq -y cri-o cri-o-runc >/dev/null 2>&1
systemctl restart crio
systemctl enable crio >/dev/null 2>&1
#echo "[TASK 5] Install CRIO runtime"
#VERSION=1.24
#OS=xUbuntu_22.04
#
#echo "deb [signed-by=/usr/share/keyrings/libcontainers-archive-keyring.gpg] https://download.opensuse.org/repositories/devel:/kubic:/libcontainers:/stable/$OS/ /" > /etc/apt/sources.list.d/devel:kubic:libcontainers:stable.list
#echo "deb [signed-by=/usr/share/keyrings/libcontainers-crio-archive-keyring.gpg] https://download.opensuse.org/repositories/devel:/kubic:/libcontainers:/stable:/cri-o:/$VERSION/$OS/ /" > /etc/apt/sources.list.d/devel:kubic:libcontainers:stable:cri-o:$VERSION.list
#
#mkdir -p /usr/share/keyrings
#curl -L https://download.opensuse.org/repositories/devel:/kubic:/libcontainers:/stable/$OS/Release.key | gpg --dearmor -o /usr/share/keyrings/libcontainers-archive-keyring.gpg
#curl -L https://download.opensuse.org/repositories/devel:/kubic:/libcontainers:/stable:/cri-o:/$VERSION/$OS/Release.key | gpg --dearmor -o /usr/share/keyrings/libcontainers-crio-archive-keyring.gpg
#
#apt update -qq >/dev/null 2>&1
#apt install -qq -y cri-o cri-o-runc >/dev/null 2>&1
#systemctl restart crio
#systemctl enable crio >/dev/null 2>&1

echo "[TASK 6] Add apt repo for kubernetes"
apt install -qq -y apt-transport-https ca-certificates curl >/dev/null 2>&1
curl -fsSLo /usr/share/keyrings/kubernetes-archive-keyring.gpg https://packages.cloud.google.com/apt/doc/apt-key.gpg
echo "deb [signed-by=/usr/share/keyrings/kubernetes-archive-keyring.gpg] https://apt.kubernetes.io/ kubernetes-xenial main" | sudo tee /etc/apt/sources.list.d/kubernetes.list
apt update -qq >/dev/null 2>&1
curl -fsSL https://pkgs.k8s.io/core:/stable:/v1.28/deb/Release.key | sudo 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/ /' > /etc/apt/sources.list.d/kubernetes.list
#apt install -qq -y apt-transport-https ca-certificates curl >/dev/null 2>&1
#curl -fsSLo /usr/share/keyrings/kubernetes-archive-keyring.gpg https://packages.cloud.google.com/apt/doc/apt-key.gpg
#echo "deb [signed-by=/usr/share/keyrings/kubernetes-archive-keyring.gpg] https://apt.kubernetes.io/ kubernetes-xenial main" | sudo tee /etc/apt/sources.list.d/kubernetes.list
#apt update -qq >/dev/null 2>&1

echo "[TASK 7] Install Kubernetes components (kubeadm, kubelet and kubectl)"
apt install -qq -y kubeadm=1.24.3-00 kubelet=1.24.3-00 kubectl=1.24.3-00 >/dev/null 2>&1
apt-mark hold kubelet kubeadm kubectl
apt update -qq -y >/dev/null 2>&1
apt install -qq -y kubeadm kubelet kubectl >/dev/null 2>&1
apt-mark hold -qq kubelet kubeadm kubectl

echo "[TASK 8] Enable ssh password authentication"
sed -i 's/^PasswordAuthentication .*/PasswordAuthentication yes/' /etc/ssh/sshd_config
Expand All @@ -62,7 +75,7 @@ systemctl reload sshd

echo "[TASK 9] Set root password"
echo -e "kubeadmin\nkubeadmin" | passwd root >/dev/null 2>&1
echo "export TERM=xterm" >> /etc/bash.bashrc
#echo "export TERM=xterm" >> /etc/bash.bashrc

echo "[TASK 10] Update /etc/hosts file"
cat >>/etc/hosts<<EOF
Expand Down
10 changes: 5 additions & 5 deletions vagrant/kubernetes/bootstrap_kmaster.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ echo "[TASK 1] Pull required containers"
kubeadm config images pull >/dev/null 2>&1

echo "[TASK 2] Initialize Kubernetes Cluster"
kubeadm init --apiserver-advertise-address=10.10.10.2 --pod-network-cidr=192.168.0.0/16 >> /root/kubeinit.log 2>/dev/null
kubeadm init --apiserver-advertise-address=172.16.16.100 --pod-network-cidr=192.168.0.0/16 >> /root/kubeinit.log 2>/dev/null

echo "[TASK 3] Deploy Calico network"
kubectl --kubeconfig=/etc/kubernetes/admin.conf create -f https://docs.projectcalico.org/v3.18/manifests/calico.yaml >/dev/null 2>&1
kubectl --kubeconfig=/etc/kubernetes/admin.conf create -f https://raw.githubusercontent.com/projectcalico/calico/v3.26.3/manifests/calico.yaml >/dev/null 2>&1

echo "[TASK 4] Generate and save cluster join command to /joincluster.sh"
kubeadm token create --print-join-command > /joincluster.sh 2>/dev/null
Expand All @@ -19,7 +19,7 @@ sudo chown $(id -u):$(id -g) $HOME/.kube/config

echo "[TASK 6] Enable aliases to use with kubectl"
curl -fsSLo /root/.bash_aliases https://raw.githubusercontent.com/ahmetb/kubectl-aliases/master/.kubectl_aliases
sed -ri 's/(kubectl.*) --watch/watch \1/g' .bash_aliases
sed -ri 's/(kubectl.*) --watch/watch \1/g' /root/.bash_aliases

echo "[TASK 6] Install kubectx and kubens with command line fuzzy find"
apt install -qq -y git fzf >/dev/null 2>&1
Expand Down Expand Up @@ -47,7 +47,7 @@ echo "[TASK 7] Install krew"
curl -fsSLO "https://github.com/kubernetes-sigs/krew/releases/latest/download/${KREW}.tar.gz" &&
tar zxvf "${KREW}.tar.gz" &&
./"${KREW}" install krew
)
) >/dev/null 2>&1
cat >>/root/.bashrc<<EOF
#kubectl krew
Expand All @@ -66,7 +66,7 @@ cat >>/root/.bashrc<<EOF
EOF

echo "[TASK 9] install Helm"
curl https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-3 | bash >/dev/null 2>&1
curl -s https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-3 | bash >/dev/null 2>&1

echo "[TASK 10] Install kustomize"
curl -s "https://raw.githubusercontent.com/kubernetes-sigs/kustomize/master/hack/install_kustomize.sh" | bash >/dev/null 2>&1
Expand Down
5 changes: 3 additions & 2 deletions vagrant/singlevm/Vagrantfile
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,9 @@
# VARIABLES
#--------------------------------------------------------------

VAGRANT_BOX = "generic/ubuntu2204"
VAGRANT_BOX_VERSION = "4.2.8"
#VAGRANT_BOX = "generic/ubuntu2204"
VAGRANT_BOX = "generic/arch"
VAGRANT_BOX_VERSION = "4.3.6"
CPUS = 2
MEMORY = 2048
HOSTNAME = "vagrant.local"
Expand Down

0 comments on commit 895332b

Please sign in to comment.