ITeye博客

how to proxy to k8s web console

jXee · 2018-06-28 07:16 · JEE · Java · k8s · 开源软件 · Markdown

### how to access k8s web console if it's still available

  1. Run the proxy: $ cd /c/tools/env-prod $ ls -l -rwxr-xr-x 1 John.Wang 1049089 85 May 14 14:45 prod.listAllPods.sh* -rw-r--r-- 1 John.Wang 1049089 6146 Oct 4 2017 prod_cluster_config

$ kubectl --kubeconfig=prod_cluster_config --namespace=env-prod proxy Starting to serve on 127.0.0.1:8001

  1. Open the web console in your browser: http://localhost:8001/ui OR http://localhost:8001/api/v1/namespaces/kube-system/services/https:kubernetes-dashboard:/proxy/ YOU MUST CHANGE "https" to "http" in "https:kubernetes-dashboard". And the final url is as follows: http://localhost:8001/api/v1/namespaces/kube-system/services/http:kubernetes-dashboard:/proxy/

select your namespace, like "env-pod"

  1. How to restart a pod?

Just "delete" the current pod: k8s would start a new pod for it. kubectl --kubeconfig=test_cluster_config --namespace=env-qa delete pod order-service-5fbb59878d-qqqs9

### how to tail container log with kubectl

command: kubectl --kubeconfig=prod_cluster_config --namespace=env-prod logs pod-name --tail=50

$ cd /c/tools/env-prod/

find the pod-name by listing all the pods

$ kubectl --kubeconfig=prod_cluster_config --namespace=env-prod get pods | grep scheduling NAME READY STATUS RESTARTS AGE scheduling-service-6995d7fc67-zpdfm 1/1 Running 0 9d

to tail 50 lines of the container's log and stop

$ kubectl --kubeconfig=prod_cluster_config --namespace=env-prod logs scheduling-service-6995d7fc67-zpdfm --tail=50

to keep tailing 30 lines of the container's log

$ kubectl --kubeconfig=prod_cluster_config --namespace=env-prod logs scheduling-service-6995d7fc67-zpdfm --tail=30 -f

评论(0)

暂无评论。

评论功能维护中,当前仅展示历史评论。