how to proxy to k8s web console
程序员文章站
2024-01-11 20:07:34
...
### 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
2. 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"
3. 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 [-f]
$ 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
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
2. 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"
3. 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 [-f]
$ 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
上一篇: (转)yii流程,入口文件下的准备工作
下一篇: springMVC REST 上传文件