接上篇文章,在已經部署好Kubernetes的基礎上部署kubernetes dashboard,它是官方提供的用戶管理Kubernets集群可視化工具;部署dashboard其實和在kubernets部署其他的應用一樣,創建dashboard所需的Replication Controller、Se ...
接上篇文章,在已經部署好Kubernetes的基礎上部署kubernetes-dashboard,它是官方提供的用戶管理Kubernets集群可視化工具;部署dashboard其實和在kubernets部署其他的應用一樣,創建dashboard所需的Replication Controller、Service服務即可;
註意Kubernets的Overlay Network要正常工作,每個節點都已經啟動Flannel,並且docker啟動時配置了Flannel提供的子網,或使用其他方式保證Container之間的連通,否則dashboard將無法正常工作;
Namespace
使用預設的Namespace也是可以得,因為dashboard算是屬於系統應用所以這裡使用Namespace把dashboard與其他App進行隔離,建議線上正式的Kubernetes環境都要使用Namespace;
創建kube-namespace.yaml文件,內容如下:
apiVersion: v1
kind: Namespace
metadata:
name: kube-system
Replication Controller
Replication Controller用於保證pod期望狀態與當前狀態一致,還可對pod數量彈性伸縮,這裡主要是保證dashboard的正常運行;
創建kube-dashboard-rc.yaml文件:內容如下:
apiVersion: v1
kind: ReplicationController
metadata:
# Keep the name in sync with image version and
# gce/coreos/kube-manifests/addons/dashboard counterparts
name: kubernetes-dashboard-latest
namespace: kube-system
labels:
k8s-app: kubernetes-dashboard
version: latest
kubernetes.io/cluster-service: "true"
spec:
replicas: 1
selector:
k8s-app: kubernetes-dashboard
template:
metadata:
labels:
k8s-app: kubernetes-dashboard
version: latest
kubernetes.io/cluster-service: "true"
spec:
containers:
- name: kubernetes-dashboard
image: 192.168.2.144:5000/kkubernetes-dashboard-amd64
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.2.143:8080
livenessProbe:
httpGet:
path: /
port: 9090
initialDelaySeconds: 30
timeoutSeconds: 30
由於kubernetes-dashboard-amd64如要被牆,這裡下了index.alauda.cn/googlecontainer/kubernetes-dashboard-amd64放在本地私有倉庫,使用了本地私有長褲鏡像庫kubernetes-dashboard-amd64;還要註意別忘了配置apiserver-host否則dashboard將無法連接到kubernets集群;
Service
service用於配置dashboard的label selector;
創建kube-dashboard-svc.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
kubernates中創建dashboard應用
1、創建namespace
kubectl -s 192.168.2.143:8080 create -f namespace.yaml
2、創建replication Controller
kubectl -s 192.168.2.143:8080 create -f kube-dashboard-rc.yaml
3、創建service
kubectl -s 192.168.2.143:8080 create -f kube-dashboard-svc.yaml
查看dashboard啟動情況
Kubernetes dashboard訪問地址:http://192.168.2.143:8080/ui 註意這裡的地址是master節點的地址;
參考資料:
http://kubernetes.io/docs/user-guide/
文章首發地址:Solinx
http://www.solinx.co/archives/632