I want to expose kubernetes dashboard to multiple users who have access to my vpc, i've seen some examples using internal load balancer with external DNS but i just want to know if there are more suggestions.
When you install the dashboard, the service is set as ClusterIP. To let users from the same VPC access it you need to change the service to NodePort.
$ kubectl get service kubernetes-dashboard -n kube-system
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
kubernetes-dashboard ClusterIP 10.0.184.227 <none> 80/TCP 15m
To change it you have to edit the service:
kubectl edit service kubernetes-dashboard -n kube-systemAnd change the .spec.type from ClusterIP to NodePort.
Another option is to patch the service with the following command:
$ kubectl patch service -n kube-system kubernetes-dashboard --patch '{"spec": {"type": "NodePort"}}'After you edit or patch it your service is ready to be acceded as you need.
$ kubectl get service kubernetes-dashboard -n kube-system
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
kubernetes-dashboard NodePort 10.0.184.227 <none> 80:30334/TCP 18m
...Now to connect to the dashboard you have to point your browser to http://master-node-ip:nodePort
$ kubectl describe service kubernetes-dashboard -n kube-system
...
NodePort: <unset> 30334/TCP
...$ kubectl get node -o wide
NAME STATUS ROLES AGE VERSION INTERNAL-IP EXTERNAL-IP OS-IMAGE KERNEL-VERSION CONTAINER-RUNTIME
aks-agentpool-20139558-vmss000000 Ready agent 16m v1.15.10 10.240.0.5 <none> Ubuntu 16.04.6 LTS 4.15.0-1071-azure docker://3.0.10+azure
...
So based on this example it looks like: http://10.240.0.5:30334
And it can be accessed from anyone in the same network as your master node.
$ curl http://10.240.0.5:30334
<!doctype html> <html ng-app="kubernetesDashboard"> <head> <meta charset="utf-8"> <title ng-controller="kdTitle as $ctrl" ng-bind="$ctrl.title()"></title> <link rel="icon" type="image/png" href="assets/images/kubernetes-logo.png"> <meta name="viewport" content="width=device-width"> <link rel="stylesheet" href="static/vendor.93db0a0d.css"> <link rel="stylesheet" href="static/app.ddd3b5ec.css"> </head> <body ng-controller="kdMain as $ctrl"> <!--[if lt IE 10]>
<p class="browsehappy">You are using an <strong>outdated</strong> browser.
Please <a href="http://browsehappy.com/">upgrade your browser</a> to improve your
experience.</p>
<![endif]--> <kd-login layout="column" layout-fill ng-if="$ctrl.isLoginState()"> </kd-login> <kd-chrome layout="column" layout-fill ng-if="!$ctrl.isLoginState()"> </kd-chrome> <script src="static/vendor.bd425c26.js"></script> <script src="api/appConfig.json"></script> <script src="static/app.91a96542.js"></script> </body> </html>To know more about the different between all Kubernetes services type, check the following links:
Publishing Services (ServiceTypes) Kubernetes – Service Publishing