Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
59 changes: 31 additions & 28 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
# install-k8s on ubuntu 20.4
--------------------------------------------------------------------------------------------------------------------------------------------------------------------

#docker

sudo apt update
&& lsmod | grep br_netfilter
&& sudo modprobe br_netfilter
&& sudo sysctl net.bridge.bridge-nf-call-iptables=1
--------------------------------------------------------------------------------------------------------------------------------------------------------------------

sudo apt install apt-transport-https ca-certificates curl software-properties-common -y
&& sudo curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
&& sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu focal stable"
Expand All @@ -26,6 +28,7 @@
&& sudo rm -rf /etc/containerd/config.toml
&& sudo systemctl restart containerd
--------------------------------------------------------------------------------------------------------------------------------------------------------------------

#k8s

sudo apt install apt-transport-https curl -y
Expand All @@ -39,11 +42,13 @@
&& sudo apt-get install -y kubernetes-cni
&& sudo apt-get install -y kubelet kubeadm kubectl kubernetes-cni
--------------------------------------------------------------------------------------------------------------------------------------------------------------------

#swap

sudo swapoff -a
&& sudo nano /etc/fstab
--------------------------------------------------------------------------------------------------------------------------------------------------------------------

#comment swap file

Inside the file, comment out the swapfile line as shown in the screenshot below:
Expand All @@ -61,6 +66,7 @@
UUID=71D9-7FBF /boot/efi vfat umask=0077 0 1
-> #/swapfile none swap sw 0 0
--------------------------------------------------------------------------------------------------------------------------------------------------------------------

#init node in k8s

sudo kubeadm init --ignore-preflight-errors=NumCPU,Mem --pod-network-cidr=10.244.0.0/16
Expand All @@ -72,12 +78,17 @@
&& sudo ufw allow 6443/tcp
&& kubectl apply -f https://raw.githubusercontent.com/coreos/flannel/master/Documentation/kube-flannel.yml
--------------------------------------------------------------------------------------------------------------------------------------------------------------------

#Sử dụng khi chỉ dùng một node master (huynt là tên node)

kubectl taint nodes huynt node-role.kubernetes.io/control-plane-

--------------------------------------------------------------------------------------------------------------------------------------------------------------------

#install dashboard

#create tls

sudo mkdir /certs
&& sudo chmod -R 777 /certs
&& sudo openssl req -nodes -newkey rsa:2048 -keyout /certs/dashboard.key -out /certs/dashboard.csr -subj "/C=/ST=/L=/O=/OU=/CN=kubernetes-dashboard"
Expand All @@ -89,21 +100,30 @@
kubectl create secret generic kubernetes-dashboard-certs --from-file=/certs -n kubernetes-dashboard

#run file dashboard.yaml

kubectl apply -f dashboard.yaml

#create account admin

#run file admin-user.yaml

kubectl apply -f admin-user.yaml

#create token login web dashboard

kubectl -n kubernetes-dashboard create token admin-user

-------------------------------------------------------------------------------------------------------------------#install ingress-nginx controller
-------------------------------------------------------------------------------------------------------------------

#install ingress-nginx controller

kubectl apply -f https://raw.githubusercontent.com/kubernetes/ingress-nginx/controller-v1.7.1/deploy/static/provider/cloud/deploy.yaml
kubectl get pods --namespace=ingress-nginx

-------------------------------------------------------------------------------------------------------------------#install loadalancer

#install loadalancer

# see what changes would be made, returns nonzero returncode if different
kubectl get configmap kube-proxy -n kube-system -o yaml | \
sed -e "s/strictARP: false/strictARP: true/" | \
Expand All @@ -119,13 +139,16 @@
#run file loadalancer.yaml
kubectl apply -f loadalancer.yaml
-------------------------------------------------------------------------------------------------------------------

#insert name hosts

sudo nano /etc/hosts

example: 192.168.1.11 congcu24.com

--------------------------------------------------------------------------------------------------------------------------------------------------------------------
--------------------------------------------------------------------------------------------------------------------------------------------------------------------

#common k8s

#reset Node
Expand Down Expand Up @@ -194,40 +217,20 @@

---------------------------------------------------------------------------------------
#common

#Xem port nào đang chạy

sudo lsof -i -P -n | grep LISTEN

#Cấp Quyền

sudo chmod -R 777 /home/worker/.kube/config-mycluster

#Đứng ở node worker gọi lệnh để tải file cấu hình master về worker (truyền file)

sudo scp [email protected]:/etc/kubernetes/admin.conf ~/.kube/config-mycluster

--------------------------------------------------------------------------------------------------------------------------------------------------------------------
--------------------------------------------------------------------------------------------------------------------------------------------------------------------
--------------------------------------------------------------------------------------------------------------------------------------------------------------------
--------------------------------------------------------------------------------------------------------------------------------------------------------------------
--------------------------------------------------------------------------------------------------------------------------------------------------------------------
--------------------------------------------------------------------------------------------------------------------------------------------------------------------
--------------------------------------------------------------------------------------------------------------------------------------------------------------------
--------------------------------------------------------------------------------------------------------------------------------------------------------------------
--------------------------------------------------------------------------------------------------------------------------------------------------------------------
--------------------------------------------------------------------------------------------------------------------------------------------------------------------
--------------------------------------------------------------------------------------------------------------------------------------------------------------------
--------------------------------------------------------------------------------------------------------------------------------------------------------------------
--------------------------------------------------------------------------------------------------------------------------------------------------------------------
--------------------------------------------------------------------------------------------------------------------------------------------------------------------
--------------------------------------------------------------------------------------------------------------------------------------------------------------------
--------------------------------------------------------------------------------------------------------------------------------------------------------------------
--------------------------------------------------------------------------------------------------------------------------------------------------------------------
--------------------------------------------------------------------------------------------------------------------------------------------------------------------
--------------------------------------------------------------------------------------------------------------------------------------------------------------------
--------------------------------------------------------------------------------------------------------------------------------------------------------------------
--------------------------------------------------------------------------------------------------------------------------------------------------------------------
--------------------------------------------------------------------------------------------------------------------------------------------------------------------
--------------------------------------------------------------------------------------------------------------------------------------------------------------------
--------------------------------------------------------------------------------------------------------------------------------------------------------------------
--------------------------------------------------------------------------------------------------------------------------------------------------------------------
--------------------------------------------------------------------------------------------------------------------------------------------------------------------
--------------------------------------------------------------------------------------------------------------------------------------------------------------------
--------------------------------------------------------------------------------------------------------------------------------------------------------------------
--------------------------------------------------------------------------------------------------------------------------------------------------------------------