在1.9k8s中 dashboard可以有两种访问方式

kubeconfig(HTTPS)和token(http)

2018-03-18

一、基于token的访问
1、下载官方的dashboard
wget https://raw.githubusercontent.com/kubernetes/dashboard/master/src/deploy/recommended/kubernetes-dashboard.yaml
2、编辑yaml文件
1)添加类型nodeport
spec:
type: NodePort
ports:
- port: 443
targetPort: 8443
selector:
2)修改镜像为自己可用的镜像
image: gcr.io/google_containers/kubernetes-dashboard-amd64:v1.8.3
3、创建pod
kubectl create -f kube-dashboard-admin.yaml

4、查看pod
kubectl get svc,pod --all-namespaces | grep dashboard
kube-system svc/kubernetes-dashboard NodePort 10.254.15.217 <none> 443:27446/TCP 19h
kube-system po/kubernetes-dashboard-cdc8db7d-7xnsw 1/1 Running 0 19h

5、创建RBAC
vim kube-dashboard-admin.yaml
---
apiVersion: v1
kind: ServiceAccount
metadata:
labels:
k8s-app: kubernetes-dashboard
name: kubernetes-dashboard-admin
namespace: kube-system
---
apiVersion: rbac.authorization.k8s.io/v1beta1
kind: ClusterRoleBinding
metadata:
name: kubernetes-dashboard-admin
labels:
k8s-app: kubernetes-dashboard
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: cluster-admin
subjects:
- kind: ServiceAccount
name: kubernetes-dashboard-admin
namespace: kube-system

6、修改deployment文件中的ServiceAccount名称
146 serviceAccountName: kubernetes-dashboard-admin
重启pod
kubectl apply -f kubernetes-dashboard.yaml -f kubernetes-dashboard-admin.rbac.yaml
7、查看RBAC的token登录UI界面时用
kubectl -n kube-system get secret | grep kubernetes-dashboard-admin

kubectl describe -n kube-system secret kubernetes-dashboard-admin-token-7ss4x

8、使用proxy暴露服务
kubectl proxy --address='192.168.11.70' --port=23455 --accept-hosts='^*$' &
9访问 192.168.11.70:2355/ui
访问dashboard后直接skip就可以了

二、利用token或是kubeconfig登录dashboard

首先:kubeconfig就是.kube/config文件
但是得手动的将token放到里面
1、wget下载dashboard
wget https://raw.githubusercontent.com/deauss2017/k8s/master/1.9/dashboard/yaml-file/admin-rbac.yaml
wget https://raw.githubusercontent.com/deauss2017/k8s/master/1.9/dashboard/yaml-file/kube-rbac.yaml
wget https://raw.githubusercontent.com/deauss2017/k8s/master/1.9/dashboard/yaml-file/kubernetes-dashboard.yaml
配置apiserver服务
wget https://raw.githubusercontent.com/deauss2017/k8s/master/1.9/heapster/yaml-file/kube-apiserver.service

2、修改master上的API
vim /etc/systemd/system/kube-apiserver.service

重启API
systemctl daemon-reload
systemctl restart kube-apiserver
systemctl status kube-apiserver

3、部署heapster服务
wget https://raw.githubusercontent.com/deauss2017/k8s/master/1.9/heapster/yaml-file/grafana.yaml
wget https://raw.githubusercontent.com/deauss2017/k8s/master/1.9/heapster/yaml-file/heapster-rbac.yaml
wget https://raw.githubusercontent.com/deauss2017/k8s/master/1.9/heapster/yaml-file/heapster.yaml
wget https://raw.githubusercontent.com/deauss2017/k8s/master/1.9/heapster/yaml-file/influxdb.yaml

按顺序创建
heapster-rbac.yaml>>>>> influxdb.yaml >>>>> heapster.yaml >>>>> grafana.yaml

注:在k8s中服务的域名是:
服务名.空间名.svc.cluster.local
例如:
monitoring-influxdb.kube-system.svc.cluster.local

# 部署dashboard 主yaml配置文件
kubectl create -f kubernetes-dashboard.yaml
kubectl create -f ui-admin-rbac.yaml
kubectl create -f ui-read-rbac.yaml
kubectl create -f admin-user-sa-rbac.yaml
3、验证
kubectl get pod -n kube-system | grep dashboard
kubectl get svc -n kube-system|grep dashboard
kubectl cluster-info|grep dashboard

4、修改apiserver配置
修改配置文件中的IP

basic-auth.csv设置dashboard密码登录
格式:密码,用户,ID号
例如:
admin123, admin, 2

重启master
5、登录
https://192.168.11.70:6443/ui
https://192.168.11.70:6443/api/v1/namespaces/kube-system/services/https:kubernetes-dashboard:/proxy/#!/ingress?namespace=default

使用token访问
kubectl -n kube-system describe secret $(kubectl -n kube-system get secret | grep admin-user | awk '{print $1}')

将token复制到对话框中点击登录
使用kubeconfig访问
上传config配置文件到Windows上
sz /root/.kube/config
将上边的token添加到config中

注:
1、apiserver中开启了RBAC认证,所以要锁RBAC
2、kubeconfig = ./kube/conf = kubernetes.pem要在config文件的最后添加token信息才能访问
3、修改API组件的配置文件 添加密码和用登录认证,开启CA认证,关闭匿名访问
--authorization-mode=Node,RBAC \ 开启RBAC认证
--anonymous-auth=false \ 关闭匿名访问
--basic-auth-file=/etc/kubernetes/ssl/basic-auth.csv \ 添加密码和用登录认证(密码,用户名,ID号)
4、访问方式一共有三种:
1)通过kubectl proxy访问
kubectl proxy --address='192.168.11.70' --port=23455 --accept-hosts='^*$' &
访问 192.168.11.70:2355/ui

2)通过API访问(密码+用户名+token(kubeconfig))
https://192.168.11.70:6443/ui
https://192.168.11.70:6443/api/v1/namespaces/kube-system/services/https:kubernetes-dashboard:/proxy/#!/login

参考文档:

主要https://github.com/gjmzj/kubeasz/blob/master/docs/guide/dashboard-1.8.2.md

https://blog.qikqiak.com/post/add-authorization-for-kubernetes-dashboard/

在1.9k8s中 dashboard可以有两种访问方式

kubeconfig(HTTPS)和token(http)

一、基于token的访问

1、下载官方的dashboard

wget https://raw.githubusercontent.com/kubernetes/dashboard/master/src/deploy/recommended/kubernetes-dashboard.yaml

2、编辑yaml文件

1)添加类型nodeport

spec:

type: NodePort

ports:

- port: 443

targetPort: 8443

selector:

2)修改镜像为自己可用的镜像

image: gcr.io/google_containers/kubernetes-dashboard-amd64:v1.8.3

3、创建pod

kubectl create -f kube-dashboard-admin.yaml

4、查看pod

kubectl get svc,pod --all-namespaces  | grep dashboard

kube-system   svc/kubernetes-dashboard   NodePort    10.254.15.217   <none>          443:27446/TCP   19h

kube-system   po/kubernetes-dashboard-cdc8db7d-7xnsw    1/1       Running   0          19h

5、创建RBAC

vim kube-dashboard-admin.yaml

---

apiVersion: v1

kind: ServiceAccount

metadata:

labels:

k8s-app: kubernetes-dashboard

name: kubernetes-dashboard-admin

namespace: kube-system

---

apiVersion: rbac.authorization.k8s.io/v1beta1

kind: ClusterRoleBinding

metadata:

name: kubernetes-dashboard-admin

labels:

k8s-app: kubernetes-dashboard

roleRef:

apiGroup: rbac.authorization.k8s.io

kind: ClusterRole

name: cluster-admin

subjects:

- kind: ServiceAccount

name: kubernetes-dashboard-admin

namespace: kube-system

6、修改deployment文件中的ServiceAccount名称

146  serviceAccountName: kubernetes-dashboard-admin

重启pod

kubectl apply -f kubernetes-dashboard.yaml -f kubernetes-dashboard-admin.rbac.yaml

7、查看RBAC的token登录UI界面时用

kubectl -n kube-system get secret | grep kubernetes-dashboard-admin

kubectl describe -n kube-system secret kubernetes-dashboard-admin-token-7ss4x

8、使用proxy暴露服务

kubectl proxy --address='192.168.11.70' --port=23455 --accept-hosts='^*$' &

9访问 192.168.11.70:2355/ui

访问dashboard后直接skip就可以了

利用token或是kubeconfig登录dashboard

参考文档:

https://github.com/gjmzj/kubeasz/blob/master/docs/guide/dashboard-1.8.2.md

https://jimmysong.io/posts/kubernetes-dashboard-upgrade/

首先:kubeconfig就是.kube/config文件

但是得手动的将token放到里面

1、wget下载dashboard

wget https://raw.githubusercontent.com/deauss2017/k8s/master/1.9/dashboard/yaml-file/admin-rbac.yaml

wget https://raw.githubusercontent.com/deauss2017/k8s/master/1.9/dashboard/yaml-file/kube-rbac.yaml

wget https://raw.githubusercontent.com/deauss2017/k8s/master/1.9/dashboard/yaml-file/kubernetes-dashboard.yaml

配置apiserver服务

wget https://raw.githubusercontent.com/deauss2017/k8s/master/1.9/heapster/yaml-file/kube-apiserver.service

2、修改master上的API

vim /etc/systemd/system/kube-apiserver.service

重启API

systemctl daemon-reload

systemctl restart kube-apiserver

systemctl status kube-apiserver

3、部署heapster服务

wget https://raw.githubusercontent.com/deauss2017/k8s/master/1.9/heapster/yaml-file/grafana.yaml

wget https://raw.githubusercontent.com/deauss2017/k8s/master/1.9/heapster/yaml-file/heapster-rbac.yaml

wget https://raw.githubusercontent.com/deauss2017/k8s/master/1.9/heapster/yaml-file/heapster.yaml

wget https://raw.githubusercontent.com/deauss2017/k8s/master/1.9/heapster/yaml-file/influxdb.yaml

按顺序创建

heapster-rbac.yaml>>>>> influxdb.yaml >>>>> heapster.yaml >>>>> grafana.yaml

注:在k8s中服务的域名是:

服务名.空间名.svc.cluster.local

例如:

monitoring-influxdb.kube-system.svc.cluster.local

# 部署dashboard 主yaml配置文件

kubectl create -f kubernetes-dashboard.yaml

kubectl create -f ui-admin-rbac.yaml

kubectl create -f ui-read-rbac.yaml

kubectl create -f admin-user-sa-rbac.yaml

3、验证

kubectl get pod -n kube-system | grep dashboard
kubectl get svc -n kube-system|grep dashboard
kubectl cluster-info|grep dashboard

4、修改apiserver配置

修改配置文件中的IP

basic-auth.csv设置dashboard密码登录

格式:密码,用户,ID号

例如:

admin123, admin, 2

重启master

5、登录

https://192.168.11.70:6443/ui

https://192.168.11.70:6443/api/v1/namespaces/kube-system/services/https:kubernetes-dashboard:/proxy/#!/ingress?namespace=default

使用token访问

kubectl -n kube-system describe secret $(kubectl -n kube-system get secret | grep admin-user | awk '{print $1}')

将token复制到对话框中点击登录

使用kubeconfig访问

上传config配置文件到Windows上

sz /root/.kube/config

将上边的token添加到config中

注:

1、apiserver中开启了RBAC认证,所以要锁RBAC

2、kubeconfig = ./kube/conf = kubernetes.pem要在config文件的最后添加token信息才能访问

3、修改API组件的配置文件 添加密码和用登录认证,开启CA认证,关闭匿名访问

--authorization-mode=Node,RBAC \                                                                开启RBAC认证

--anonymous-auth=false \                                                                                  关闭匿名访问

--basic-auth-file=/etc/kubernetes/ssl/basic-auth.csv \                          添加密码和用登录认证(密码,用户名,ID号)

4、访问方式:

1)通过kubectl  proxy访问

kubectl proxy --address='192.168.11.70' --port=23455 --accept-hosts='^*$' &

访问 192.168.11.70:2355/ui

2)通过API访问(密码+用户名+token(kubeconfig))

https://192.168.11.70:6443/ui

https://192.168.11.70:6443/api/v1/namespaces/kube-system/services/https:kubernetes-dashboard:/proxy/#!/login

kubernetes1.9中部署dashboard的更多相关文章

  1. K8S之部署Dashboard

    转载声明 本文转载自:ASP.NET Core on K8S深入学习(2)部署过程解析与部署Dashboard 1.Yaml安装 下载yaml文件 wget https://raw.githubuse ...

  2. 基于 kubeadm 搭建高可用的kubernetes 1.18.2 (k8s)集群 部署 dashboard 2.x

    1. 部署dashboard 2.x版本 Dashboard 分为 1.x版本 和 2.x版本, k8s 使用的是1.18.2 故部署2.x版本的 # dashboard 2.x版本的部署 # 上传d ...

  3. Kubernetes入门(四)——如何在Kubernetes中部署一个可对外服务的Tensorflow机器学习模型

    机器学习模型常用Docker部署,而如何对Docker部署的模型进行管理呢?工业界的解决方案是使用Kubernetes来管理.编排容器.Kubernetes的理论知识不是本文讨论的重点,这里不再赘述, ...

  4. kubernetes之部署dashboard 和heapster

    部署dashboard之前,先确保traefik https方式部署成功,这样就可以通过 https 域名的方式访问dashboard,无需kube-proxy转发了.假设traefik-ingres ...

  5. 不使用pvc的方式在K8S中部署apisix-gateway

    不使用pvc的方式在K8S中部署apisix-gateway 简介 我的apisix使用etcd作为数据存储服务器,官方的使用pvc方式或者docker-compose的方式,对于新手不太友好,本篇是 ...

  6. K8s 部署 Dashboard UI 仪表板 ——让一切可视化

    K8s 部署 Dashboard UI  仪表板   --让一切可视化 Dashboard 介绍 仪表板是基于Web的Kubernetes用户界面.您可以使用仪表板将容器化应用程序部署到Kuberne ...

  7. K8S中部署apisix(非ingress)

    不使用pvc的方式在K8S中部署apisix-gateway 简介 因为公司项目准备重构,现在做技术储备,之前公司项目使用的ocelot做网关,ocelot是.net平台下的一个网关,也是很不错,但是 ...

  8. 【续集】在 IIS 中部署 ASP.NET 5 应用程序遭遇的问题

    dudu 的一篇博文:在 IIS 中部署 ASP.NET 5 应用程序遭遇的问题 针对 IIS 部署 ASP.NET 5 应用程序的问题,在上面博文中主要采用两种方式尝试: VS2015 的 Publ ...

  9. Intellij IDEA 创建Web项目并在Tomcat中部署运行(不使用maven)【转载】

    原文链接:http://www.thinksaas.cn/topics/0/350/350000.html 一.创建Web项目 1.File -> New Module,进入创建项目窗口 2.选 ...

随机推荐

  1. ajax上传图片chrome报错net::ERR_CONNECTION_RESET/net::ERR_CONNECTION_ABORTED

    网上搜了一下,base64图片太大,tomcat对post请求大小有默认限制,要在tomcat配置文件server.xml 加一个:maxPostSize="0",0表示无限制 & ...

  2. C语言学习之插入排序

    此前的一些博文分别写了C语言中经典的排序方式,选择排序 冒泡排序 桶排序,此文就写 插入排序吧. 相对于冒泡排序,插入排序就比较方便快捷了.和冒泡 选择排序一样,插入排序也需要比较大小.可以这样理解插 ...

  3. 去掉chrome浏览器中input获得焦点时的带颜色边框呢

    可以设置表单控件的outline属性为none值, 来去掉Chrome浏览器中输入框以及其它表单控件获得焦点时的带颜色边框. css代码如下: input{outline:none}

  4. Yii2重置密码

    //Yii框架下hash密码正确的比较方法$result = Yii::$app->security->validatePassword($password, $hash);echo $r ...

  5. CodeForces-747C

    直接模拟就行,用一个数组保存某个server上次是在哪个task里面即可很方便判断它现在是否可用. AC代码: #include<cstdio> #include<cstring&g ...

  6. 两种实现方式mycat多租户,枚举分片,注解拦截

    第一种: 优点:支持进一步分片 缺点:schema配置繁琐 注解式  /*!mycat:schema=[schemaName] */   注意:这在navicat 里面是会报错的,请用命令行登陆myc ...

  7. nodejs爬虫初试---superagent和cheerio

    前言 早就听过爬虫,这几天开始学习nodejs,写了个爬虫 demo ,爬取 博客园首页的文章标题.用户名.阅读数.推荐数和用户头像,现做个小总结. 使用到这几个点: 1.node的核心模块-- 文件 ...

  8. Hive语法

    1.Select 语法 SELECT [ALL | DISTINCT] select_expr, select_expr, ... FROM table_reference [WHERE where_ ...

  9. FusionCharts封装-dataset和categories

    Chart.java: /** * @Title:Chart.java * @Package:com.fusionchart.model * @Description:FusionCharts 封装d ...

  10. 用Dw CS6运行静态页面出问题

    1.报错截图一 2.报错截图二