1. 部署kube-ui环境
请参考 docker集群管理工具kubernetes初步搭建
2. 下载kube-ui镜像
# 目前好像docker.io上不支持下载。从国内的一个网站上下载
docker pull index.alauda.cn/googlecontainer/kube-ui:v5
# 然后把此image推到你的私有镜像地址
# 启动私有镜像容器
> docker run -d -p 5000:5000 --name siyou -v /data/docker/registry:/tmp/registry docker.io/registry
>docker tag 1270a664f530 1.1.1.100:5000/kube-ui
# 把1.1.1.100:5000/kube-ui推到 siyou
>docker push 1.1.1.100:5000/kube-ui
# 确认下镜像上传成功没,如果没有,后面的kube-ui会失败
> curl -X GET http://1.1.1.100:5000/v2/_catalog
{"repositories":["centos","kube-ui","memcached","mysql","nginx","pause","php"]}
3. 创建kube-ui namespace
# 创建kube-namespace.yaml,内容如下:
apiVersion: v1
kind: Namespace
metadata:
name: kube-system
# 创建namespace
> kubectl create -f kube-namespace.yaml
namespace "kube-system" created
> kubectl get namespace
NAME STATUS AGE
default Active 5d
kube-system Active 6m
4. 创建rc创建kube-ui-rc-src.yaml 文件
# kube-ui-rc
kind: Deployment
apiVersion: extensions/v1beta1
metadata:
labels:
app: kubernetes-dashboard
name: kubernetes-dashboard
namespace: kube-system
spec:
# 建立3个副本
replicas: 3
selector:
matchLabels:
app: kubernetes-dashboard
template:
metadata:
labels:
app: kubernetes-dashboard
spec:
containers:
- name: kubernetes-dashboard
# 填写自己私有镜像地址
image: 1.1.1.100:5000/kube-ui
imagePullPolicy: Always
ports:
- containerPort: 8080
protocol: TCP
args:
# Uncomment the following line to manually specify Kubernetes API server Host
# If not specified, Dashboard will attempt to auto discover the API server and connect
# to it. Uncomment only if the default does not work.
# - --apiserver-host=http://my-address:port
livenessProbe:
httpGet:
path: /
port: 8080
initialDelaySeconds: 30
timeoutSeconds: 30
# kube-ui-srv
---
kind: Service
apiVersion: v1
metadata:
labels:
app: kubernetes-dashboard
name: kubernetes-dashboard
namespace: kube-system
spec:
type: NodePort
ports:
- port: 80
targetPort: 8080
selector:
app: kubernetes-dashboard
- 配置参考:https://rawgit.com/kubernetes/dashboard/master/src/deploy/kubernetes-dashboard.yaml
# 运行一下命令创建rc和service,查看创建完成的pod(因设定了空间,查询时也要加上namespace,否则无法显示):kubectl get pod --namespace=kube-system
> kubectl create -f kube-ui.yaml
# 运行以下命令创建service,并查看service 和 pods
> kubectl get pod,rc --all-namespaces -o wide
NAMESPACE NAME READY STATUS RESTARTS AGE NODE
kube-system kubernetes-dashboard-3943700943-endp7 1/1 Running 0 2m 1.1.1.101
kube-system kubernetes-dashboard-3943700943-o60eg 0/1 ContainerCreating 0 2m 1.1.1.102
kube-system kubernetes-dashboard-3943700943-rk3yy 1/1 Running 0 2m 1.1.1.101
# 可以看到kube-ui服务正在运行,有两个副本分配到 101上了,一个在102上,但状态为 ContainerCreating
,我们分别去101和102上查看下:
> docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
75eb412a61d0 1.1.1.100:5000/kube-ui "/kube-ui" 2 minutes ago Up 2 minutes k8s_kubernetes-dashboard.d6579469_kubernetes-dashboard-3943700943-endp7_kube-system_f9bc4a36-8195-11e6-9113-000c294b72eb_5b4cbe1e
bdd31a94f4f7 1.1.1.100:5000/kube-ui "/kube-ui" 2 minutes ago Up 2 minutes k8s_kubernetes-dashboard.d6579469_kubernetes-dashboard-3943700943-rk3yy_kube-system_f9bb65a7-8195-11e6-9113-000c294b72eb_9a24d635
ff7417e55016 1.1.1.100:5000/pause:latest "/pause" 2 minutes ago Up 2 minutes k8s_POD.3dfbfbed_kubernetes-dashboard-3943700943-endp7_kube-system_f9bc4a36-8195-11e6-9113-000c294b72eb_7b727231
08421b2f531d 1.1.1.100:5000/pause:latest "/pause" 2 minutes ago Up 2 minutes k8s_POD.3dfbfbed_kubernetes-dashboard-3943700943-rk3yy_kube-system_f9bb65a7-8195-11e6-9113-000c294b72eb_1c4cae12
# 查看子网分配
> kubectl --namespace=kube-system get ep kubernetes-dashboard
NAME ENDPOINTS AGE
kubernetes-dashboard 10.1.37.2:8080,10.1.37.3:8080 19m
5. master配置flannel
# 配置flannel网络,与minion连通master安装flannel,并启动
>yum install flannel -y
>systemctl enable flanneld
>systemctl start flanneld
6. 访问kube-ui
# 访问 http://1.1.1.100:8080/ui/ 会自动跳转 http://1.1.1.100:8080/api/v1/proxy/namespaces/kube-system/services/kube-ui/#/dashboard/ 即可访问kube-ui的dashboard 页面,如下图所示:
可以查看minion的系统信息,pods,RC,services等信息
- 自此,kube-ui搭建成功,后续对其进行一些操作实战。。。