Kubernetes is an open-source system for automating deployment, scaling, and management of containerized applications.
概念
-
master
-
node
-
pod
label
- service
label selector
- container
pause
安装
版本
CentOS 7.6
docker-ce 19.03.9-3.el7
Kubernetes 1.19.16-0
calico 3.20
关闭防火墙
systemctl disable firewalld
systemctl stop firewalld
关闭swap
swapoff -a
vi /etc/fstab,删除swap挂载
建议在主机上禁用 SELinux (修改文件/etc/sysconfig/selinux, SELINUX=enforcing 修改为 SELIN口(=中sabled)
修改主机名
1 |
|
/etc/hosts
1 |
|
1 |
|
yum install -y kubelet-1.19.16-0 kubeadm-1.19.16-0 kubectl-1.19.16-0
echo 1 > /proc/sys/net/bridge/bridge-nf-call-iptables
cat > /etc/docker/daemon.json «EOF { “exec-opts”: [“native.cgroupdriver=systemd”], “log-driver”: “json-file”, “log-opts”: { “max-size”: “100m” }, “storage-driver”: “overlay2”, “storage-opts”: [ “overlay2.override_kernel_check=true” ] } EOF
rm -rf /var/lib/etcd/
kubeadm init phase preflight
kubeadm init
kubeadm config print init-defaults
kubeadm config print join-defaults
kubeadm config images list
kubeadm config images pull
kubeadm config images pull –image-repository registry.aliyuncs.com/google_containers
kubeadm init –image-repository registry.aliyuncs.com/google_containers
export KUBECONFIG=/etc/kubernetes/admin.conf
kubeadm join 192.168.1.231:6443 –token ot1cwn.jcjdue03ud93or6r
–discovery-token-ca-cert-hash sha256:81abfd322b69dcccef74381214fa54f52205dfca34a1a0bb8e253d805a433926
kubectl -n kube-system get configmap
kubectl get nodes
安装CNI网络插件
kubectl apply -f “https://docs.projectcalico.org/archive/v3.20/manifests/calico.yaml”
kubectl get pods –all-namespaces
kubectl apply -f mysql-deploy.yaml
mysql-deploy.yaml
1 |
|
1 |
|
1 |
|
1 |
|
kubectl create -f mysql-svc.yaml
mysql-svc.yaml
1 |
|
kubectl get svc mysql
1 |
|
注意修改mysql的地址
kubectl apply -f myweb-deploy.yaml
myweb-deploy.yaml
1 |
|
kubectl create -f myweb-svc.yaml
1 |
|
kubectl get deployments.apps
kubectl edit deployment/myweb -o yaml –save-config
kubectl get svc myweb
http://192.168.1.232:30001/demo/
相关书籍
《Kubernetes权威指南:从Docker到Kubernetes实践全接触》
《Kubernetes权威指南——企业级容器云实战》