Bird
Raised Fist0
Kubernetesdevops~10 mins

Kubernetes dashboard - Interactive Code Practice

Choose your learning style10 modes available

Start learning this pattern below

Jump into concepts and practice - no test required

or
Recommended
Test this pattern10 questions across easy, medium, and hard to know if this pattern is strong
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the command to start the Kubernetes dashboard proxy.

Kubernetes
kubectl [1] proxy
Drag options to blanks, or click blank then click option'
Aproxy
Brun
Ccreate
Dapply
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'create' or 'apply' instead of 'proxy' will not start the proxy server.
Trying to use 'run' will cause an error because it is for running pods.
2fill in blank
medium

Complete the command to deploy the Kubernetes dashboard using the official YAML file.

Kubernetes
kubectl apply -f [1]
Drag options to blanks, or click blank then click option'
Adashboard-config.yaml
Bhttps://raw.githubusercontent.com/kubernetes/dashboard/v2.7.0/aio/deploy/recommended.yaml
Cdashboard.json
Ddashboard.yaml
Attempts:
3 left
💡 Hint
Common Mistakes
Using a local file name will fail if the file does not exist.
Using JSON files is incorrect because Kubernetes uses YAML for manifests.
3fill in blank
hard

Fix the error in the command to get the dashboard login token for the 'kubernetes-dashboard' service account in the 'kubernetes-dashboard' namespace.

Kubernetes
kubectl -n kubernetes-dashboard get secret [1] -o go-template='{{.data.token | base64decode}}'
Drag options to blanks, or click blank then click option'
Aadmin-user-token
Bdefault-token
C$(kubectl -n kubernetes-dashboard get sa kubernetes-dashboard -o jsonpath='{.secrets[0].name}')
Dkubernetes-dashboard-token
Attempts:
3 left
💡 Hint
Common Mistakes
Using a fixed secret name may fail if the secret name changes.
Not using command substitution will cause the command to fail.
4fill in blank
hard

Fill both blanks to create a ClusterRoleBinding named 'dashboard-admin' that binds the 'cluster-admin' role to the 'kubernetes-dashboard' service account in the 'kubernetes-dashboard' namespace.

Kubernetes
kubectl create clusterrolebinding dashboard-admin --clusterrole=[1] --serviceaccount=[2]
Drag options to blanks, or click blank then click option'
Acluster-admin
Badmin
Ckubernetes-dashboard:kubernetes-dashboard
Ddefault:default
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'admin' instead of 'cluster-admin' will not grant full permissions.
Not specifying the namespace in the service account will cause errors.
5fill in blank
hard

Fill all three blanks to create a dictionary comprehension that maps pod names to their status phase for pods in the 'kubernetes-dashboard' namespace where the phase is 'Running'.

Kubernetes
pods_status = { [1]: pod.status.phase for pod in [3].items if pod.status.phase == '[2]' }
Drag options to blanks, or click blank then click option'
Apod.metadata.name
BRunning
Cpods
Dpod.metadata.labels
Attempts:
3 left
💡 Hint
Common Mistakes
Using labels instead of name as key will not give pod names.
Filtering with wrong phase will give incorrect results.

Practice

(1/5)
1. What is the primary purpose of the Kubernetes dashboard?
easy
A. To automatically scale pods based on CPU usage
B. To replace the kubectl command-line tool entirely
C. To serve as a container runtime for Kubernetes
D. To provide a web-based user interface for managing Kubernetes clusters

Solution

  1. Step 1: Understand the role of Kubernetes dashboard

    The dashboard is designed as a web UI to help users visually manage and monitor their Kubernetes clusters.
  2. Step 2: Compare with other Kubernetes components

    It does not replace kubectl, nor does it handle scaling or container runtime tasks.
  3. Final Answer:

    To provide a web-based user interface for managing Kubernetes clusters -> Option D
  4. Quick Check:

    Kubernetes dashboard = Web UI for cluster management [OK]
Hint: Dashboard = visual cluster management tool [OK]
Common Mistakes:
  • Thinking dashboard replaces kubectl
  • Confusing dashboard with autoscaling
  • Assuming dashboard is a container runtime
2. Which command correctly installs the Kubernetes dashboard?
easy
A. kubectl apply -f https://raw.githubusercontent.com/kubernetes/dashboard/v2.7.0/aio/deploy/recommended.yaml
B. kubectl create dashboard
C. kubectl run dashboard --image=kubernetes/dashboard
D. kubectl install dashboard

Solution

  1. Step 1: Identify the installation method for the dashboard

    The official way to install the Kubernetes dashboard is by applying the recommended YAML manifest from the official GitHub repository.
  2. Step 2: Verify the command syntax

    kubectl apply -f [URL] is the correct syntax to apply a manifest file from a URL.
  3. Final Answer:

    kubectl apply -f https://raw.githubusercontent.com/kubernetes/dashboard/v2.7.0/aio/deploy/recommended.yaml -> Option A
  4. Quick Check:

    Install dashboard = kubectl apply -f URL [OK]
Hint: Use kubectl apply with official dashboard YAML URL [OK]
Common Mistakes:
  • Using kubectl create instead of apply
  • Trying kubectl run which is for pods
  • Using non-existent kubectl install command
3. After running kubectl proxy, what URL should you open in your browser to access the Kubernetes dashboard?
medium
A. http://localhost:8080/dashboard
B. http://localhost:8001/api/v1/namespaces/kubernetes-dashboard/services/https:kubernetes-dashboard:/proxy/
C. https://dashboard.kubernetes.local
D. http://127.0.0.1:6443/dashboard

Solution

  1. Step 1: Understand kubectl proxy behavior

    Running kubectl proxy creates a local proxy on port 8001 that forwards requests to the Kubernetes API server.
  2. Step 2: Identify the dashboard proxy URL

    The dashboard is accessed via the API server proxy path: /api/v1/namespaces/kubernetes-dashboard/services/https:kubernetes-dashboard:/proxy/ on localhost port 8001.
  3. Final Answer:

    http://localhost:8001/api/v1/namespaces/kubernetes-dashboard/services/https:kubernetes-dashboard:/proxy/ -> Option B
  4. Quick Check:

    Dashboard URL after proxy = localhost:8001/api/v1/... [OK]
Hint: Dashboard URL uses kubectl proxy on localhost:8001 [OK]
Common Mistakes:
  • Using wrong port like 8080 or 6443
  • Trying HTTPS without proxy
  • Using a made-up domain name
4. You installed the Kubernetes dashboard but get a 403 Forbidden error when accessing it. What is the most likely cause?
medium
A. You did not create a login token or proper access permissions
B. The dashboard service is not running
C. kubectl proxy is not installed
D. Your browser does not support HTTPS

Solution

  1. Step 1: Understand 403 Forbidden meaning

    A 403 error means access is denied due to lack of permissions or authentication.
  2. Step 2: Check dashboard access requirements

    The dashboard requires a valid login token with proper RBAC permissions to allow access.
  3. Final Answer:

    You did not create a login token or proper access permissions -> Option A
  4. Quick Check:

    403 Forbidden = missing token or permissions [OK]
Hint: 403 means missing token or permissions [OK]
Common Mistakes:
  • Assuming service is not running without checking
  • Thinking kubectl proxy is missing (it's a client tool)
  • Blaming browser HTTPS support
5. You want to securely access the Kubernetes dashboard remotely without exposing it publicly. Which approach is best?
hard
A. Expose the dashboard service with a LoadBalancer type service
B. Disable authentication on the dashboard for easy access
C. Use kubectl proxy on your local machine and SSH tunnel to the cluster
D. Access the dashboard directly via the cluster IP from anywhere

Solution

  1. Step 1: Consider security for remote access

    Exposing the dashboard publicly or disabling authentication is insecure and not recommended.
  2. Step 2: Use kubectl proxy with SSH tunneling

    Running kubectl proxy locally and creating an SSH tunnel to the cluster securely forwards traffic without exposing the dashboard publicly.
  3. Final Answer:

    Use kubectl proxy on your local machine and SSH tunnel to the cluster -> Option C
  4. Quick Check:

    Secure remote access = kubectl proxy + SSH tunnel [OK]
Hint: Secure access = kubectl proxy plus SSH tunnel [OK]
Common Mistakes:
  • Exposing dashboard publicly with LoadBalancer
  • Disabling authentication for convenience
  • Trying to access cluster IP directly without security