我是靠谱客的博主 傲娇电话,最近开发中收集的这篇文章主要介绍kubenetes-dashboard 实践,觉得挺不错的,现在分享给大家,希望可以做个参考。

概述

本文出自 “Elephant” 博客,请务必保留此出处http://zlyang.blog.51cto.com/1196234/1953399 根据个人情况,做了修改


一、先决条件


  1、首先你必有现成的Kubernetes集群,如果现在你一无所有,请参考:

  http://zlyang.blog.51cto.com/1196234/1951010

  2、建议采用etcd集群,搭建过程请参考:

  http://zlyang.blog.51cto.com/1196234/1951164


二、部署Kubernetes-dashboard

  

  [所有机器:Master、Node1、Node2]

  1、安装flannel(flannel为管理Containers网络)

  [root@k8s-master ~]# yum -y install epel-release flannel


  2、配置flanel


  [Master]

  [root@k8s-master ~]# vim /etc/sysconfig/flanneld

# Flanneld configuration options  


# etcd url location.  Point this to the server where etcd runs

FLANNEL_ETCD_ENDPOINTS="http://k8s-master:2379"


# etcd config key.  This is the configuration key that flannel queries

# For address range assignment

FLANNEL_ETCD_PREFIX="/atomic.io/network"


# Any additional options that you want to pass

#FLANNEL_OPTIONS=""


  [Node]

    [root@k8s-node1 ~]# vim /etc/sysconfig/flanneld

# Flanneld configuration options  


# etcd url location.  Point this to the server where etcd runs

FLANNEL_ETCD_ENDPOINTS="http://k8s-master:2379"


# etcd config key.  This is the configuration key that flannel queries

# For address range assignment

FLANNEL_ETCD_PREFIX="/atomic.io/network"


# Any additional options that you want to pass

#FLANNEL_OPTIONS=""


  3、添加Etcd网络配置

  [Master]

  [root@k8s-master ~]# mkdir -p /atomic.io/network/

  [root@k8s-master ~]# chmod -R 777 /atomic.io

  [root@k8s-master ~]# etcdctl mk /atomic.io/network/config '{"Network":"10.254.0.0/16"}'

   ****** 注:此IP为/etc/kubernetes/apiserver中{KUBE_SERVICE_ADDRESSES="--service-cluster-ip-range=10.254.0.0/16" }填写的地址


  4、启动flannel服务

  [所有机器]

  [root@k8s-master ~]# systemctl start flanneld.service

  [root@k8s-master ~]# systemctl enable flanneld.service


  5、修改Kubernetes所有Node节点kubelet设置中添加dns信息,否则会报错

  

  [Node1/Node2]

  [root@k8s-node1 ~]# vim /etc/kubernetes/kubelet

  ###

# kubernetes kubelet (minion) config


# The address for the info server to serve on (set to 0.0.0.0 or "" for all interfaces)

KUBELET_ADDRESS="--address=0.0.0.0"


# The port for the info server to serve on

KUBELET_PORT="--port=10250"


# You may leave this blank to use the actual hostname

KUBELET_HOSTNAME="--hostname-override=k8s-node1"


# location of the api-server

KUBELET_API_SERVER="--api-servers=http://k8s-master:8080"


# pod infrastructure container

KUBELET_POD_INFRA_CONTAINER="--pod-infra-container-p_w_picpath=registry.access.redhat.com/rhel7/pod-infrastructure:latest"


# Add your own!

#KUBELET_ARGS=""

KUBELET_ARGS="--cluster-dns=223.5.5.5 --cluster-domain=k8s-master"


  6、重启Node上的服务

  [Master]

for SERVICES in flanneld etcd kube-apiserver kube-controller-manager kube-scheduler; do     systemctl restart $SERVICES;     systemctl enable $SERVICES;     systemctl status $SERVICES ;   done


  [Node]

for SERVICES in flanneld kube-proxy kubelet docker; do     systemctl restart $SERVICES;     systemctl enable $SERVICES;     systemctl status $SERVICES ; done


  7、安装dashboard

    

    [Node1/Node2]

    a、导入p_w_picpaths

相关p_w_picpath 可以在daocloud.io 上面下载(3Q daocloud.io)


    b、导入:

    [root@k8s-node1 ~]# docker load < kubernetes-dashboard.tar.gz


    c、查看

    [root@k8s-node1 ~]# docker p_w_picpaths

REPOSITORY                                            TAG                 IMAGE ID            CREATED             SIZE

gcr.io/google_containers/kubernetes-dashboard-amd64   v1.6.2              bd4d50b8499e        8 days ago          139 MB


  8、创建dashboard容器

    [Master]

    a、下载kubernetes-dashboar.yaml文件

    [root@k8s-master ~]# git clone https://github.com/jdedu/kubernetes.git


    b、修改其中标红项

    [root@k8s-master ~]# vim kubernetes/kubernetes-dashboard.yaml

    kind: Deployment

apiVersion: extensions/v1beta1

metadata:

  labels:

    app: kubernetes-dashboard

    version: v1.1.1

  name: kubernetes-dashboard

  namespace: kube-system

spec:

  replicas: 1

  selector:

    matchLabels:

      app: kubernetes-dashboard

  template:

    metadata:

      labels:

        app: kubernetes-dashboard

    spec:

      containers:

      - name: kubernetes-dashboard

        p_w_picpath: gcr.io/google_containers/kubernetes-dashboard-amd64:v1.6.2

        p_w_picpathPullPolicy: Always

        ports:

        - containerPort: 9090

          protocol: TCP

        args:

        - --apiserver-host=http://192.168.80.130:8080

        livenessProbe:

          httpGet:

            path: /

            port: 9090

          initialDelaySeconds: 30

          timeoutSeconds: 30

---

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


  9、创建dashboard容器

  [Master]

  [root@k8s-master ~]# kubectl create -f kubernetes-dashboard.yaml

deployment "kubernetes-dashboard" created

service "kubernetes-dashboard" created

  

  10、查看状态

  a、查看pods

  [root@k8s-master ~]# kubectl get pods --namespace=kube-system

NAME                                    READY     STATUS              RESTARTS   AGE

kubernetes-dashboard-1607234690-3bnk2   0/1       ContainerCreating   0          34s


  b、查看构建详细信息

  [root@k8s-master ~]# kubectl describe pods kubernetes-dashboard-1607234690-3bnk2 --namespace=kube-system


Name:   kubernetes-dashboard-1607234690-3bnk2

Namespace:  kube-system

Node:   k8s-node2/192.168.80.132

Start Time: Thu, 03 Aug 2017 17:15:50 +0800

Labels:   app=kubernetes-dashboard

    pod-template-hash=1607234690

Status:   Pending

IP:   

Controllers:  ReplicaSet/kubernetes-dashboard-1607234690

Containers:

  kubernetes-dashboard:

    Container ID: 

    Image:    gcr.io/google_containers/kubernetes-dashboard-amd64:v1.6.2

    Image ID:   

    Port:   9090/TCP

    Args:

      --apiserver-host=http://192.168.80.130:8080

    State:      Waiting

      Reason:     ContainerCreating

    Ready:      False

    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   False 

  PodScheduled  True 

No volumes.

QoS Class:  BestEffort

Tolerations:  <none>

Events:

  FirstSeen LastSeen  Count From      SubObjectPath Type    Reason    Message

  --------- --------  ----- ----      ------------- --------  ------    -------

  2m    2m    1 {default-scheduler }      Normal    Scheduled Successfully assigned kubernetes-dashboard-1607234690-3bnk2 to k8s-node2

  

三、测试

  a、在测试机上添加host信息

  192.168.80.130  k8s-master


  b、使用浏览器输入:http://k8s-master:8080/ui



四、错误

  

  [错误1]

  [root@k8s-master ~]# kubectl describe pods kubernetes-dashboard-1607234690-3bnk2 --namespace=kube-system


  1s    1s    1 {kubelet k8s-node2}           Warning   FailedSync  Error syncing pod, skipping: failed to "StartContainer" for "kubernetes-dashboard" with CrashLoopBackOff: "Back-off 10s restarting failed container=kubernetes-dashboard pod=kubernetes-dashboard-980055440-l9zl5_kube-system(870d02e1-7810-11e7-9517-000c296a54e8)"

  

  再次使用kubectl logs查看具体错误信息

  [root@k8s-master ~]# kubectl logs kubernetes-dashboard-1607234690-l6gfk --namespace=kube-system


No request provided. Skipping authorization header

Error while initializing connection to Kubernetes apiserver. This most likely means that the cluster is misconfigured (e.g., it has invalid apiserver certificates or service accounts configuration) or the --apiserver-host param points to a server that does not exist. Reason: Get http://k8s-master:8080/version: dial tcp: lookup k8s-master on 223.5.5.5:53: no such host

Refer to the troubleshooting guide for more information: https://github.com/kubernetes/dashboard/blob/master/docs/user-guide/troubleshooting.md


  [解决方案]

[root@k8s-master ~]# vim kubenetes-dashboard.yaml

- --apiserver改成ip,不要使用域名


转载于:https://blog.51cto.com/onlywyn/1955057

最后

以上就是傲娇电话为你收集整理的kubenetes-dashboard 实践的全部内容,希望文章能够帮你解决kubenetes-dashboard 实践所遇到的程序开发问题。

如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(40)

评论列表共有 0 条评论

立即
投稿
返回
顶部