kubenetes-dashboard

dashboard web ui

Posted by minicool on March 15, 2018

官方安装流程

1.优点 安装方便 2.缺点 没有暴露外网访问

kubectl create -f https://raw.githubusercontent.com/kubernetes/dashboard/master/src/deploy/recommended/kubernetes-dashboard.yaml

kubectl proxy

http://localhost:8001/api/v1/namespaces/kube-system/services/https:kubernetes-dashboard:/proxy/.

https://:/api/v1/namespaces/kube-system/services/https:kubernetes-dashboard:/proxy/

应用原理

官方提供的方法是使用kubectl proxy代理暴露apiserver,再通过apisercer proxy 访问node 中的 service进行直接访问。

  1. kubectl proxy runs on a user’s desktop or in a pod proxies from a localhost address to the Kubernetes apiserver client to proxy uses HTTP proxy to apiserver uses HTTPS locates apiserver adds authentication headers

本质上kubectl proxy为访问kubernetes apiserver的REST api充当反向代理角色,这里反向代理的作用与通常意义上的反向代理作用相同,比如提供统一入口进行访问控制、监控、管理,在代理中管理后端,在代理中进行认证等。当然可以不经过kubectl proxy反向代理直接访问kubernetes apiserver的REST api,但是需要手动管理kubernetes apiserver的地址、手动获取token、手动将token加请到请求的头部,相对来说要繁琐而已。

  1. apiserver proxy is a bastion built into the apiserver connects a user outside of the cluster to cluster IPs which otherwise might not be reachable runs in the apiserver processes client to proxy uses HTTPS (or http if apiserver so configured) proxy to target may use HTTP or HTTPS as chosen by proxy using available information can be used to reach a Node, Pod, or Service does load balancing when used to reach a Service

apiserver作为用户与kubernetes集群交互的接口,负责响应用户请求,与此同时,它本身也是一个访问集群内部资源的代理。例如,集群内有一个名为service_name的服务,端口号是port_name,这个服务本身具备集群IP,但是众所周知集群IP是一个虚拟IP,对于集群以外的世界来说,这个IP无法被识别。那么如何从外部世界访问这个服务呢?一种方法就是通过本节所介绍的apiserver proxy,当然前提条件是外界能够访问到apierver ,如果不能的话可以按第一节所介绍的kubectl proxy为apiserver设置反向代理,使它能够被外部世界访问。手动构建如下格式请求:

  1. server 路由原理 https:: http://apiserver address/api/v1/namespaces/namespace_name/services/service_name:[port_name]/proxy 在上例中,通过服务名称、服务端口号称、服务所属的名称空间,通过apiserver的代理实现对服务的访问,至于访问最终是如何路由到真正运行中的容器实例由kubernetes系统内部的机制实现。

例如:http://localhost:8001/api/v1/namespaces/default/services/http:test-traefik-dashboard:/proxy

helm 安装方法