Professional Documents
Culture Documents
Kubernetes có thể chạy trên nhiều nền tảng khác nhau, từ Laptop đến trên các VM hay máy chủ vật lý
(bare metal server). Nếu chỉ mới tìm hiểu Kubernetes thì có thể dùng Minikube, kind hoặc Microk8s để
tạo một Kubernetes Cluster (Single-Node) cực kì đơn giản và nhanh chóng.
Tìm hiểu Kubernetes để hiểu sâu hoạt động bên trong của nó để thi chứng chỉ Certified Kubernetes
Administrator (CKA) hay vận hành một Kubernetes Cluster ở môi trường Production thì có thể dùng
kubeadm, Kops. kubeadm là công cụ giúp bootstrap một Kubernetes Cluster. kubeadm cho phép tùy
biến cao trong quá trình cài đặt Kubernetes Cluster, nó hỗ trợ multi-node thậm chí multi-master.
Kubernetes Cluster bao gồm 1 Master Node và 2 Worker Node (CentOS 7):
Tắt SELinux:
setenforce 0
sed -i 's/^SELINUX=enforcing$/SELINUX=permissive/' /etc/selinux/config
systemctl daemon-reload
systemctl restart docker
systemctl enable docker
Lưu lại dòng kubeadm join để join các máy worker vào cluster
Thiết lập trên kubectl cho user root trên Master Node nên chỉ cần export đường dẫn file config thông
qua biến môi trường KUBECONFIG:
export KUBECONFIG=/etc/kubernetes/admin.conf
echo 'export KUBECONFIG=/etc/kubernetes/admin.conf' >> ~/.bash_profile
Cài Network addon calico:
curl https://docs.projectcalico.org/manifests/canal.yaml -O
kubectl apply -f canal.yaml
Kết quả
Để lấy thông tin chi tiết về một Node nào đó như tài nguyên bộ nhớ, CPU, các container ... sử dụng lệnh:
kubectl describe node tên-node
1. Cài dardboard cho k8s
Sử dụng Lens hoặc build
kubectl proxy
http://localhost:8001/api/v1/namespaces/kubernetes-dashboard/services/https:kubernetes-
dashboard:/proxy/
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
name: admin-user
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: cluster-admin
subjects:
- kind: ServiceAccount
name: admin-user
namespace: kubernetes-dashboard