文章插图
# master节点执行: # 创建必要文件 mkdir -p $HOME/.kube sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config sudo chown $(id -u):$(id -g) $HOME/.kube/config6、node节点加入集群 # 所有node节点执行: # 执行初始化生成的join 命令: kubeadm join 10.0.0.17:6443 --token fnpbrc.e5s4jqrx8na4cpo9 \ --discovery-token-ca-cert-hash sha256:5ecaba93c59504941137c963584e81643c6b50ecda6c2c1f4a4f60ca8cd9a7a0 # 提示"kubectl get nodes",表示加入集群成功,可在master节点使用此命令查看node信息 # 如果忘记或者token过期(默认有效期24小时)需要执行以下命令: kubeadm token create --print-join-command
文章插图
7、部署网络 # master节点执行: # 下载calico YAML文件 wget https://docs.projectcalico.org/manifests/calico.yaml #修改Pod网络(CALICO_IPV4POOL_CIDR),与前面kubeadm init的–pod-network-cidr指定的一样(大概4551行左右) vim calico.yaml ...... # no effect. This should fall within `--cluster-cidr`. - name: CALICO_IPV4POOL_CIDR #取消注释 value: "10.244.0.0/16" #取消注释,修改为初始化–pod-network-cidr指定的地址 # Disable file logging so `kubectl logs` works. ...... kubectl apply -f calico.yaml # 稍等片刻,查看节点状态: [root@master ~]# kubectl get nodes NAME STATUS ROLES AGE VERSION master Ready control-plane,master 49m v1.23.0 node Ready <none> 14m v1.23.0 # 查看通信状态 kubectl get pods -n kube-system8、部署nginx测试 #创建一个yaml文件 [root@master ~]# vim nginx.yml apiVersion: apps/v1 kind: Deployment metadata: name: nginx-deployment labels: app: nginx rel: stable spec: replicas: 3 selector: matchLabels: app: nginx rel: stable template: metadata: labels: app: nginx rel: stable spec: containers: - name: nginx image: nginx [root@master ~]# kubectl apply -f nginx.yml #再创建一个yaml文件: [root@master ~]# vim nginx-service.yml apiVersion: v1 kind: Service metadata: name: nginx-service spec: selector: app: nginx type: NodePort ports: - protocol: TCP port: 80 targetPort: 80 [root@master ~]# kubectl apply -f nginx-service.yml #查看服务 (Running说明启动成功) [root@master ~]# kubectl get pod,svc NAME READY STATUS RESTARTS AGE pod/nginx-deployment-749d94b5db-64lm7 1/1 Running 0 8m20s pod/nginx-deployment-749d94b5db-j522z 1/1 Running 0 8m20s pod/nginx-deployment-749d94b5db-jjwjr 1/1 Running 0 8m20s NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE service/kubernetes ClusterIP 10.96.0.1 <none> 443/TCP 63m service/nginx-service NodePort 10.98.54.199 <none> 80:32378/TCP 4m35s
推荐阅读
- Kubeadm部署Kubernetes
- 含源码 【YOLOv5】手把手教你使用LabVIEW ONNX Runtime部署 TensorRT加速,实现YOLOv5实时物体识别
- 二 Istio:在Kubernetes(k8s)集群上安装部署istio1.14
- .NET6打包部署到Windows Service
- docker swarm快速部署redis分布式集群
- 使用 etcdadm 快速、弹性部署 etcd 集群
- Cenots7 离线安装部署PostgreSQL
- 十一 【Kubernetes】K8s笔记:Ingress 集群进出流量总管
- 快速安装 服务器之Apollo单机部署
- 云计算_OpenStack