Skip to content

Commit eea3678

Browse files
authored
Docs install k8s
0 parents  commit eea3678

File tree

1 file changed

+68
-0
lines changed

1 file changed

+68
-0
lines changed

install k8s.md

+68
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
# Step1 install docker
2+
```bash
3+
sudo apt update
4+
sudo apt install apt-transport-https ca-certificates curl software-properties-common -y
5+
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
6+
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu bionic stable"
7+
sudo apt update
8+
sudo apt install docker-ce -y
9+
sudo systemctl status docker
10+
```
11+
# Step2 disabe firewall swap
12+
- Kubernetes khuyến nghị swap
13+
```bash
14+
ufw disable
15+
swapoff -a
16+
sed -i '/swap/ s/^\(.*\)$/#\1/g' /etc/fstab
17+
```
18+
# Step3 add public keys
19+
```bash
20+
curl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo apt-key add -
21+
```
22+
# Step4 Add kubernetes repo
23+
```bash
24+
sudo bash -c 'echo "deb http://apt.kubernetes.io/ kubernetes-xenial main" > /etc/apt/sources.list.d/kubernetes.list'
25+
```
26+
# Step5
27+
```bash
28+
sudo apt-get update && sudo apt-get install -y kubelet kubeadm kubectl
29+
```
30+
# Step6 Enable, start and status kubelet
31+
```bash
32+
sudo systemctl enable kubelet
33+
sudo systemctl start kubelet
34+
sudo systemctl status kubelet
35+
```
36+
# Step7 khởi tạo Kubernetes Cluster
37+
```bash
38+
IPADDR=$(hostname -I |awk '{ print $1 }')
39+
40+
kubeadm init --apiserver-advertise-address $IPADDR --pod-network-cidr=10.224.0.0/16
41+
```
42+
# Step8 cấu hình để sử dụng được tập lệnh kubectl tương tác với API server
43+
```bash
44+
mkdir -p $HOME/.kube
45+
sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
46+
sudo chown $(id -u):$(id -g) $HOME/.kube/config
47+
```
48+
# Step9 apply CNI(container network interface)
49+
plugin network là calico. Dải địa chỉ IP có `CIDR là 10.224.0.0/16` sẽ được sử dụng để cấp phát địa chỉ IP cho các Pod. Pod là một thành phần bao bọc các container khi chạy container trong Kubernetes.
50+
```bash
51+
curl https://docs.tigera.io/archive/v3.25/manifests/calico.yaml -O
52+
```
53+
`vim calico.yaml +4601` Loại bỏ comment của 02 dòng này và thay đúng CIDR từ lệnh khởi tạo vào
54+
```
55+
- name: CALICO_IPV4POOL_CIDR
56+
value: "10.224.0.0/16"
57+
```
58+
`kubectl apply -f calico.yaml` triển khai calico
59+
# Step 10 get token
60+
Vì token sử dụng để join các Worker node có thời gian sử dụng là 24h, chạy lệnh sau sẽ có token khi chạy `kubeadm join`
61+
```bash
62+
kubeadm token create --print-join-command
63+
```
64+
Run token trên các worker node
65+
# Check node
66+
```bash
67+
kubectl get nodes -o wide
68+
```

0 commit comments

Comments
 (0)