Dashboard是Kubernetes官方的一个web页面;dashboard UI 目前可以处理所有的工作负载资源(指 Service、Pod 等这些 k8s 中的资源)。这意味着无论你使用什么类型的工作负载资源,它在Web界面上都是可见的,并且可以进行相应的操作。
下载yaml文件,修改镜像
#下载yaml文件
wget https://raw.githubusercontent.com/kubernetes/dashboard/v1.10.1/src/deploy/recommended/kubernetes-dashboard.yaml
#修改镜像地址和service两处 [这个镜像默认国外的访问不了;service处加一个type类型]
vim kubernetes-dashboard.yaml
省略信息······
# ------------------- Dashboard Deployment ------------------- #
省略信息······
containers:
- name: kubernetes-dashboard
image: lizhenliang/kubernetes-dashboard-amd64:v1.10.1
ports:
- containerPort: 8443
protocol: TCP
省略信息······
# ------------------- Dashboard Service ------------------- #
kind: Service
apiVersion: v1
metadata:
labels:
k8s-app: kubernetes-dashboard
name: kubernetes-dashboard
namespace: kube-system
spec:
type : NodePort
ports:
- port: 443
targetPort: 8443
selector:
k8s-app: kubernetes-dashboard
#创建
kubectl apply -f kubernetes-dashboard.yaml
#输出信息
secret/kubernetes-dashboard-certs created
serviceaccount/kubernetes-dashboard created
role.rbac.authorization.k8s.io/kubernetes-dashboard-minimal created
rolebinding.rbac.authorization.k8s.io/kubernetes-dashboard-minimal created
deployment.apps/kubernetes-dashboard created
service/kubernetes-dashboard created
#查看状态
kubectl get pods -n kube-system
NAME READY STATUS RESTARTS AGE
coredns-8686dcc4fd-6p9np 1/1 Running 0 70m
coredns-8686dcc4fd-jzv6q 1/1 Running 0 70m
etcd-k8s-master 1/1 Running 0 69m
kube-apiserver-k8s-master 1/1 Running 0 69m
kube-controller-manager-k8s-master 1/1 Running 0 69m
kube-flannel-ds-amd64-96xmb 1/1 Running 0 59m
kube-flannel-ds-amd64-fnfwc 1/1 Running 0 51m
kube-flannel-ds-amd64-nj29m 1/1 Running 0 51m
kube-proxy-7ghzz 1/1 Running 0 70m
kube-proxy-88kdl 1/1 Running 0 51m
kube-proxy-8x7lk 1/1 Running 0 51m
kube-scheduler-k8s-master 1/1 Running 0 69m
kubernetes-dashboard-7df98d85bd-vqtjc 1/1 Running 0 47s
#查看service
kubectl get svc -n kube-system
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
kube-dns ClusterIP 10.1.0.10 <none> 53/UDP,53/TCP,9153/TCP 71m
kubernetes-dashboard NodePort 10.1.136.94 <none> 443:31046/TCP 87s
访问
创建SA并绑定默定集群管理员角色
#创建
kubectl create serviceaccount dashboard-admin -n kube-system
kubectl create clusterrolebinding dashborad-admin --clusterrole=cluster-admin --serviceaccount=kube-system:dashboard-admin
#查看
kubectl get secret -n kube-system
NAME TYPE DATA AGE
attachdetach-controller-token-9c6b7 kubernetes.io/service-account-token 3 78m
bootstrap-signer-token-qvgbc kubernetes.io/service-account-token 3 78m
bootstrap-token-zhgabv bootstrap.kubernetes.io/token 7 78m
certificate-controller-token-phxh7 kubernetes.io/service-account-token 3 78m
clusterrole-aggregation-controller-token-cvhr4 kubernetes.io/service-account-token 3 78m
coredns-token-f6xvg kubernetes.io/service-account-token 3 78m
cronjob-controller-token-rtzgz kubernetes.io/service-account-token 3 78m
daemon-set-controller-token-lsf27 kubernetes.io/service-account-token 3 78m
dashboard-admin-token-rjknr kubernetes.io/service-account-token 3 57s
default-token-w59dw kubernetes.io/service-account-token 3 78m
deployment-controller-token-8bm7j kubernetes.io/service-account-token 3 78m
disruption-controller-token-nnccp kubernetes.io/service-account-token 3 78m
endpoint-controller-token-f92c9 kubernetes.io/service-account-token 3 78m
expand-controller-token-66fdx kubernetes.io/service-account-token 3 78m
flannel-token-wnzrq kubernetes.io/service-account-token 3 67m
generic-garbage-collector-token-8mpbd kubernetes.io/service-account-token 3 78m
horizontal-pod-autoscaler-token-xvbkf kubernetes.io/service-account-token 3 78m
job-controller-token-kfz8c kubernetes.io/service-account-token 3 78m
kube-proxy-token-64c8t kubernetes.io/service-account-token 3 78m
kubernetes-dashboard-certs Opaque 0 9m3s
kubernetes-dashboard-key-holder Opaque 2 8m51s
kubernetes-dashboard-token-h2vv8 kubernetes.io/service-account-token 3 9m3s
namespace-controller-token-czstf kubernetes.io/service-account-token 3 78m
node-controller-token-fhqlg kubernetes.io/service-account-token 3 78m
persistent-volume-binder-token-x7vb2 kubernetes.io/service-account-token 3 78m
pod-garbage-collector-token-pnqms kubernetes.io/service-account-token 3 78m
pv-protection-controller-token-w4krj kubernetes.io/service-account-token 3 78m
pvc-protection-controller-token-f6h5v kubernetes.io/service-account-token 3 78m
replicaset-controller-token-vll88 kubernetes.io/service-account-token 3 78m
replication-controller-token-rbnv7 kubernetes.io/service-account-token 3 78m
resourcequota-controller-token-m5pts kubernetes.io/service-account-token 3 78m
service-account-controller-token-bgh45 kubernetes.io/service-account-token 3 78m
service-controller-token-6qhjs kubernetes.io/service-account-token 3 78m
statefulset-controller-token-wk9wk kubernetes.io/service-account-token 3 78m
token-cleaner-token-dwhlj kubernetes.io/service-account-token 3 78m
ttl-controller-token-zqmjh kubernetes.io/service-account-token 3 78m
#查看token
kubectl describe secret -n dashboard-admin-token-rjknr -n kube-system
#找到dashboard-admin-token-rjknr下面的token,使用此token登录Dashboard
省略信息······
Name: dashboard-admin-token-rjknr
Namespace: kube-system
Labels: <none>
Annotations: kubernetes.io/service-account.name: dashboard-admin
kubernetes.io/service-account.uid: 096b42fb-671d-11e9-930c-000c29161b3b
Type: kubernetes.io/service-account-token
Data
====
ca.crt: 1025 bytes
namespace: 11 bytes
token: eyJhbGciOiJSUzI1NiIsImtpZCI6IiJ9.eyJpc3MiOiJrdWJlcm5ldGVzL3NlcnZpY2VhY2NvdW50Iiwia3ViZXJuZXRlcy5pby9zZXJ2aWNlYWNjb3VudC9uYW1lc3BhY2UiOiJrdWJlLXN5c3RlbSIsImt1YmVybmV0ZXMuaW8vc2VydmljZWFjY291bnQvc2VjcmV0Lm5hbWUiOiJkYXNoYm9hcmQtYWRtaW4tdG9rZW4tcmprbnIiLCJrdWJlcm5ldGVzLmlvL3NlcnZpY2VhY2NvdW50L3NlcnZpY2UtYWNjb3VudC5uYW1lIjoiZGFzaGJvYXJkLWFkbWluIiwia3ViZXJuZXRlcy5pby9zZXJ2aWNlYWNjb3VudC9zZXJ2aWNlLWFjY291bnQudWlkIjoiMDk2YjQyZmItNjcxZC0xMWU5LTkzMGMtMDAwYzI5MTYxYjNiIiwic3ViIjoic3lzdGVtOnNlcnZpY2VhY2NvdW50Omt1YmUtc3lzdGVtOmRhc2hib2FyZC1hZG1pbiJ9.jRn9N3WKp45QpWDLydggHJNXBvT0GW7RBbvgMjl4ttAa5XMMf54YdxCcb74g5YqlYKUbov-hSfOhRfGaIGOkXaBML31jt8tJSyu2EnzmnI5g84GTla1AyY-5eim5P1kdE5WeUWZmh12-nL3zkBrctoyD3S7oZCOpGvPX7TnzvLp0HKyJbuuzaMsRMhnTLCCan2l8SGoKbB_gDKB7w3uKbXIqYrj4zEtnWlKgxFWl0-6EXWEAiqiu9Iw8zHjMVXZX3c8LoezZ4U1FH4hB8x0BfboJTXo7-UYfRzvCcD07DhYZ2mXo-eQPrSsSaVFO3Pc9XMlDdrTJWNlu-Fr8yPXRvA
省略信息······
登录查看
本文最后记录时间 2024-03-30
文章链接地址:https://me.jinchuang.org/archives/447.html
本站文章除注明[转载|引用|来源],均为本站原创内容,转载前请注明出处
文章链接地址:https://me.jinchuang.org/archives/447.html
本站文章除注明[转载|引用|来源],均为本站原创内容,转载前请注明出处