k8s搭建

搭建教程
https://www.cnblogs.com/xuweiweiwoaini/p/13884112.html
初始化参数
kubeadm init --apiserver-advertise-address=192.168.1.161 --image-repository registry.aliyuncs.com/google_containers --kubernetes-version v1.18.0 --pod-network-cidr=10.244.0.0/16

安装dashboard教程
https://www.cnblogs.com/bigberg/p/13469736.html

生成一个永不过期的token

kubeadm token create --print-join-command
kubeadm token create --ttl 0

卸载dashboard

kubectl get secret,sa,role,rolebinding,services,deployments --namespace=kubernetes-dashboard | grep dashboard

kubectl delete deployment kubernetes-dashboard --namespace=kubernetes-dashboard 
kubectl delete service kubernetes-dashboard  --namespace=kubernetes-dashboard 
kubectl delete role kubernetes-dashboard-minimal --namespace=kubernetes-dashboard 
kubectl delete rolebinding kubernetes-dashboard-minimal --namespace=kubernetes-dashboard
kubectl delete sa kubernetes-dashboard --namespace=kubernetes-dashboard 
kubectl delete secret kubernetes-dashboard-certs --namespace=kubernetes-dashboard
kubectl delete secret kubernetes-dashboard-key-holder --namespace=kubernetes-dashboard

node加入master
kubeadm join 192.168.1.161:6443 --token kuezr7.kcikphsnhsr7v65d --discovery-token-ca-cert-hash sha256:8a603328953526a436bf8250ef3fb3aa75565f3de18308d0bee15cb7bc2e6c4e

kubectl 常用命令

获取node
kubectl get node

查看pod运行情况

kubectl get pods -A  -o wide

获取pod列表
kubectl get pod -A

查看命名空间下的pod
kubectl get pods -n kube-system

获取pod详情
kubectl describe pod 'podname' -n 'namespace'

使用yaml创建容器、用户、角色等
kubectl apply -f **.yaml

上一篇:centos K8S容器部署


下一篇:SpringBoot狂神10-(员工管理系统-登录功能实现)