凯发k8天生赢家一触即发

k8s-凯发k8天生赢家一触即发

2023-10-20

[root@k8s-master dashboard]# pwd
/usr/local/src/kubernetes/cluster/addons/dashboard

[root@k8s-master dashboard]# mkdir /usr/local/src/dashboard
[root@k8s-master dashboard]# cp dashboard-rbac.yaml dashboard-service.yaml dashboard-controller.yaml /usr/local/src/dashboard
[root@k8s-master dashboard]# cd /usr/local/src/dashboard/
[root@k8s-master dashboard]# ll
total 12
-rw-r--r-- 1 root root 1821 may 30 01:01 dashboard-controller.yaml
-rw-r--r-- 1 root root 1353 may 30 01:01 dashboard-rbac.yaml
-rw-r--r-- 1 root root 322 may 30 01:01 dashboard-service.yaml

[root@k8s-master dashboard]# pwd
/usr/local/src/dashboard
[root@k8s-master dashboard]# ll
total
-rw-r--r-- root root may : dashboard-controller.yaml
-rw-r--r-- root root may : dashboard-rbac.yaml
-rw-r--r-- root root may : dashboard-service.yaml
[root@k8s-master dashboard]# kubectl create -f dashboard-rbac.yaml
[root@k8s-master dashboard]# kubectl create -f dashboard-controller.yaml
deployment "kubernetes-dashboard" created
[root@k8s-master dashboard]# kubectl create -f dashboard-service.yaml
service "kubernetes-dashboard" created
###查看
[root@k8s-master ~]# kubectl get services kubernetes-dashboard -n kube-system
name type cluster-ip external-ip port(s) age
kubernetes-dashboard nodeport 10.10.10.199 :/tcp 2m [root@k8s-master dashboard]# kubectl get pods -n kube-system #####status not running
name ready status restarts age
kubernetes-dashboard-765c8bfdff-ddwvw / imagepullbackoff 22m [root@k8s-master dashboard]# kubectl describe pod kubernetes-dashboard-765c8bfdff-ddwvw -n kube-system ####查看原因
发现里面的一个image地址写错了,解决办法如下:
[root@k8s-master dashboard]# kubectl delete -f dashboard-controller.yaml
deployment "kubernetes-dashboard" deleted
[root@k8s-master dashboard]# kubectl create -f dashboard-controller.yaml
deployment "kubernetes-dashboard" created
[root@k8s-master dashboard]# kubectl get pods
name ready status restarts age
nginx-64f497f8fd-jnhgm / running 20h
nginx-64f497f8fd-n5pst / running 20h
nginx-64f497f8fd-rzldm / running 20h
[root@k8s-master dashboard]# kubectl get pods -n kube-system
name ready status restarts age
kubernetes-dashboard-769c9999cb-wwxsn / running 21s [root@k8s-master dashboard]# kubectl get all -n kube-system
name desired current up-to-date available age
deploy/kubernetes-dashboard 18m name desired current ready age
rs/kubernetes-dashboard-769c9999cb 18m name ready status restarts age
po/kubernetes-dashboard-769c9999cb-wwxsn / running 18m name type cluster-ip external-ip port(s) age
svc/kubernetes-dashboard nodeport 10.10.10.199 :/tcp 42m [root@k8s-master dashboard]# kubectl get svc -n kube-system
name type cluster-ip external-ip port(s) age
kubernetes-dashboard nodeport 10.10.10.199 :/tcp 46m
[root@k8s-master dashboard]# cat dashboard-controller.yaml
apiversion: apps/v1beta2
kind: deployment
metadata:
name: kubernetes-dashboard
namespace: kube-system
labels:
k8s-app: kubernetes-dashboard
kubernetes.io/cluster-service: "true"
addonmanager.kubernetes.io/mode: reconcile
spec:
selector:
matchlabels:
k8s-app: kubernetes-dashboard
template:
metadata:
labels:
k8s-app: kubernetes-dashboard
annotations:
scheduler.alpha.kubernetes.io/critical-pod: ''
spec:
serviceaccountname: kubernetes-dashboard
containers:
- name: kubernetes-dashboard
image: registry.cn-hangzhou.aliyuncs.com/google_containers/kubernetes-dashboard-amd64:v1.7.1
resources:
limits:
cpu: 100m
memory: 300mi
requests:
cpu: 100m
memory: 100mi
ports:
- containerport:
protocol: tcp
livenessprobe:
httpget:
scheme: http
path: /
port:
initialdelayseconds:
timeoutseconds:
tolerations:
- key: "criticaladdonsonly"
operator: "exists"
[root@k8s-master dashboard]# cat dashboard-rbac.yaml
apiversion: v1
kind: serviceaccount
metadata:
labels:
k8s-app: kubernetes-dashboard
addonmanager.kubernetes.io/mode: reconcile
name: kubernetes-dashboard
namespace: kube-system
--- kind: clusterrolebinding
apiversion: rbac.authorization.k8s.io/v1beta1
metadata:
name: kubernetes-dashboard-minimal
namespace: kube-system
labels:
k8s-app: kubernetes-dashboard
addonmanager.kubernetes.io/mode: reconcile
roleref:
apigroup: rbac.authorization.k8s.io
kind: clusterrole
name: cluster-admin
subjects:
- kind: serviceaccount
name: kubernetes-dashboard
namespace: kube-system
[root@k8s-master dashboard]# cat dashboard-service.yaml
apiversion: v1
kind: service
metadata:
name: kubernetes-dashboard
namespace: kube-system
labels:
k8s-app: kubernetes-dashboard
kubernetes.io/cluster-service: "true"
addonmanager.kubernetes.io/mode: reconcile
spec:
type: nodeport
selector:
k8s-app: kubernetes-dashboard
ports:
- port:
targetport:

#####可以在浏览器输入其中一个节点和端口访问

k8s-部署web-ui(dashboard)的相关教程结束。

网站地图