Kubernetest dashboard安装

kubernetes-dashboard是kubernetes的web UI图形管理界面,我们可以在页面中进行配置,管理,方便我们的操作。

必要条件

  • Kubernetes集群
  • 安装flannel网络

如果还没有安装kubernetes集群的同学请参考:kubernetes1.5.2集群搭建

集群角色如下,dashboard在Master上进行配置即可

192.168.1.40
Master
192.168.1.41
Node
192.168.1.42
Node

这里使用的dashboard镜像为:

docker.io/mritd/kubernetes-dashboard-amd64

开始安装dashboard

可以下载示例文件作为参考

git clone https://github.com/jdedu/kubernetes.git

创建ReplicationController

注意:需要指定apiserver地址

[root@uat-app01 ~]# vi /etc/k8s_yaml/kubernetes-dashboard-controller.yaml
apiVersion: v1
kind: ReplicationController
metadata:
  labels:
    app: kubernetes-dashboard
  name: kubernetes-dashboard
  namespace: kube-system
spec:
  replicas: 1
  selector:
    app: kubernetes-dashboard
  template:
    metadata:
      labels:
        app: kubernetes-dashboard
    spec:
      containers:
      - name: kubernetes-dashboard
        image: docker.io/mritd/kubernetes-dashboard-amd64  #指定镜像
        imagePullPolicy: Always
        ports:
        - containerPort: 9090
          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=192.168.1.40:9000   #指定apiserver地址
        livenessProbe:
          httpGet:
            path: /
            port: 9090
          initialDelaySeconds: 30
          timeoutSeconds: 30

创建Service

[root@uat-app01 ~]#  vi /etc/k8s_yaml/kubernetes-dashboard-service.yaml
kind: Service
apiVersion: v1
metadata:
  labels:
    app: kubernetes-dashboard
  name: kubernetes-dashboard
  namespace: kube-system
spec:
  type: NodePort
  ports:
  - port: 80
    targetPort: 9090
  selector:
    app: kubernetes-dashboard

创建ReplicationController,创建service

[root@uat-app01 ~]# kubectl create -f /etc/k8s_yaml/kubernetes-dashboard-controller.yaml
replicationcontroller "kubernetes-dashboard" created
[root@uat-app01 ~]# kubectl create -f /etc/k8s_yaml/kubernetes-dashboard-service.yaml
service "kubernetes-dashboard" created

查看pod状况

[root@uat-app01 k8s_yaml]# kubectl get pods --all-namespaces
NAMESPACE     NAME                         READY     STATUS              RESTARTS   AGE
default       frontend-3bv0p               1/1       Running             0          17h
default       frontend-kmth2               1/1       Running             0          17h
default       frontend-vltkp               1/1       Running             0          17h
default       redis-master-f59zp           1/1       Running             0          17h
default       redis-slave-6rxl8            1/1       Running             0          17h
default       redis-slave-j4jz0            1/1       Running             0          17h
kube-system   kubernetes-dashboard-5fnrk   0/1       ContainerCreating   0          10s

注意,这里不会马上启动,进行一段时间的检测,如果检测不通过,会重启

[root@uat-app01 k8s_yaml]# kubectl describe pod kubernetes-dashboard --namespace=kube-system
Name:		kubernetes-dashboard-5fnrk
Namespace:	kube-system
Node:		uat-app01.insightcredit/192.168.1.40
Start Time:	Thu, 21 Dec 2017 11:26:24 +0800
Labels:		app=kubernetes-dashboard
Status:		Running
IP:		10.0.63.2
Controllers:	ReplicationController/kubernetes-dashboard
Containers:
  kubernetes-dashboard:
    Container ID:	docker://3df93bfd23dc50247102904cf4579e4dd4ab2a910f2a6c37298191d806ca611c
    Image:		docker.io/mritd/kubernetes-dashboard-amd64
    Image ID:		docker-pullable://docker.io/mritd/kubernetes-dashboard-amd64@sha256:377d905c758d08674fd434e567fbfb4411f64a52090d0de7f64fd70b72b2fbeb
    Port:		9091/TCP
    Args:
      --apiserver-host=192.168.1.40:9090
    State:			Running
      Started:			Thu, 21 Dec 2017 14:34:59 +0800
    Last State:			Terminated
      Reason:			Error
      Exit Code:		2
      Started:			Thu, 21 Dec 2017 14:34:23 +0800
      Finished:			Thu, 21 Dec 2017 14:34:54 +0800
    Ready:			True
    Restart Count:		51
    Liveness:			http-get http://:9091/ delay=30s timeout=30s period=10s #success=1 #failure=3
    Volume Mounts:		<none>
    Environment Variables:	<none>
Conditions:
  Type		Status
  Initialized 	True 
  Ready 	True 
  PodScheduled 	True 
No volumes.
QoS Class:	BestEffort
Tolerations:	<none>
Events:
  FirstSeen	LastSeen	Count	From					SubObjectPath				Type		Reason		Message
  ---------	--------	-----	----					-------------				--------	------		-------
  2h	13s	52	{kubelet uat-app01.insightcredit}	spec.containers{kubernetes-dashboard}	Normal	Pulled			Successfully pulled image "docker.io/mritd/kubernetes-dashboard-amd64"
  2h		1m		52	{kubelet uat-app01.insightcredit}	spec.containers{kubernetes-dashboard}	Normal		Pulled			Successfully pulled image "docker.io/mritd/kubernetes-dashboard-amd64"
  2h		1m		43	{kubelet uat-app01.insightcredit}	spec.containers{kubernetes-dashboard}	Normal		Created			(events with common reason combined)
  2h		1m		43	{kubelet uat-app01.insightcredit}	spec.containers{kubernetes-dashboard}	Normal		Started			(events with common reason combined)
  2h		50s		54	{kubelet uat-app01.insightcredit}	spec.containers{kubernetes-dashboard}	Warning		Unhealthy		Liveness probe failed: Get http://10.0.63.2:9091/: dial tcp 10.0.63.2:9091: getsockopt: connection refused
  2h		50s		43	{kubelet uat-app01.insightcredit}	spec.containers{kubernetes-dashboard}	Normal		Killing			(events with common reason combined)
  2h		14s		563	{kubelet uat-app01.insightcredit}	spec.containers{kubernetes-dashboard}	Warning		BackOff			Back-off restarting failed docker container
  2h		14s		541	{kubelet uat-app01.insightcredit}						Warning		FailedSync		Error syncing pod, skipping: failed to "StartContainer" for "kubernetes-dashboard" with CrashLoopBackOff: "Back-off 5m0s restarting failed container=kubernetes-dashboard pod=kubernetes-dashboard-5fnrk_kube-system(b8ffc3d2-e5fe-11e7-8a9f-ee940baef0c1)"


最后检测成功,成功启动,在浏览器中输入http://192.168.1.40:9000/ui,就可以看到页面啦


然后就可以在页面上进行kubernetes的快速创建app、扩展应用了!


赶快试试吧~

赫墨拉

我是一个喜爱大数据的小菜鸡,这里是我分享我的成长和经历的博客

You may also like...

发表评论

邮箱地址不会被公开。