kubernetes-dashboard

时间:Nov. 5, 2017 分类:

目录:

kubernetes-dashboard

我使用的镜像是

mritd/kubernetes-dashboard-amd64

rc配置

[root@why-01 ~]# 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=140.143.187.188:8080
        livenessProbe:
          httpGet:
            path: /
            port: 9090
          initialDelaySeconds: 30
          timeoutSeconds: 30

service配置

[root@why-01 ~]# 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: 9090
    nodePort: 30002
  selector:
    app: kubernetes-dashboard

创建rc和service

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

查看一下描述

[root@why-01 ~]# kubectl describe pod kubernetes-dashboard --namespace='kube-system'
Name:       kubernetes-dashboard-c0800
Namespace:  kube-system
Node:       why-03/10.181.5.146
Start Time: Wed, 25 Oct 2017 14:53:54 +0800
Labels:     app=kubernetes-dashboard
Status:     Running
IP:     10.1.45.3
Controllers:    ReplicationController/kubernetes-dashboard
Containers:
  kubernetes-dashboard:
    Container ID:   docker://2ff3c74c566d657c3142f9134f72db2375b38ff237d9d3414cb3f0f8f6df326e
    Image:      docker.io/mritd/kubernetes-dashboard-amd64
    Image ID:       docker-pullable://docker.io/mritd/kubernetes-dashboard-amd64@sha256:377d905c758d08674fd434e567fbfb4411f64a52090d0de7f64fd70b72b2fbeb
    Port:       9090/TCP
    Args:
      --apiserver-host=140.143.187.188:8080
    State:          Running
      Started:          Wed, 25 Oct 2017 14:54:00 +0800
    Ready:          True
    Restart Count:      0
    Liveness:           http-get http://:9090/ 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
  --------- --------    -----   ----            -------------               --------    ------          -------
  29m       29m     1   {default-scheduler }                        Normal      Scheduled       Successfully assigned kubernetes-dashboard-c0800 to why-03
  29m       29m     1   {kubelet why-03}    spec.containers{kubernetes-dashboard}   Normal      Pulling         pulling image "docker.io/mritd/kubernetes-dashboard-amd64"
  29m       29m     2   {kubelet why-03}                        Warning     MissingClusterDNS   kubelet does not have ClusterDNS IP configured and cannot create Pod using "ClusterFirst" policy. Falling back to DNSDefault policy.
  29m       29m     1   {kubelet why-03}    spec.containers{kubernetes-dashboard}   Normal      Pulled          Successfully pulled image "docker.io/mritd/kubernetes-dashboard-amd64"
  29m       29m     1   {kubelet why-03}    spec.containers{kubernetes-dashboard}   Normal      Created         Created container with docker id 2ff3c74c566d; Security:[seccomp=unconfined]
  29m       29m     1   {kubelet why-03}    spec.containers{kubernetes-dashboard}   Normal      Started         Started container with docker id 2ff3c74c566d

--namespace='kube-system'指定namespace,使用--all-namespaces是不行的

[root@why-01 ~]# kubectl describe pod kubernetes-dashboard --all-namespaces
error: a resource cannot be retrieved by name across all namespaces

不过如果直接获取的时候可以

[root@why-01 ~]# kubectl get pod --all-namespaces
NAMESPACE     NAME                         READY     STATUS    RESTARTS   AGE
default       frontend-0rzd1               1/1       Running   0          5d
default       frontend-l8bpq               1/1       Running   0          5d
default       frontend-sk1wm               1/1       Running   0          5d
default       redis-master-8g9zf           1/1       Running   0          5d
default       redis-slave-4k60b            1/1       Running   0          5d
default       redis-slave-x8tvb            1/1       Running   0          5d
kube-system   kubernetes-dashboard-c0800   1/1       Running   0          1h
[root@why-01 ~]# kubectl get service --all-namespaces
NAMESPACE     NAME                   CLUSTER-IP       EXTERNAL-IP   PORT(S)          AGE
default       frontend               10.254.44.223    <nodes>       80:30001/TCP     6d
default       kubernetes             10.254.0.1       <none>        443/TCP          7d
default       redis-master           10.254.69.157    <none>        6379/TCP         6d
default       redis-slave            10.254.195.218   <none>        6379/TCP         6d
kube-system   kubernetes-dashboard   10.254.53.115    <nodes>       9090:30002/TCP   1h
[root@why-01 ~]# kubectl get rc --all-namespaces
NAMESPACE     NAME                   DESIRED   CURRENT   READY     AGE
default       frontend               3         3         3         6d
default       redis-master           1         1         1         6d
default       redis-slave            2         2         2         6d
kube-system   kubernetes-dashboard   1         1         1         1h

如果检测没通过

  2m        2m      1   {kubelet why-03}    spec.containers{kubernetes-dashboard}   Normal      Killing     Killing container with docker id 0c4e5188b67d: pod "kubernetes-dashboard-fhzcf_kube-system(43187744-b8ba-11e7-b8d0-5254006db97b)" container "kubernetes-dashboard" is unhealthy, it will be killed and re-created.
  2m        2m      1   {kubelet why-03}    spec.containers{kubernetes-dashboard}   Normal      Created     Created container with docker id 65ea1c7df1af; Security:[seccomp=unconfined]
  2m        2m      1   {kubelet why-03}    spec.containers{kubernetes-dashboard}   Normal      Started     Started container with docker id 65ea1c7df1af
  1m        1m      1   {kubelet why-03}    spec.containers{kubernetes-dashboard}   Normal      Killing     Killing container with docker id 65ea1c7df1af: pod "kubernetes-dashboard-fhzcf_kube-system(43187744-b8ba-11e7-b8d0-5254006db97b)" container "kubernetes-dashboard" is unhealthy, it will be killed and re-created.
  5m        1m      8   {kubelet why-03}    spec.containers{kubernetes-dashboard}   Warning     Unhealthy   Liveness probe failed: Get http://10.1.45.3:90/: dial tcp 10.1.45.3:90: getsockopt: connection refused
  1m        31s     8   {kubelet why-03}                        Warning     FailedSync  Error syncing pod, skipping: failed to "StartContainer" for "kubernetes-dashboard" with CrashLoopBackOff: "Back-off 1m20s restarting failed container=kubernetes-dashboard pod=kubernetes-dashboard-fhzcf_kube-system(43187744-b8ba-11e7-b8d0-5254006db97b)"

  1m    31s 8   {kubelet why-03}    spec.containers{kubernetes-dashboard}   Warning BackOff         Back-off restarting failed docker container
  6m    18s 7   {kubelet why-03}    spec.containers{kubernetes-dashboard}   Normal  Pulling         pulling image "docker.io/mritd/kubernetes-dashboard-amd64"
  6m    13s 8   {kubelet why-03}                        Warning MissingClusterDNS   kubelet does not have ClusterDNS IP configured and cannot create Pod using "ClusterFirst" policy. Falling back to DNSDefault policy.
  6m    13s 7   {kubelet why-03}    spec.containers{kubernetes-dashboard}   Normal  Pulled          Successfully pulled image "docker.io/mritd/kubernetes-dashboard-amd64"
  12s   12s 1   {kubelet why-03}    spec.containers{kubernetes-dashboard}   Normal  Created         Created container with docker id 24eb133e022c; Security:[seccomp=unconfined]
  12s   12s 1   {kubelet why-03}    spec.containers{kubernetes-dashboard}   Normal  Started         Started container with docker id 24eb133e022c

可以看到会重复的进行重启。

访问30002端口

dashboard支持的修改service和pod配置,查看pod日志

根据yaml或直接配置创建k8s服务。