1、部署Kubernetes-dashboard

1.1 准备dashboard镜像

在10.4.7.200上操作

[root@hdss7-200 ~]# docker pull k8scn/kubernetes-dashboard-amd64:v1.8.3
[root@hdss7-200 ~]# docker images|grep dashboard
k8scn/kubernetes-dashboard-amd64 v1.8.3 fcac9aa03fd6 3 years ago 102MB
[root@hdss7-200 ~]# docker tag k8scn/kubernetes-dashboard-amd64:v1.8.3 harbor.od.com/public/dashboard:v1.8.3
[root@hdss7-200 ~]# docker push harbor.od.com/public/dashboard:v1.8.3

1.2 准备dashboard资源配置清单

[root@hdss7-200 ~]# mkdir /data/k8s-yaml/dashboard
[root@hdss7-200 ~]# cd /data/k8s-yaml/dashboard/

创建rbac.yaml

[root@hdss7-200 dashboard]# vim 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

[root@hdss7-200 dashboard]# vim 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:
# PLATFORM-SPECIFIC ARGS HERE
- --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"
imagePullSecrets:
- name: harbor

创建svc.yaml

[root@hdss7-200 dashboard]# vim 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

[root@hdss7-200 dashboard]# vim 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

2.3 依次创建资源

在任意一个运算节点操作

[root@hdss7-21 ~]# kubectl apply -f http://k8s-yaml.od.com/dashboard/rbac.yaml
serviceaccount/kubernetes-dashboard-admin created
clusterrolebinding.rbac.authorization.k8s.io/kubernetes-dashboard-admin created
[root@hdss7-21 ~]# kubectl apply -f http://k8s-yaml.od.com/dashboard/dp.yaml
deployment.apps/kubernetes-dashboard created
[root@hdss7-21 ~]# kubectl apply -f http://k8s-yaml.od.com/dashboard/svc.yaml
service/kubernetes-dashboard created
[root@hdss7-21 ~]# kubectl apply -f http://k8s-yaml.od.com/dashboard/ingress.yaml
ingress.extensions/kubernetes-dashboard created

2.4 查看资源

如下,dashboard资源均已被创建

查看pod
[root@hdss7-21 ~]# kubectl get pod -n kube-system|grep dashboard
kubernetes-dashboard-99ff79fcd-5f6pg 1/1 Running 0 2m45s
查看svc
[root@hdss7-21 ~]# kubectl get svc -n kube-system|grep dashboard
kubernetes-dashboard ClusterIP 192.168.250.65 <none> 443/TCP 3m18s
查看ingress
[root@hdss7-21 ~]# kubectl get ingress -n kube-system|grep dashboard
kubernetes-dashboard dashboard.od.com 80 3m23s

2、配置解析域名

在10.4.7.11上操作

[root@hdss7-11 ~]# vim /var/named/od.com.zone
$ORIGIN od.com.
$TTL 600 ; 10 minutes
@ IN SOA dns.od.com. dnsadmin.od.com. (
2020010505 ; 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
[root@hdss7-11 ~]# systemctl restart named
[root@hdss7-11 ~]# dig -t A dashboard.od.com @10.4.7.11 +short
10.4.7.10
运算节点解析
[root@hdss7-21 ~]# dig -t A dashboard.od.com @192.168.0.2 +short
10.4.7.10

3、配置反向代理认证

3.1 自签证书

在10.4.7.200上操作

[root@hdss7-200 certs]# (umask 007;openssl genrsa -out dashboard.od.com.key 2048)
Generating RSA private key, 2048 bit long modulus
..........................................................+++
..................................................................................................................................................................................................................+++
e is 65537 (0x10001)
[root@hdss7-200 certs]# [root@hdss7-200 certs]# openssl req -new -key dashboard.od.com.key -out dashboard.od.com.csr -subj "/CN=*.od.com/C=CN/ST=BeiJing/L=Beijing/O=od/OU=ops"
[root@hdss7-200 certs]# openssl x509 -req -in dashboard.od.com.csr -CA ca.pem -CAkey ca-key.pem -CAcreateserial -out dashboard.od.com.crt -days 3650
Signature ok
subject=/CN=*.od.com/C=CN/ST=BeiJing/L=Beijing/O=od/OU=ops
Getting CA Private Key
[root@hdss7-200 certs]# ls |grep dashboard
dashboard.od.com.crt
dashboard.od.com.csr
dashboard.od.com.key
[root@hdss7-200 certs]# cfssl-certinfo -cert dashboard.od.com.crt

3.2 拉取证书

在10.4.7.11/12上都要操作

[root@hdss7-11 ~]# mkdir /etc/nginx/certs/
[root@hdss7-11 ~]# cd /etc/nginx/certs/
[root@hdss7-11 certs]# scp root@10.4.7.200:/opt/certs/dashboard.od.com.key .
[root@hdss7-11 certs]# scp root@10.4.7.200:/opt/certs/dashboard.od.com.crt .

3.3 配置nginx代理,使用https

在10.4.7.11/12两台代理服务器上操作

[root@hdss7-11 ~]# vim /etc/nginx/conf.d/dashboard.conf
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;
}
}
[root@hdss7-11 certs]# nginx -t
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful
[root@hdss7-11 certs]# nginx -s reload

4、浏览器访问

尝试访问dashboard页面http://dashboard.od.com/

在运算节点上查看登录令牌token

[root@hdss7-21 ~]# kubectl get secret -n kube-system
NAME TYPE DATA AGE
coredns-token-xkclr kubernetes.io/service-account-token 3 3d22h
default-token-xqn4c kubernetes.io/service-account-token 3 10d
kubernetes-dashboard-admin-token-mhmvg kubernetes.io/service-account-token 3 10m
kubernetes-dashboard-key-holder Opaque 2 23h
traefik-ingress-controller-token-dr7cs kubernetes.io/service-account-token 3 31m
[root@hdss7-21 ~]# kubectl describe secret kubernetes-dashboard-admin-token-mhmvg -n kube-system
Name: kubernetes-dashboard-admin-token-mhmvg
Namespace: kube-system
Labels: <none>
Annotations: kubernetes.io/service-account.name: kubernetes-dashboard-admin
kubernetes.io/service-account.uid: d15809d2-ebb8-11eb-bb04-000c29e396b1 Type: kubernetes.io/service-account-token Data
====
ca.crt: 1346 bytes
namespace: 11 bytes
token: eyJhbGciOiJSUzI1NiIsImtpZCI6IiJ9.eyJpc3MiOiJrdWJlcm5ldGVzL3NlcnZpY2VhY2NvdW50Iiwia3ViZXJuZXRlcy5pby9zZXJ2aWNlYWNjb3VudC9uYW1lc3BhY2UiOiJrdWJlLXN5c3RlbSIsImt1YmVybmV0ZXMuaW8vc2VydmljZWFjY291bnQvc2VjcmV0Lm5hbWUiOiJrdWJlcm5ldGVzLWRhc2hib2FyZC1hZG1pbi10b2tlbi1taG12ZyIsImt1YmVybmV0ZXMuaW8vc2VydmljZWFjY291bnQvc2VydmljZS1hY2NvdW50Lm5hbWUiOiJrdWJlcm5ldGVzLWRhc2hib2FyZC1hZG1pbiIsImt1YmVybmV0ZXMuaW8vc2VydmljZWFjY291bnQvc2VydmljZS1hY2NvdW50LnVpZCI6ImQxNTgwOWQyLWViYjgtMTFlYi1iYjA0LTAwMGMyOWUzOTZiMSIsInN1YiI6InN5c3RlbTpzZXJ2aWNlYWNjb3VudDprdWJlLXN5c3RlbTprdWJlcm5ldGVzLWRhc2hib2FyZC1hZG1pbiJ9.Uc6nhJprnjerB4IaTxMlDwVv_fE_mFwyikAB7wA9ZLyIh79a_KDGS--bZu_L0tfoctb9cpn3nYrwfnkB5C6Iie-3DQTbRoygOptORvh5Q3HwBvkHUo54HK4ylFK7oukaZJW0Mer_5ZnWWdRPy764pOUGi3Cy3pYrv6dWX5ZCTEugjJmskLfwDfr8cWVEkH6qQwdTpVmZuX-RlgoVLI2ZnPjvtOPu_bUerZXLyC013RfcTvmN5rXrXOoNUBSNUIHaMEj4K9o5PtTMfK_H4PliK_4Tl-LASJu_zOCRuZZHHfqYvqTDr1tf03RrlTxcQJfuWgGa7kBrXF76lOdI7xwZoA

使用令牌登录就用上面的token信息就行

直接跳过就行了,如下是dashboard的页面详情

5、使用1.10.1版本镜像

在10.4.7.200服务器上

修改dp.yaml文件中的镜像(经常版本修改程1.10.1)

[root@hdss7-200 dashboard]# vim dp.yaml
image: harbor.od.com/public/dashboard:v1.10.1
保存退出
在任意运算节点上(10.4.7.21、22)
删除原来的deployment资源
[root@hdss7-21 ~]# kubectl delete -f http://k8s-yaml.od.com/dashboard/dp.yaml
deployment.apps "kubernetes-dashboard" deleted
创建新的deployment资源
[root@hdss7-21 ~]# kubectl apply -f http://k8s-yaml.od.com/dashboard/dp.yaml
deployment.apps/kubernetes-dashboard created
查看token
[root@hdss7-21 ~]# kubectl get secret -n kube-system
NAME TYPE DATA AGE
coredns-token-xkclr kubernetes.io/service-account-token 3 4d18h
default-token-xqn4c kubernetes.io/service-account-token 3 11d
kubernetes-dashboard-admin-token-mhmvg kubernetes.io/service-account-token 3 19h
kubernetes-dashboard-key-holder Opaque 2 42h
traefik-ingress-controller-token-dr7cs kubernetes.io/service-account-token 3 19h
[root@hdss7-21 ~]# kubectl describe secret kubernetes-dashboard-admin-token-mhmvg -n kube-system
Name: kubernetes-dashboard-admin-token-mhmvg
Namespace: kube-system
Labels: <none>
Annotations: kubernetes.io/service-account.name: kubernetes-dashboard-admin
kubernetes.io/service-account.uid: d15809d2-ebb8-11eb-bb04-000c29e396b1 Type: kubernetes.io/service-account-token Data
====
ca.crt: 1346 bytes
namespace: 11 bytes
token: eyJhbGciOiJSUzI1NiIsImtpZCI6IiJ9.eyJpc3MiOiJrdWJlcm5ldGVzL3NlcnZpY2VhY2NvdW50Iiwia3ViZXJuZXRlcy5pby9zZXJ2aWNlYWNjb3VudC9uYW1lc3BhY2UiOiJrdWJlLXN5c3RlbSIsImt1YmVybmV0ZXMuaW8vc2VydmljZWFjY291bnQvc2VjcmV0Lm5hbWUiOiJrdWJlcm5ldGVzLWRhc2hib2FyZC1hZG1pbi10b2tlbi1taG12ZyIsImt1YmVybmV0ZXMuaW8vc2VydmljZWFjY291bnQvc2VydmljZS1hY2NvdW50Lm5hbWUiOiJrdWJlcm5ldGVzLWRhc2hib2FyZC1hZG1pbiIsImt1YmVybmV0ZXMuaW8vc2VydmljZWFjY291bnQvc2VydmljZS1hY2NvdW50LnVpZCI6ImQxNTgwOWQyLWViYjgtMTFlYi1iYjA0LTAwMGMyOWUzOTZiMSIsInN1YiI6InN5c3RlbTpzZXJ2aWNlYWNjb3VudDprdWJlLXN5c3RlbTprdWJlcm5ldGVzLWRhc2hib2FyZC1hZG1pbiJ9.Uc6nhJprnjerB4IaTxMlDwVv_fE_mFwyikAB7wA9ZLyIh79a_KDGS--bZu_L0tfoctb9cpn3nYrwfnkB5C6Iie-3DQTbRoygOptORvh5Q3HwBvkHUo54HK4ylFK7oukaZJW0Mer_5ZnWWdRPy764pOUGi3Cy3pYrv6dWX5ZCTEugjJmskLfwDfr8cWVEkH6qQwdTpVmZuX-RlgoVLI2ZnPjvtOPu_bUerZXLyC013RfcTvmN5rXrXOoNUBSNUIHaMEj4K9o5PtTMfK_H4PliK_4Tl-LASJu_zOCRuZZHHfqYvqTDr1tf03RrlTxcQJfuWgGa7kBrXF76lOdI7xwZoA

访问新的dashboard页面,登录页面没有skip选项,必须要使用密码文件或者token令牌进行登录,增加了安全性

第十三章 k8s的GUI资源管理插件--dashboard的更多相关文章

  1. 6.kubernetes的GUI资源管理插件-dashboard

    目录 1.准备dashboard镜像 2.创建资源配置清单 3.应用资源配置清单 4.查看创建的资源 5.解析域名 6.浏览器访问 7.令牌命令行获取方式 准备dashboard镜像 [root@hd ...

  2. Gradle 1.12用户指南翻译——第五十三章. 签名插件

    其他章节的翻译请参见:http://blog.csdn.net/column/details/gradle-translation.html翻译项目请关注Github上的地址:https://gith ...

  3. Gradle 1.12用户指南翻译——第二十三章. Java 插件

    其他章节的翻译请参见: http://blog.csdn.net/column/details/gradle-translation.html 翻译项目请关注Github上的地址: https://g ...

  4. Gradle 1.12用户指南翻译——第三十三章. PMD 插件

    本文由CSDN博客万一博主翻译,其他章节的翻译请参见: http://blog.csdn.net/column/details/gradle-translation.html 翻译项目请关注Githu ...

  5. Gradle 1.12用户指南翻译——第四十三章. 构建公告插件

    本文由CSDN博客貌似掉线翻译,其他章节的翻译请参见: http://blog.csdn.net/column/details/gradle-translation.html 翻译项目请关注Githu ...

  6. Gradle 1.12 翻译——第十三章 编写构建脚本

    有关其它已翻译的章节请关注Github上的项目:https://github.com/msdx/gradledoc/tree/1.12,或訪问:http://gradledoc.qiniudn.com ...

  7. PMBOK(第六版) PMP笔记——《十三》第十三章(项目干系人管理)

    PMBOK(第六版) PMP笔记——<十三>第十三章(项目干系人管理) 第十三章 项目干系人管理: 了解干系人的需要和期望.解决实际发生的问题.管理利益冲突.促进干系人合理参与 项目决策和 ...

  8. CentOS7安装CDH 第十三章:CDH资源池配置

    相关文章链接 CentOS7安装CDH 第一章:CentOS7系统安装 CentOS7安装CDH 第二章:CentOS7各个软件安装和启动 CentOS7安装CDH 第三章:CDH中的问题和解决方法 ...

  9. 【C++】《C++ Primer 》第十三章

    第十三章 拷贝控制 定义一个类时,需要显式或隐式地指定在此类型地对象拷贝.移动.赋值和销毁时做什么. 一个类通过定义五种特殊的成员函数来控制这些操作.即拷贝构造函数(copy constructor) ...

随机推荐

  1. 【RocketMQ】消息的拉取

    RocketMQ消息的消费以组为单位,有两种消费模式: 广播模式:同一个消息队列可以分配给组内的每个消费者,每条消息可以被组内的消费者进行消费. 集群模式:同一个消费组下,一个消息队列同一时间只能分配 ...

  2. 2022-07-14 第六组 润土 Java02学习笔记

    1.引用数据类型 Scanner类: Scanner shuru=new Scanner(System.in); int a=shuru.nextInt();//输入整型 String b= shur ...

  3. 初学者对html的认知

    首先是关于本人对一个新事物的理解路线 对html的认知: what:首先我得知道它是什么?html是一门超文本标记语言,它不是一门编程语言 why:它为什么会存在?它存在的意义是什么?随着互联网的发展 ...

  4. Gorgerous -「歌词」留言板

    歌者,献祭「心声」,以沐浴「新生」. Oh love. How I miss you every single days when I see you on those streets. Oh lov ...

  5. 如何在Excel/WPS表格中批量查询快递信息?

    如何在Excel/WPS表格中批量查询快递信息? 干电商的小伙伴们还在为如何批量查询快递物流信息发愁吗?别着急,这篇文章或许能够帮助到您. 首先给大家看一下查询的具体成果: 第一步:安装Excel网络 ...

  6. 如何在CentOS上找出逐渐耗尽磁盘空间的目录和文件

    起因 随着系统运行,CentOS空间不断减少,对此非常焦虑,到底磁盘空间被哪些新增文件占用了呢? 分析过程,主要使用du命令,逐层找出消耗空间的目录 1.在根目录下检索一下文件的占用情况,执行du命令 ...

  7. OpenMP入门

    OpenMP入门 前情提要:并行(parallel):需要多个运算核心同时完成 其中有多处理器和单处理器多核两种实现方式,其中差异如下: 同一芯片上的多核通信速度更快 同一芯片上的多核能耗更低 Ope ...

  8. 叫高二上一调?简要题解 (ACD)

    A. 电压机制 题意转换为所有奇环的并排除掉所有偶环留下的边的个数 . 建出 DFS 树,然后只有返祖边可能构成环 . 于是类似树上差分,\(odd_u\) 统计奇环,\(even_u\) 统计偶环 ...

  9. 技术分享 | 测试git上2500星的闪回小工具

    GreatSQL社区原创内容未经授权不得随意使用,转载请联系小编并注明来源. 1.实验环境 2.软件下载 3.开始测试 4.附参数说明 生产上发生误删数据或者误更新数据的事故时,传统恢复方法是利用备份 ...

  10. 正则表达式实战:最新豆瓣top250爬虫超详细教程

    检查网页源代码 首先让我们来检查豆瓣top250的源代码,一切网页爬虫都需要从这里开始.F12打开开发者模式,在元素(element)页面通过Ctrl+F直接搜索你想要爬取的内容,然后就可以开始编写正 ...