Accessing Kubernetes API via Kubernetes Dashboard Host
Solution 1:
Sure you can. So after you set up your proxy with kubectl proxy
, you can access the services with this format:
http://localhost:8001/api/v1/namespaces/kube-system/services/<service-name>:<port-name>/proxy/
For example for http-svc
and port name http
:
http://localhost:8001/api/v1/namespaces/default/services/http-svc:http/proxy/
Note: it's not necessarily for public access, but rather a proxy for you to connect from your public machine (say your laptop) to a private Kubernetes cluster.
Solution 2:
You can do it by changing your service to NodePort
:
$ kubectl -n kube-system edit service kubernetes-dashboard
You should see yaml
representation of the service. Change type: ClusterIP
to type: NodePort
and save file.
Note: This way of accessing Dashboard is only possible if you choose to install your user certificates in the browser. Certificates used by kubeconfig file to contact API Server can be used.
Please check the following articles and URLs for better understanding:
Stackoverflow thread
Accessing Dashboard 1.7.X and above
Deploying a publicly accessible Kubernetes Dashboard
How to access kubernetes dashboard from outside cluster
Hope it will help you!