配置kubernetes UI圖形化界面

配置Kubernetes網絡node

  • 在master和nodes上都須要安裝flannel
yum install flannel

 

  • 在master和nodes上都須要配置flannel

vi /etc/sysconfig/flanneldgit

# Flanneld configuration optionsgithub

# etcd url location. Point this to the server where etcd runs
FLANNEL_ETCD_ENDPOINTS="http://etcd:2379"web

# etcd config key. This is the configuration key that flannel queries
# For address range assignment
FLANNEL_ETCD_PREFIX="/atomic.io/network"docker

# Any additional options that you want to pass
#FLANNEL_OPTIONS=""api

 

  • 配置etcd中flannel的key,須要在etcd中進行配置
etcdctl mk /atomic.io/network/config '{ "Network": "192.168.0.0/16" }'

 

  • 啓動

在master節點上啓動網絡

systemctl enable flanneld.service 
systemctl start flanneld.service 
service docker restart
systemctl restart kube-apiserver.service
systemctl restart kube-controller-manager.service
systemctl restart kube-scheduler.service

 

在各個Nodes上啓動app

systemctl enable flanneld.service 
systemctl start flanneld.service 
service docker restart
systemctl restart kubelet.service
systemctl restart kube-proxy.service

運行 kubectl get pods --all-namespaces -o wide 看獲取的ip地址是否正確tcp

 

 

 編輯一個kubernetes-dashboard.yaml文件ide

最新版本能夠去官網下載

https://github.com/kubernetes/dashboard/blob/master/src/deploy/kubernetes-dashboard.yaml

 

apiVersion: extensions/v1beta1
kind: Deployment
metadata:
# Keep the name in sync with image version and
# gce/coreos/kube-manifests/addons/dashboard counterparts
  name: kubernetes-dashboard-latest
  namespace: kube-system
spec:
  replicas: 1
  template:
    metadata:
      labels:
        k8s-app: kubernetes-dashboard
        version: latest
        kubernetes.io/cluster-service: "true"
    spec:
      containers:
      - name: kubernetes-dashboard
        image: gcr.io/google_containers/kubernetes-dashboard-amd64:v1.5.1
        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://10.182.169.33:8080
        livenessProbe:
          httpGet:
            path: /
            port: 9090
          initialDelaySeconds: 30
          timeoutSeconds: 30
---
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

 

注意修改--apiserver-host=http://10.182.169.33:8080 指向本身的api server.

 


建立dashboard
 

kubectl create -f kubernetes-dashboard.yaml

kubectl get  -f kubernetes-dashboard.yaml 

發現deploy/kubernetes-dashboard-latest一直不在avaiable狀態,經過下面命令查詢

kubectl get pods --all-namespaces

發現kube-system的命名空間下,老是有個kubernetes-dashboard-latest-1590787137-pp8qd處於CrashLoopBackOff狀態.

能夠經過下面命令查看namespace的日誌狀況

kubectl describe po kubernetes-dashboard --namespace=kube-system

 

刪除kubernetes-dashboard

由於沒搞清楚什麼緣由,很想再試一次,刪除命令以下:

kubectl delete -f kubernetes-dashboard.yaml

在運行kubectl get pods --all-namespaces發現老是有kube-system命名空間下的pod在運行.最後經過指定命名空間刪除

kubectl delete --all pods --namespace=kube-system

kubectl delete deployment kubernetes-dashboard --namespace=kube-system

注意,若是隻刪除pod會發現刪完後又會有個一樣的pod啓動起來,刪除deployment便可.

 

查看日誌肯定緣由

最重要仍是要看日誌,最重要仍是要看日誌,最重要仍是要看日誌, 重要事情說三遍,此問題浪費3個鐘頭時間 :(

 

kubectl logs -f kubernetes-dashboard-latest-3243398-thc7k -n kube-system

[root@k8s-master ~]# kubectl logs -f kubernetes-dashboard-latest-3243398-thc7k -n kube-system
Using HTTP port: 9090
Using apiserver-host location: http://k8s-master:8080
Creating API server client for http://k8s-master:8080
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 202.96.134.33:53: no such host
Refer to the troubleshooting guide for more information: https://github.com/kubernetes/dashboard/blob/master/docs/user-guide/troubleshooting.md

 

發現是dns把k8s-master解析成202.96.134.33的地址了,修改kubernetes-dashboard.yaml中的apiserver-host=http://k8s-master:8080爲

http://192.168.0.104:8080後,再進行create就成功.

 

訪問http://192.168.0.104:8080/ui,界面以下:

 

 

點擊weblogic Pod的日誌,顯示以下:

相關文章
相關標籤/搜索