接上文:在centos7上安装和配置Kubernetes
下载kube-ui镜像并导入
谷歌的镜像地址被墙了,无法pull拉取镜像,只能手动下载。
在每个minion上导入镜像:
1
|
docker load kube-ui_v3.tar
|
创建kube-system namespace
创建kube-system.json,内容如下:
1
2
3
4
5
6
7
8
9
|
# vim kube-system.json
{
"kind": "Namespace",
"apiVersion": "v1",
"metadata": {
"name": "kube-system"
}
}
|
运行以下命令创建namespace
1
2
3
4
5
|
# kubectl create -f kube-system.json
# kubectl get namespace
NAME LABELS STATUS
default none Active
kube-system none Active
|
创建rc
- 创建kube-ui-rc.yaml 文件,并写入一下内容
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
|
# vim kube-ui-rc.yaml
apiVersion: v1
kind: ReplicationController
metadata:
name: kube-ui-v3
namespace: kube-system
labels:
k8s-app: kube-ui
version: v3
slug:.io/cluster-service: "true"
spec:
replicas: 3
selector:
k8s-app: kube-ui
version: v3
template:
metadata:
labels:
k8s-app: kube-ui
version: v3
slug:.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
|
- 运行一下命令创建rc,并查看
1
2
3
4
5
|
# 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
- 创建 kube-ui-svc.yaml 文件,并写入以下内容
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
|
# vim kube-ui-svc.yaml
apiVersion: v1
kind: Service
metadata:
name: kube-ui
namespace: kube-system
labels:
k8s-app: kube-ui
slug:.io/cluster-service: "true"
slug:.io/name: "KubeUI"
spec:
selector:
k8s-app: kube-ui
ports:
- port: 80
targetPort: 8080
|
- 运行以下命令创建service,并查看service 和 pods
1
2
3
4
5
6
7
8
|
# 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连通
- master安装flannel,并启动
1
2
3
|
# yum install flannel -y
# systemctl enable flanneld
# systemctl start flanneld
|
- 访问kube-ui
访问 http://master_ip:8080/ui/ 会自动跳转 http://kube-ui:8080/api/v1/proxy/namespaces/kube-system/services/kube-ui/#/dashboard/ 即可访问kube-ui的dashboard 页面,如下图所示:
可以查看minion的系统信息,pods,RC,services等信息