1.kubernetes的GUI资源管理插件-仪表盘
hdss7-200上下载dashboard镜像
[root@hdss7-200 ~]
[root@hdss7-200 ~]
[root@hdss7-200 ~]
[root@hdss7-200 ~]
在hdss7-200.host.com上创建资源配置清单
[root@hdss7-200 ~]
rbac.yaml
apiVersion: v1
kind: ServiceAccount
metadata:
labels:
k8s-app: kubernetes-dashboard
addonmanager.kubernetes.io/mode: Reconcile
name: kubernetes-dashboard-admin
namespace: kube-system
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
name: kubernetes-dashboard-admin
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-admin
namespace: kube-system
dp.yaml
apiVersion: apps/v1
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:
priorityClassName: system-cluster-critical
containers:
- name: kubernetes-dashboard
image: harbor.od.com/public/dashboard:v1.8.3
resources:
limits:
cpu: 100m
memory: 300Mi
requests:
cpu: 50m
memory: 100Mi
ports:
- containerPort: 8443
protocol: TCP
args:
- --auto-generate-certificates
volumeMounts:
- name: tmp-volume
mountPath: /tmp
livenessProbe:
httpGet:
scheme: HTTPS
path: /
port: 8443
initialDelaySeconds: 30
timeoutSeconds: 30
volumes:
- name: tmp-volume
emptyDir: {}
serviceAccountName: kubernetes-dashboard-admin
tolerations:
- key: "CriticalAddonsOnly"
operator: "Exists"
svc.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:
selector:
k8s-app: kubernetes-dashboard
ports:
- port: 443
targetPort: 8443
ingress.yaml
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: kubernetes-dashboard
namespace: kube-system
annotations:
kubernetes.io/ingress.class: traefik
spec:
rules:
- host: dashboard.od.com
http:
paths:
- backend:
serviceName: kubernetes-dashboard
servicePort: 443
hdss7-21上应用资源配置清单
[root@hdss7-21 containers]
[root@hdss7-21 containers]
[root@hdss7-21 containers]
[root@hdss7-21 containers]
查看创建的资源
[root@hdss7-21 containers]
[root@hdss7-21 containers]
[root@hdss7-21 containers]
出现CrashLoopBackOff kubernetes(k8s)创建Dashboard失败,Dashboard的pod状态为CrashLoopBackOff 解决方法 解析域名
[root@hdss7-11 ~]
$ORIGIN od.com.
$TTL 600 ; 10 minutes
@ IN SOA dns.od.com. dnsadmin.od.com. (
2021123105 ; serial
10800 ; refresh (3 hours)
900 ; retry (15 minutes)
604800 ; expire (1 week)
86400 ; minimum (1 day)
)
NS dns.od.com.
$TTL 60 ; 1 minute
dns A 10.4.7.11
harbor A 10.4.7.200
k8s-yaml A 10.4.7.200
traefik A 10.4.7.10
dashboard A 10.4.7.10
浏览器访问
http://dashboard.od.com/
hdss7-200上执行生成dashboard证书
[root@hdss7-200 ~]
[root@hdss7-200 certs]
[root@hdss7-200 certs]
[root@hdss7-200 certs]
将生成的dashboard证书复制相对应的主机 分别在11和12上执行
~]
~]
certs]
certs]
为域名提供nginx的证书配置文件 分别在11、12执行如下命令
~]
server {
listen 80;
server_name dashboard.od.com;
rewrite ^(.*)\$ https://\${server_name}\$1 permanent;
}
server {
listen 443 ssl;
server_name dashboard.od.com;
ssl_certificate "certs/dashboard.od.com.crt";
ssl_certificate_key "certs/dashboard.od.com.key";
ssl_session_cache shared:SSL:1m;
ssl_session_timeout 10m;
ssl_ciphers HIGH:!aNULL:!MD5;
ssl_prefer_server_ciphers on;
location / {
proxy_pass http://default_backend_traefik;
proxy_set_header Host \$http_host;
proxy_set_header x-forwarded-for \$proxy_add_x_forwarded_for;
}
}
分别重启11和12的nginx服务
~]
~]
访问域名dashboard.od.com 查看dashboard的token 令牌命令行获取方式
kubernetes-dashboard的pod镜像成功运行后,会由kuberneter-dashboard-admin服务帐号自动生成secret,查看secret得到token就可以登录 一个服务帐号,它一定会对应着一个惟一的有服务帐号的secret 在master节点(21、22)任意一台执行
[root@hdss7-21 ~]
[root@hdss7-21 ~]
使用查询到的token登录dashboard
|