1. 程式人生 > >k8s實踐14:dashboard部署訪問用戶權限一籮筐

k8s實踐14:dashboard部署訪問用戶權限一籮筐

ble mua source api data sys win temp psr

1.
準備配置文件

[[email protected] ~]# wget https://raw.githubusercontent.com/kubernetes/dashboard/master/aio/deploy/recommended/kubernetes-dashboard.yaml
--2019-04-23 11:11:25--? https://raw.githubusercontent.com/kubernetes/dashboard/master/aio/deploy/recommended/kubernetes-dashboard.yaml
Resolving raw.githubusercontent.com (raw.githubusercontent.com)... 199.232.4.133
Connecting to raw.githubusercontent.com (raw.githubusercontent.com)|199.232.4.133|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 4784 (4.7K) [text/plain]
Saving to: ‘kubernetes-dashboard.yaml’

100%[==================================================================>] 4,784? ? ?? --.-K/s?? in 0.004s?
[[email protected] dashboard]# ls
kubernetes-dashboard.yaml

2.
配置文件簡單了解

[[email protected] dashboard]# cat kubernetes-dashboard.yaml
# Copyright 2017 The Kubernetes Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#? ?? http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# ------------------- Dashboard Secrets ------------------- #

apiVersion: v1
kind: Secret
metadata:
? labels:
? ? k8s-app: kubernetes-dashboard
? name: kubernetes-dashboard-certs
? namespace: kube-system
type: Opaque

---

apiVersion: v1
kind: Secret
metadata:
? labels:
? ? k8s-app: kubernetes-dashboard
? name: kubernetes-dashboard-csrf
? namespace: kube-system
type: Opaque
data:
? csrf: ""

---
# ------------------- Dashboard Service Account ------------------- #

apiVersion: v1
kind: ServiceAccount
metadata:
? labels:
? ? k8s-app: kubernetes-dashboard
? name: kubernetes-dashboard
? namespace: kube-system

---
# ------------------- Dashboard Role & Role Binding ------------------- #

kind: Role
apiVersion: rbac.authorization.k8s.io/v1
metadata:
? name: kubernetes-dashboard-minimal
? namespace: kube-system
rules:
? # Allow Dashboard to create ‘kubernetes-dashboard-key-holder‘ secret.
- apiGroups: [""]
? resources: ["secrets"]
? verbs: ["create"]
? # Allow Dashboard to create ‘kubernetes-dashboard-settings‘ config map.
- apiGroups: [""]
? resources: ["configmaps"]
? verbs: ["create"]
? # Allow Dashboard to get, update and delete Dashboard exclusive secrets.
- apiGroups: [""]
? resources: ["secrets"]
? resourceNames: ["kubernetes-dashboard-key-holder", "kubernetes-dashboard-certs", "kubernetes-dashboard-csrf"]
? verbs: ["get", "update", "delete"]
? # Allow Dashboard to get and update ‘kubernetes-dashboard-settings‘ config map.
- apiGroups: [""]
? resources: ["configmaps"]
? resourceNames: ["kubernetes-dashboard-settings"]
? verbs: ["get", "update"]
? # Allow Dashboard to get metrics from heapster.
- apiGroups: [""]
? resources: ["services"]
? resourceNames: ["heapster"]
? verbs: ["proxy"]
- apiGroups: [""]
? resources: ["services/proxy"]
? resourceNames: ["heapster", "http:heapster:", "https:heapster:"]
? verbs: ["get"]

---
apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
? name: kubernetes-dashboard-minimal
? namespace: kube-system
roleRef:
? apiGroup: rbac.authorization.k8s.io
? kind: Role
? name: kubernetes-dashboard-minimal
subjects:
- kind: ServiceAccount
? name: kubernetes-dashboard
? namespace: kube-system

---
# ------------------- Dashboard Deployment ------------------- #

kind: Deployment
apiVersion: apps/v1
metadata:
? labels:
? ? k8s-app: kubernetes-dashboard
? name: kubernetes-dashboard
? namespace: kube-system
spec:
? replicas: 1
? revisionHistoryLimit: 10
? selector:
? ? matchLabels:
? ? ? k8s-app: kubernetes-dashboard
? template:
? ? metadata:
? ? ? labels:
? ? ? ? k8s-app: kubernetes-dashboard
? ? spec:
? ? ? containers:
? ? ? - name: kubernetes-dashboard
? ? ? ? image: k8s.gcr.io/kubernetes-dashboard-amd64:v1.10.1
? ? ? ? ports:
? ? ? ? - containerPort: 8443
? ? ? ? ? protocol: TCP
? ? ? ? args:
? ? ? ? ? - --auto-generate-certificates
? ? ? ? ? # 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
? ? ? volumes:
? ? ? - name: kubernetes-dashboard-certs
? ? ? ? secret:
? ? ? ? ? secretName: kubernetes-dashboard-certs
? ? ? - name: tmp-volume
? ? ? ? emptyDir: {}
? ? ? serviceAccountName: kubernetes-dashboard
? ? ? # Comment the following tolerations if Dashboard must not be deployed on master
? ? ? tolerations:
? ? ? - key: node-role.kubernetes.io/master
? ? ? ? effect: NoSchedule

---
# ------------------- Dashboard Service ------------------- #

kind: Service
apiVersion: v1
metadata:
? labels:
? ? k8s-app: kubernetes-dashboard
? name: kubernetes-dashboard
? namespace: kube-system
spec:
? ports:
? ? - port: 443
? ? ? targetPort: 8443
? selector:
? ? k8s-app: kubernetes-dashboard
[[email protected] dashboard]#?

創建sa:kubernetes-dashboard 並指定了權限,用這個sa登陸dashboard

3.

部署

[[email protected] dashboard]# kubectl apply -f kubernetes-dashboard.yaml
secret "kubernetes-dashboard-certs" created
secret "kubernetes-dashboard-csrf" 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
[[email protected] dashboard]#

[[email protected] dashboard]# kubectl get svc,pod -n kube-system
NAME? ? ? ? ? ? ? ? ? ? ? ? ? ? ? TYPE? ? ? ? CLUSTER-IP? ? ?? EXTERNAL-IP? ? ? PORT(S)? ? ? ? ?? AGE
service/kube-dns? ? ? ? ? ? ? ? ? ClusterIP?? 10.254.0.2? ? ?? <none>? ? ? ? ?? 53/UDP,53/TCP? ?? 20h
service/kubernetes-dashboard? ? ? ClusterIP?? 10.254.61.18? ?? <none>? ? ? ? ?? 443/TCP? ? ? ? ?? 5s
service/traefik-ingress-service?? ClusterIP?? 10.254.83.91? ?? 192.168.32.127?? 80/TCP,8080/TCP?? 3h
service/traefik-web-ui? ? ? ? ? ? ClusterIP?? 10.254.124.127?? <none>? ? ? ? ?? 80/TCP? ? ? ? ? ? 21h

NAME? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? READY? ?? STATUS? ? RESTARTS?? AGE
pod/coredns-779ffd89bd-pz6s2? ? ? ? ? ? ? ? ? ? ? 0/1? ? ?? Unknown?? 1? ? ? ? ? 20h
pod/coredns-779ffd89bd-wmzhf? ? ? ? ? ? ? ? ? ? ? 1/1? ? ?? Running?? 1? ? ? ? ? 3h
pod/kubernetes-dashboard-65c76f6c97-zq6wr? ? ? ?? 1/1? ? ?? Running?? 0? ? ? ? ? 4s
pod/traefik-ingress-controller-6545547764-22jx6?? 1/1? ? ?? Running?? 0? ? ? ? ? 3h
pod/traefik-ingress-controller-6545547764-66wb8?? 1/1? ? ?? Running?? 0? ? ? ? ? 3h
pod/traefik-ingress-controller-6545547764-9dbt6?? 1/1? ? ?? Running?? 0? ? ? ? ? 3h
pod/traefik-ingress-controller-6545547764-vrf8h?? 1/1? ? ?? Running?? 0? ? ? ? ? 3h

4.

如何訪問dashboard

用traefik配置訪問dashboard

創建個Ing

[[email protected] dashboard]# cat dashboard-svc-ingress.yaml
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
? name: dashboard-ingress
? namespace: kube-system
spec:
? rules:
? - host: dashboard-ingress
? ? http:
? ? ? paths:
? ? ? - path: /
? ? ? ? backend:
? ? ? ? ? serviceName: kubernetes-dashboard
? ? ? ? ? servicePort: 443
[[email protected] dashboard]#
[[email protected] dashboard]# kubectl apply -f dashboard-svc-ingress.yaml
ingress.extensions "dashboard-ingress" created
[[email protected] dashboard]# kubectl get ing
NAME? ? ? ? ? ? ? ? HOSTS? ? ? ? ? ? ?? ADDRESS?? PORTS? ?? AGE
httpd-svc-ingress?? httpd-svc.ingress? ? ? ? ? ?? 80? ? ? ? 21h
[[email protected] dashboard]# kubectl get ing -n kube-system
NAME? ? ? ? ? ? ? ? HOSTS? ? ? ? ? ? ? ?? ADDRESS?? PORTS? ?? AGE
dashboard-ingress?? dashboard-ingress? ? ? ? ? ? ?? 80? ? ? ? 11s
traefik-web-ui? ? ? traefik-ui.minikube? ? ? ? ? ?? 80? ? ? ? 21h

綁定域名,我這裏是綁定dashboard-ingress到ip 192.168.32.127
訪問瀏覽器頁面報錯:Internal Server Error

pod報錯:

[[email protected] traefik]# kubectl get pod -n kube-system
NAME? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?? READY? ?? STATUS? ? RESTARTS?? AGE
coredns-779ffd89bd-wmzhf? ? ? ? ? ? ? ? ? ?? 1/1? ? ?? Running?? 3? ? ? ? ? 1d
kubernetes-dashboard-65c76f6c97-m29nl? ? ? ? 1/1? ? ?? Running?? 2? ? ? ? ? 19h
traefik-ingress-controller-c6978f9f7-4c767?? 1/1? ? ?? Running?? 0? ? ? ? ? 2m
traefik-ingress-controller-c6978f9f7-8fvjk?? 1/1? ? ?? Running?? 0? ? ? ? ? 2m
traefik-ingress-controller-c6978f9f7-hjfvb?? 1/1? ? ?? Running?? 0? ? ? ? ? 2m
[[email protected] traefik]# kubectl logs traefik-ingress-controller-c6978f9f7-hjfvb -n kube-system
time="2019-04-25T02:40:45Z" level=info msg="Using TOML configuration file /config/traefik.toml"
time="2019-04-25T02:40:45Z" level=info msg="No tls.defaultCertificate given for https: using the first item in tls.certificates as a fallback."
time="2019-04-25T02:40:45Z" level=info msg="Traefik version v1.7.10 built on 2019-03-29_12:20:34PM"
time="2019-04-25T02:40:45Z" level=info msg="\nStats collection is disabled.\nHelp us improve Traefik by turning this feature on :)\nMore details on: https://docs.traefik.io/basics/#collected-data\n"
time="2019-04-25T02:40:45Z" level=info msg="Preparing server traefik &{Address::8080 TLS:<nil> Redirect:<nil> Auth:<nil> WhitelistSourceRange:[] WhiteList:<nil> Compress:false ProxyProtocol:<nil> ForwardedHeaders:0xc000735760} with readTimeout=0s writeTimeout=0s idleTimeout=3m0s"
time="2019-04-25T02:40:45Z" level=info msg="Preparing server http &{Address::80 TLS:<nil> Redirect:0xc000082340 Auth:<nil> WhitelistSourceRange:[] WhiteList:<nil> Compress:false ProxyProtocol:<nil> ForwardedHeaders:0xc000735780} with readTimeout=0s writeTimeout=0s idleTimeout=3m0s"
time="2019-04-25T02:40:45Z" level=info msg="Preparing server https &{Address::443 TLS:0xc00021d170 Redirect:<nil> Auth:<nil> WhitelistSourceRange:[] WhiteList:<nil> Compress:false ProxyProtocol:<nil> ForwardedHeaders:0xc000735740} with readTimeout=0s writeTimeout=0s idleTimeout=3m0s"
time="2019-04-25T02:40:45Z" level=info msg="Starting provider configuration.ProviderAggregator {}"
time="2019-04-25T02:40:45Z" level=info msg="Starting server on :8080"
time="2019-04-25T02:40:45Z" level=info msg="Starting server on :80"
time="2019-04-25T02:40:45Z" level=info msg="Starting server on :443"
time="2019-04-25T02:40:45Z" level=info msg="Starting provider *kubernetes.Provider {\"Watch\":true,\"Filename\":\"\",\"Constraints\":[],\"Trace\":false,\"TemplateVersion\":0,\"DebugLogGeneratedTemplate\":false,\"Endpoint\":\"\",\"Token\":\"\",\"CertAuthFilePath\":\"\",\"DisablePassHostHeaders\":false,\"EnablePassTLSCert\":false,\"Namespaces\":null,\"LabelSelector\":\"\",\"IngressClass\":\"\",\"IngressEndpoint\":null}"
time="2019-04-25T02:40:45Z" level=info msg="ingress label selector is: \"\""
time="2019-04-25T02:40:45Z" level=info msg="Creating in-cluster Provider client"
time="2019-04-25T02:40:46Z" level=info msg="Server configuration reloaded on :80"
time="2019-04-25T02:40:46Z" level=info msg="Server configuration reloaded on :443"
time="2019-04-25T02:40:46Z" level=info msg="Server configuration reloaded on :8080"
time="2019-04-25T02:40:48Z" level=info msg="Server configuration reloaded on :80"
time="2019-04-25T02:40:48Z" level=info msg="Server configuration reloaded on :443"
time="2019-04-25T02:40:48Z" level=info msg="Server configuration reloaded on :8080"
[[email protected] traefik]#

主要報錯是這條:

No tls.defaultCertificate given for https: using the first item in tls.certificates as a fallback

4.

學習traefik基礎知識,解決這個問題

traefik基礎篇有講過訪問得幾種方式,見下:

client --- (via http) ---> traefik ---- (via http) ---->? services
client --- (via https) ---> traefik ---- (via http) ---->? services
client --- (via https) ---> traefik ---- (via https) ---->? services

前面兩種都在基礎篇測試成功,dashboard是第三種.

這種方式非常復雜,有以下兩種情況。

第一種:
是ssl-termination的安全配置模型,即client與svc8的https通信分為“兩段”,client與traefik建立https連接後,traefik將client提交的加密請求解密後,
再向svc發起https請求,並重新加密請求數據.這種client端ssl的過程在反向代理或負載均衡器終結的https通信方式被稱為“ssl-termination”.

第二種:
ssl-passthrough的安全配置模型,即traefik不會對client的https request進行解密,而是直接轉發給svc服務,client端的ssl過程不會終結於traefik,
而是在svc對應的pod中終結.這種https通信方式被稱為”ssl-passthrough”.這種配置模型尤其適合service對client端進行client certificate驗證的情況.

無法訪問dashboard的原因是:
因為dashboard本身就是https的結構,自帶證書,無法通過自帶證書的檢查和認證.所以無法訪問dashboard.

解決方法:
在traefik.toml中加入條參數:

insecureSkipVerify = true ?

這條的意思是:禁止traefik對service後端證書檢查
修改後的配置文件見下:

[[email protected] config]# cat traefik.toml
insecureSkipVerify = true
defaultEntryPoints = ["http","https"]
[entryPoints]
? [entryPoints.http]
? address = ":80"
? ? [entryPoints.http.redirect]
? ? entryPoint = "https"
? [entryPoints.https]
? address = ":443"
? ? [entryPoints.https.tls]
? ? ? [[entryPoints.https.tls.certificates]]
? ? ? certFile = "/etc/kubernetes/cert/ca.pem"
? ? ? keyFile = "/etc/kubernetes/cert/ca-key.pem"
[[email protected] config]#

重新生成configmap

[[email protected] config]# kubectl delete cm traefik-conf -n kube-system
configmap "traefik-conf" deleted
[[email protected] config]# kubectl create configmap traefik-conf --from-file=traefik.toml -n kube-system
configmap "traefik-conf" created
[[email protected] config]#

重新部署traefik

[[email protected] traefik]# kubectl delete -f traefik-deployment.yaml
serviceaccount "traefik-ingress-controller" deleted
deployment.extensions "traefik-ingress-controller" deleted
service "traefik-ingress-service" deleted
[[email protected] traefik]# kubectl apply -f traefik-deployment.yaml
serviceaccount "traefik-ingress-controller" created
deployment.extensions "traefik-ingress-controller" created
service "traefik-ingress-service" created
[[email protected] traefik]#
[[email protected] traefik]# kubectl get pod -n kube-system
NAME? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?? READY? ?? STATUS? ? RESTARTS?? AGE
coredns-779ffd89bd-wmzhf? ? ? ? ? ? ? ? ? ?? 1/1? ? ?? Running?? 3? ? ? ? ? 1d
kubernetes-dashboard-65c76f6c97-m29nl? ? ? ? 1/1? ? ?? Running?? 2? ? ? ? ? 20h
traefik-ingress-controller-c6978f9f7-lkfss?? 1/1? ? ?? Running?? 0? ? ? ? ? 12s
traefik-ingress-controller-c6978f9f7-tsvrb?? 1/1? ? ?? Running?? 0? ? ? ? ? 12s
traefik-ingress-controller-c6978f9f7-xxz2w?? 1/1? ? ?? Running?? 0? ? ? ? ? 12s
[[email protected] traefik]#

再測試訪問dashboard,測試成功

技術分享圖片

5.

登陸dashboard

用部署時創建的sa:kubernetes-dashboard登陸
檢索它的token

[[email protected] traefik]# kubectl describe sa kubernetes-dashboard -n kube-system
Name:? ? ? ? ? ? ? ? kubernetes-dashboard
Namespace:? ? ? ? ?? kube-system
Labels:? ? ? ? ? ? ? k8s-app=kubernetes-dashboard
Annotations:? ? ? ?? kubectl.kubernetes.io/last-applied-configuration={"apiVersion":"v1","kind":"ServiceAccount","metadata":{"annotations":{},"labels":{"k8s-app":"kubernetes-dashboard"},"name":"kubernetes-dashboard","name...
Image pull secrets:? <none>
Mountable secrets:?? kubernetes-dashboard-token-82x7w
Tokens:? ? ? ? ? ? ? kubernetes-dashboard-token-82x7w
Events:? ? ? ? ? ? ? <none>

kubernetes-dashboard-token-82x7w?? kubernetes.io/service-account-token?? 3? ? ? ?? 20h
[[email protected] traefik]# kubectl describe secret kubernetes-dashboard-token-82x7w? -n kube-system
Name:? ? ? ?? kubernetes-dashboard-token-82x7w
Namespace:? ? kube-system
Labels:? ? ?? <none>
Annotations:? kubernetes.io/service-account.name=kubernetes-dashboard
? ? ? ? ? ? ? kubernetes.io/service-account.uid=b9900f44-665c-11e9-b233-000c291d7023

Type:? kubernetes.io/service-account-token

Data
====
ca.crt:? ?? 1338 bytes
namespace:? 11 bytes
token:? ? ? eyJhbGciOiJSUzI1NiIsImtpZCI6IiJ9.eyJpc3MiOiJrdWJlcm5ldGVzL3NlcnZpY2VhY2NvdW50Iiwia3ViZXJuZXRlcy5pby9zZXJ2aWNlYWNjb3VudC9uYW1lc3BhY2UiOiJrdWJlLXN5c3RlbSIsImt1YmVybmV0ZXMuaW8vc2VydmljZWFjY291bnQvc2VjcmV0Lm5hbWUiOiJrdWJlcm5ldGVzLWRhc2hib2FyZC10b2tlbi04Mng3dyIsImt1YmVybmV0ZXMuaW8vc2VydmljZWFjY291bnQvc2VydmljZS1hY2NvdW50Lm5hbWUiOiJrdWJlcm5ldGVzLWRhc2hib2FyZCIsImt1YmVybmV0ZXMuaW8vc2VydmljZWFjY291bnQvc2VydmljZS1hY2NvdW50LnVpZCI6ImI5OTAwZjQ0LTY2NWMtMTFlOS1iMjMzLTAwMGMyOTFkNzAyMyIsInN1YiI6InN5c3RlbTpzZXJ2aWNlYWNjb3VudDprdWJlLXN5c3RlbTprdWJlcm5ldGVzLWRhc2hib2FyZCJ9.Dml76hUlYVwCITgeui32CTGjyySfsmMzGQWwOHG-mDtrvsDTswu_KZbANcUL37XUAQeNycUNELavdGnvsZAfT8XmkwUU7VzvyCY3MKj1vRCrVGchiQ5KDoxJIJGieWm3GffLmo23BsysjbVPSR_jCSWCVkBYGhezb2TGN3E7rtOvsl0Zr8cw4o_BaA4KROtjB8yLsSNlbNP-mAsL5unpkbOPr2e5JH7FO1ZzJnczc7C0RFwAqVQ8oPGu8Kft1JrKBoL_HpjCutJy6rNiFelS27SfC0OShtsSn-ioGLSDsaxPYXhJKmmtYE0D6h5xUCqyG-gnne0UZVjXSU_AaMxaSw
[[email protected] traefik]#

token就是登陸需要輸入的.

6.

登陸成功,但是報錯很多,見下:

configmaps is forbidden: User "system:serviceaccount:kube-system:kubernetes-dashboard" cannot list resource "configmaps" in API group "" in the namespace "default"

persistentvolumeclaims is forbidden: User "system:serviceaccount:kube-system:kubernetes-dashboard" cannot list resource "persistentvolumeclaims" in API group "" in the namespace "default"

secrets is forbidden: User "system:serviceaccount:kube-system:kubernetes-dashboard" cannot list resource "secrets" in API group "" in the namespace "default"

services is forbidden: User "system:serviceaccount:kube-system:kubernetes-dashboard" cannot list resource "services" in API group "" in the namespace "default"

ingresses.extensions is forbidden: User "system:serviceaccount:kube-system:kubernetes-dashboard" cannot list resource "ingresses" in API group "extensions" in the namespace "default"

daemonsets.apps is forbidden: User "system:serviceaccount:kube-system:kubernetes-dashboard" cannot list resource "daemonsets" in API group "apps" in the namespace "default"

pods is forbidden: User "system:serviceaccount:kube-system:kubernetes-dashboard" cannot list resource "pods" in API group "" in the namespace "default"

events is forbidden: User "system:serviceaccount:kube-system:kubernetes-dashboard" cannot list resource "events" in API group "" in the namespace "default"

deployments.apps is forbidden: User "system:serviceaccount:kube-system:kubernetes-dashboard" cannot list resource "deployments" in API group "apps" in the namespace "default"

replicasets.apps is forbidden: User "system:serviceaccount:kube-system:kubernetes-dashboard" cannot list resource "replicasets" in API group "apps" in the namespace "default"

jobs.batch is forbidden: User "system:serviceaccount:kube-system:kubernetes-dashboard" cannot list resource "jobs" in API group "batch" in the namespace "default"

cronjobs.batch is forbidden: User "system:serviceaccount:kube-system:kubernetes-dashboard" cannot list resource "cronjobs" in API group "batch" in the namespace "default"

replicationcontrollers is forbidden: User "system:serviceaccount:kube-system:kubernetes-dashboard" cannot list resource "replicationcontrollers" in API group "" in the namespace "default"

statefulsets.apps is forbidden: User "system:serviceaccount:kube-system:kubernetes-dashboard" cannot list resource "statefulsets" in API group "apps" in the namespace "default"

rbac權限問題.

把sa:kubernetes-dashboard綁定cluster-admin權限

[[email protected] traefik]#? kubectl describe clusterroles cluster-admin
Name:? ? ? ?? cluster-admin
Labels:? ? ?? kubernetes.io/bootstrapping=rbac-defaults
Annotations:? rbac.authorization.kubernetes.io/autoupdate=true
PolicyRule:
? Resources? Non-Resource URLs? Resource Names? Verbs
? ---------? -----------------? --------------? -----
? *.*? ? ? ? []? ? ? ? ? ? ? ?? []? ? ? ? ? ? ? [*]
? ? ? ? ? ?? [*]? ? ? ? ? ? ? ? []? ? ? ? ? ? ? [*]
[[email protected] traefik]#
[[email protected] traefik]# cat kubernetes-dashboard-admin_clusterroles.yaml
apiVersion: rbac.authorization.k8s.io/v1beta1
kind: ClusterRoleBinding
metadata:
? name: kubernetes-dashboard
roleRef:
? apiGroup: rbac.authorization.k8s.io
? kind: ClusterRole
? name: cluster-admin
subjects:
- kind: ServiceAccount
? name: kubernetes-dashboard
? namespace: kube-system
[[email protected] traefik]#
[[email protected] traefik]# kubectl apply -f kubernetes-dashboard-admin_clusterroles.yaml
clusterrolebinding.rbac.authorization.k8s.io "kubernetes-dashboard" created

7.

重新登陸,一切正常.

技術分享圖片

8.

忽略chrome報錯,提高訪問速度

chrome打開訪問的時候,一直報一個錯誤

技術分享圖片

登陸進去也是非常卡頓.
這個報錯是可以忽略的.

鼠標右鍵點chrome的快捷方式選擇屬性

技術分享圖片

在目標這裏 ?後面加上

?--ignore-certificate-errors --allow-running-insecure-content

見下:

"C:\Program Files (x86)\Google\Chrome\Application\chrome.exe"? --ignore-certificate-errors --allow-running-insecure-content

這樣設置之後,訪問忽略了報錯,訪問速度也明顯快了好多.

k8s實踐14:dashboard部署訪問用戶權限一籮筐