kubernetesdashboard安装

编程

wget https://raw.githubusercontent.com/kubernetes/dashboard/v2.0.0-rc5/aio/deploy/recommended.yaml

mv recommended.yaml k8s-dashboard.yaml

 修改k8s-dashboard.yaml

  1. 增加直接访问端口
    #增加直接访问端口

    kind: Service

    apiVersion: v1

    metadata:

    labels:

    k8s-app: kubernetes-dashboard

    name: kubernetes-dashboard

    namespace: kubernetes-dashboard

    spec:

    type: NodePort #增加

    ports:

    - port: 443

    targetPort: 8443

    nodePort: 30008 #增加

    selector:

    k8s-app: kubernetes-dashboard

     

  2. 修改角色

    apiVersion: rbac.authorization.k8s.io/v1

    kind: RoleBinding

    metadata:

    labels:

    k8s-app: kubernetes-dashboard

    name: kubernetes-dashboard

    namespace: kubernetes-dashboard

    roleRef:

    apiGroup: rbac.authorization.k8s.io

    kind: ClusterRole #修改

    name: cluster-admin #修改

    subjects:

    - kind: ServiceAccount

    name: kubernetes-dashboard

    namespace: kubernetes-dashboard

    ---

    apiVersion: rbac.authorization.k8s.io/v1

    kind: ClusterRoleBinding

    metadata:

    name: kubernetes-dashboard

    roleRef:

    apiGroup: rbac.authorization.k8s.io

    kind: ClusterRole #修改

    name: cluster-admin #修改

    subjects:

    - kind: ServiceAccount

    name: kubernetes-dashboard

    namespace: kubernetes-dashboard

如果dashboard安装到master. 参考 https://www.jianshu.com/p/f9a2bd82e368。增加一个。注释几行

kind: Deployment

apiVersion: apps/v1

metadata:

labels:

k8s-app: kubernetes-dashboard

name: kubernetes-dashboard

namespace: kubernetes-dashboard

spec:

replicas: 1

revisionHistoryLimit: 10

selector:

matchLabels:

k8s-app: kubernetes-dashboard

template:

metadata:

labels:

k8s-app: kubernetes-dashboard

spec:

nodeName: ser10 #################################增加

containers:

- name: kubernetes-dashboard

image: kubernetesui/dashboard:v2.0.0-rc5

imagePullPolicy: Always

ports:

- containerPort: 8443

protocol: TCP

args:

- --auto-generate-certificates

- --namespace=kubernetes-dashboard

# Uncomment the following line to manually specify Kubernetes API server Host

# If not specified, Dashboard will attempt to auto discover the API server and connect

# to it. Uncomment only if the default does not work.

# - --apiserver-host=http://my-address:port

volumeMounts:

- name: kubernetes-dashboard-certs

mountPath: /certs

# Create on-disk volume to store exec logs

- mountPath: /tmp

name: tmp-volume

livenessProbe:

httpGet:

scheme: HTTPS

path: /

port: 8443

initialDelaySeconds: 30

timeoutSeconds: 30

securityContext:

allowPrivilegeEscalation: false

readOnlyRootFilesystem: true

runAsUser: 1001

runAsGroup: 2001

volumes:

- name: kubernetes-dashboard-certs

secret:

secretName: kubernetes-dashboard-certs

- name: tmp-volume

emptyDir: {}

serviceAccountName: kubernetes-dashboard

nodeSelector:

"beta.kubernetes.io/os": linux

# Comment the following tolerations if Dashboard must not be deployed on master

#########################注释以下#

#tolerations:

# - key: node-role.kubernetes.io/master

# effect: NoSchedule

执行命令: 

kubectl create -f k8s-dashboard.yaml

访问 http://192.168.1.10:30008

查看token, 并粘贴到页面上。

kubectl -n kubernetes-dashboard describe secret $(kubectl -n kubernetes-dashboard get secret | grep dashboard-admin | awk "{print $1}")

 

以上是 kubernetesdashboard安装 的全部内容, 来源链接: utcz.com/z/513880.html

回到顶部