1、Kubernetes Dashboard UI 配置实战
Kubernetes 实现的最重要的工作是对 Docker 容器集群统一的管 理和调度,通常使用命令行来操作 Kubernetes 集群及各个节点,命 令行操作非常不方便。
如果使用 UI 界面来可视化操作,会更加方便的管理和维护。如下
为配置 kubernetes dashboard 完整过程:
在 Node 节点提前导入两个列表镜像(从云盘下载即可):
pod-infrastructure
kubernetes-dashboard-amd64
Docker 镜像导入指令如下:
docker load <pod-infrastructure.tgz,将导入的 pod 镜像名称
修改,命令如下:
docker tag $(docker images|grep none|awk '{print $3}')
registry.access.redhat.com/rhel7/pod-infrastructure
docker load <kubernetes-dashboard-amd64.tgz,将导入的 pod
镜像名称修改,命令如下:
docker tag $(docker images|grep none|awk '{print $3}')
bestwu/kubernetes-dashboard-amd64:v1.6.3
然后在 Master 端,创建 dashboard-controller.yaml,代码如下:
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
name: kubernetes-dashboard
namespace: kube-system
labels:
k8s-app: kubernetes-dashboard
kubernetes.io/cluster-service: "true"
spec:
selector:
matchLabels:
k8s-app: kubernetes-dashboard
template:
metadata:
labels:
k8s-app: kubernetes-dashboard
annotations:
scheduler.alpha.kubernetes.io/critical-pod: ''
scheduler.alpha.kubernetes.io/tolerations:
'[{"key":"CriticalAddonsOnly", "operator":"Exists"}]'
spec:
containers:
- name: kubernetes-dashboard
image: bestwu/kubernetes-dashboard-amd64:v1.6.3
resources:
#keep request = limit to keep this container in guaranteed class
limits:
cpu: 100m
memory: 50Mi
requests:
cpu: 100m
memory: 50Mi
ports:
- containerPort: 9090
args:
- --apiserver-host=http://192.168.0.105:8080
livenessProbe:
httpGet:
path: /
port: 9090
initialDelaySeconds: 30
timeoutSeconds: 30
创建 dashboard-service.yaml,代码如下:
apiVersion: v1
kind: Service
metadata:
name: kubernetes-dashboard
namespace: kube-system
labels:
k8s-app: kubernetes-dashboard
kubernetes.io/cluster-service: "true"
spec:
selector:
k8s-app: kubernetes-dashboard
ports:
- port: 80
targetPort: 9090
创建 dashboard dashborad pods 模块:
kubectl create -f dashboard-controller.yaml
kubectl create -f dashboard-service.yaml
initialDelaySeconds: 30
timeoutSeconds: 30
创建 dashboard-service.yaml,代码如下:
apiVersion: v1
kind: Service
metadata:
name: kubernetes-dashboard
namespace: kube-system
labels:
k8s-app: kubernetes-dashboard
kubernetes.io/cluster-service: "true"
spec:
selector:
k8s-app: kubernetes-dashboard
ports:
- port: 80
targetPort: 9090
创建 dashboard dashborad pods 模块:
kubectl create -f dashboard-controller.yaml
kubectl create -f dashboard-service.yaml
创建完成后,查看 Pods 和 Service 的详细信息:
kubectl get namespace
kubectl get deployment --all-namespaces
kubectl get svc --all-namespaces
kubectl get pods --all-namespaces
kubectl get pod -o wide --all-namespaces
kubectl describe service/kubernetes-dashboard
--namespace="kube-system"
kubectl describe
pod/kubernetes-dashboard-530803917-816df
--namespace="kube-system"
通过浏览器访问:http://192.168.0.105:8080/,如图所示: