k8s相关

旧时模样 提交于 2020-03-20 06:11:59

卸载kubernetes-dashboard

kubectl get secret,sa,role,rolebinding,services,deployments --namespace=kube-system | grep dashboard
sudo kubectl delete deployment kubernetes-dashboard --namespace=kube-system 
sudo kubectl delete service kubernetes-dashboard  --namespace=kube-system 
sudo kubectl delete role kubernetes-dashboard-minimal --namespace=kube-system 
sudo kubectl delete rolebinding kubernetes-dashboard-minimal --namespace=kube-system
sudo kubectl delete sa kubernetes-dashboard --namespace=kube-system 
sudo kubectl delete secret kubernetes-dashboard-certs --namespace=kube-system
sudo kubectl delete secret kubernetes-dashboard-csrf --namespace=kube-system
sudo kubectl delete secret kubernetes-dashboard-key-holder --namespace=kube-system

  

安装kubernetes-dashboard

[root@k8s-master ~]# wget https://raw.githubusercontent.com/kubernetes/dashboard/v1.10.1/src/deploy/recommended/kubernetes-dashboard.yaml
[root@k8s-master ~]# vim kubernetes-dashboard.yaml
修改内容:
109     spec:
110       containers:
111       - name: kubernetes-dashboard
112         image: registry.cn-hangzhou.aliyuncs.com/google_containers/kubernetes-dashboard-amd64:v1.10.1   # 修改此行

......

157 spec:
158   type: NodePort     # 增加此行
159   ports:
160     - port: 443
161       targetPort: 8443
162       nodePort: 30001   # 增加此行
163   selector:
164     k8s-app: kubernetes-dashboard

[root@k8s-master ~]# kubectl apply -f kubernetes-dashboard.yaml

[root@k8s-master ~]# kubectl create clusterrolebinding test:kubernetes-dashboard --clusterrole=cluster-admin --serviceaccount=kube-system:kubernetes-dashboard
[root@k8s-master ~]# kubectl describe secrets -n kube-system $(kubectl -n kube-system get secret | awk '/kubernetes-dashboard/{print $1}')

  动态扩容

[root@k8s-master ~]# kubectl scale --replicas=1 deployment nginx

      更新pod版本

[root@k8s-master ~]# kubectl set image deployment nginx nginx=nginx:1.15.5deployment.extensions/nginx image updated

  查看更新状态

[root@k8s-master ~]# kubectl rollout status deployment nginx
deployment "nginx" successfully rolled out

  查看pod详细信息

[root@k8s-master ~]# kubectl describe pods nginx-67d678c9f7-rqrtz

  回滚版本可以直接指定镜像版本或者使用下面命令

[root@k8s-master ~]# kubectl rollout undo deployment nginx
deployment.extensions/nginx rolled back

  

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!