0
0
Kubernetesdevops~10 mins

Cross-namespace communication in Kubernetes - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to specify the namespace when accessing a service in another namespace.

Kubernetes
kubectl get svc my-service -n [1]
Drag options to blanks, or click blank then click option'
Adefault
Bproduction
Ckube-system
Ddev
Attempts:
3 left
💡 Hint
Common Mistakes
Forgetting to specify the namespace, causing errors or looking in the wrong namespace.
2fill in blank
medium

Complete the service URL to access a service named 'api' in the 'backend' namespace from another namespace.

Kubernetes
http://api.[1].svc.cluster.local
Drag options to blanks, or click blank then click option'
Abackend
Bfrontend
Cdefault
Dkube-system
Attempts:
3 left
💡 Hint
Common Mistakes
Using the wrong namespace in the URL, causing DNS resolution failure.
3fill in blank
hard

Fix the error in the pod spec to allow cross-namespace service access by completing the service name with namespace.

Kubernetes
        - name: API_URL
          value: "http://api.[1].svc.cluster.local"
Drag options to blanks, or click blank then click option'
Adefault
Bfrontend
Cbackend
Dkube-system
Attempts:
3 left
💡 Hint
Common Mistakes
Omitting the namespace or using the wrong namespace in the URL.
4fill in blank
hard

Fill both blanks to create a NetworkPolicy that allows ingress traffic from pods in the 'frontend' namespace to pods in the 'backend' namespace.

Kubernetes
apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata:
  name: allow-frontend
  namespace: backend
spec:
  podSelector: {}
  ingress:
  - from:
    - namespaceSelector:
        matchLabels:
          [1]: [2]
Drag options to blanks, or click blank then click option'
Aname
Bfrontend
Capp
Dbackend
Attempts:
3 left
💡 Hint
Common Mistakes
Using pod labels instead of namespace labels, or wrong label keys/values.
5fill in blank
hard

Fill all three blanks to create a RoleBinding that grants the 'view' role to the 'dev-team' group in the 'testing' namespace.

Kubernetes
apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
  name: view-binding
  namespace: [1]
subjects:
- kind: Group
  name: [2]
  apiGroup: rbac.authorization.k8s.io
roleRef:
  kind: Role
  name: [3]
  apiGroup: rbac.authorization.k8s.io
Drag options to blanks, or click blank then click option'
Atesting
Bdev-team
Cview
Dadmin
Attempts:
3 left
💡 Hint
Common Mistakes
Using cluster roles instead of roles, or wrong namespace or group names.