Skip to content

Commit b7bffae

Browse files
authored
Merge pull request #46693 from iainfoulds/patch-8
[AKS] Securing Kubernetes dashboard
2 parents 7f559cf + 66be5a4 commit b7bffae

File tree

1 file changed

+8
-30
lines changed

1 file changed

+8
-30
lines changed

articles/aks/kubernetes-dashboard.md

Lines changed: 8 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -34,42 +34,19 @@ This command creates a proxy between your development system and the Kubernetes
3434

3535
### For RBAC-enabled clusters
3636

37-
If your AKS cluster uses RBAC, a *ClusterRoleBinding* must be created before you can access the dashboard. Without a role binding, the Azure CLI returns an error similar to the following example:
37+
If your AKS cluster uses RBAC, a *ClusterRoleBinding* must be created before you can correctly access the dashboard. To create a binding, use the [kubectl create clusterrolebinding][kubectl-create-clusterrolebinding] command as shown in the following example.
3838

39-
```
40-
error: unable to forward port because pod is not running. Current status=Pending
41-
```
42-
43-
To create a binding, create a file named *dashboard-admin.yaml* and paste the following sample. This sample binding does not apply any additional authentication components. You can use mechanisms such as bearer tokens or a username/password to control who can access the dashboard and what permissions they have. For more information on authentication methods, see the Kubernetes dashboard wiki on [access controls][dashboard-authentication].
44-
45-
```yaml
46-
apiVersion: rbac.authorization.k8s.io/v1beta1
47-
kind: ClusterRoleBinding
48-
metadata:
49-
name: kubernetes-dashboard
50-
labels:
51-
k8s-app: kubernetes-dashboard
52-
roleRef:
53-
apiGroup: rbac.authorization.k8s.io
54-
kind: ClusterRole
55-
name: cluster-admin
56-
subjects:
57-
- kind: ServiceAccount
58-
name: kubernetes-dashboard
59-
namespace: kube-system
60-
```
39+
> [!WARNING]
40+
> This sample binding does not apply any additional authentication components and may lead to insecure use. The Kubernetes dashboard is open to anyone with access to the URL. Do not expose the Kubernetes dashboard publicly.
41+
>
42+
> You can use mechanisms such as bearer tokens or a username/password to control who can access the dashboard and what permissions they have. This allows for more secure use of the dashboard. For more information on using the different authentication methods, see the Kubernetes dashboard wiki on [access controls][dashboard-authentication].
6143
62-
Apply the binding with [kubectl apply][kubectl-apply] and specify your *dashboard-admin.yaml*, as shown in the following example:
63-
64-
```
65-
$ kubectl apply -f dashboard-admin.yaml
66-
67-
clusterrolebinding.rbac.authorization.k8s.io/kubernetes-dashboard created
44+
```console
45+
kubectl create clusterrolebinding kubernetes-dashboard --clusterrole=cluster-admin --serviceaccount=kube-system:kubernetes-dashboard
6846
```
6947

7048
You can now access the Kubernetes dashboard in your RBAC-enabled cluster. To start the Kubernetes dashboard, use the [az aks browse][az-aks-browse] command as detailed in the previous step.
7149

72-
7350
## Run an application
7451

7552
In the Kubernetes dashboard, click the **Create** button in the upper right window. Give the deployment the name `nginx` and enter `nginx:latest` for the container image name. Under **Service**, select **External** and enter `80` for both the port and target port.
@@ -116,6 +93,7 @@ For more information about the Kubernetes dashboard, see the Kubernetes document
11693
<!-- LINKS - external -->
11794
[kubernetes-dashboard]: https://kubernetes.io/docs/tasks/access-application-cluster/web-ui-dashboard/
11895
[dashboard-authentication]: https://github.com/kubernetes/dashboard/wiki/Access-control
96+
[kubectl-create-clusterrolebinding]: https://kubernetes.io/docs/reference/generated/kubectl/kubectl-commands#-em-clusterrolebinding-em-
11997
[kubectl-apply]: https://kubernetes.io/docs/reference/generated/kubectl/kubectl-commands#apply
12098

12199
<!-- LINKS - internal -->

0 commit comments

Comments
 (0)