0%

kubernetes 安装配置 kube-ui

接上文:在centos7上安装和配置Kubernetes

下载kube-ui镜像并导入

谷歌的镜像地址被墙了,无法pull拉取镜像,只能手动下载。
在每个minion上导入镜像:

docker load  kube-ui_v3.tar

创建kube-system namespace

创建kube-system.json,内容如下:

# vim kube-system.json

{
"kind": "Namespace",
"apiVersion": "v1",
"metadata": {
"name": "kube-system"
}
}

运行以下命令创建namespace

# kubectl create -f kube-system.json
# kubectl get namespace
NAME LABELS STATUS
default none Active
kube-system none Active

创建rc

  1. 创建kube-ui-rc.yaml 文件,并写入一下内容
# vim kube-ui-rc.yaml

apiVersion: v1
kind: ReplicationController
metadata:
name: kube-ui-v3
namespace: kube-system
labels:
k8s-app: kube-ui
version: v3
kubernetes.io/cluster-service: "true"
spec:
replicas: 3
selector:
k8s-app: kube-ui
version: v3
template:
metadata:
labels:
k8s-app: kube-ui
version: v3
kubernetes.io/cluster-service: "true"
spec:
containers:
- name: kube-ui
image: gcr.io/google_containers/kube-ui:v3
resources:
limits:
cpu: 100m
memory: 50Mi
ports:
- containerPort: 8080
livenessProbe:
httpGet:
path: /
port: 8080
initialDelaySeconds: 30
timeoutSeconds: 5
  1. 运行一下命令创建rc,并查看
# kubectl create -f kube-ui-rc.yaml

#kubectl get rc --all-namespaces
NAMESPACE CONTROLLER CONTAINER(S) IMAGE(S) SELECTOR REPLICAS
kube-system kube-ui-v3 kube-ui gcr.io/google_containers/kube-ui:v3 k8s-app=kube-ui,version=v3 3

创建service

  1. 创建 kube-ui-svc.yaml 文件,并写入以下内容
# vim kube-ui-svc.yaml

apiVersion: v1
kind: Service
metadata:
name: kube-ui
namespace: kube-system
labels:
k8s-app: kube-ui
kubernetes.io/cluster-service: "true"
kubernetes.io/name: "KubeUI"
spec:
selector:
k8s-app: kube-ui
ports:
- port: 80
targetPort: 8080
  1. 运行以下命令创建service,并查看service 和 pods
# kubectl create -f kube-ui-svc.yaml
# kubectl get rc,pods --all-namespaces
NAMESPACE CONTROLLER CONTAINER(S) IMAGE(S) SELECTOR REPLICAS
kube-system kube-ui-v3 kube-ui gcr.io/google_containers/kube-ui:v3 k8s-app=kube-ui,version=v3 3
NAMESPACE NAME READY STATUS RESTARTS AGE
kube-system kube-ui-v3-0zyjp 1/1 Running 0 21h
kube-system kube-ui-v3-6s1d0 1/1 Running 0 21h
kube-system kube-ui-v3-i0uqs 1/1 Running 0 21h

可以看到kube-ui服务已经成功创建,运行3个副本

master配置flannel网络,与minion连通

  1. master安装flannel,并启动
# yum install flannel -y
# systemctl enable flanneld
# systemctl start flanneld
  1. 访问kube-ui

访问 http://master_ip:8080/ui/ 会自动跳转 http://kube-ui:8080/api/v1/proxy/namespaces/kube-system/services/kube-ui/#/dashboard/ 即可访问kube-ui的dashboard 页面,如下图所示:
image

可以查看minion的系统信息,pods,RC,services等信息

-------------本文结束感谢阅读-------------