Complete the code to specify the namespace when accessing a service in another namespace.
kubectl get svc my-service -n [1]Using -n production tells kubectl to look for the service in the 'production' namespace.
Complete the service URL to access a service named 'api' in the 'backend' namespace from another namespace.
http://api.[1].svc.cluster.localThe full DNS name includes the service name, namespace, and cluster domain. Here, the namespace is 'backend'.
Fix the error in the pod spec to allow cross-namespace service access by completing the service name with namespace.
- name: API_URL
value: "http://api.[1].svc.cluster.local"Specifying the correct namespace 'backend' in the service URL allows the pod to reach the service across namespaces.
Fill both blanks to create a NetworkPolicy that allows ingress traffic from pods in the 'frontend' namespace to pods in the 'backend' namespace.
apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata:
name: allow-frontend
namespace: backend
spec:
podSelector: {}
ingress:
- from:
- namespaceSelector:
matchLabels:
[1]: [2]The NetworkPolicy uses namespaceSelector with label name: frontend to allow traffic from the 'frontend' namespace.
Fill all three blanks to create a RoleBinding that grants the 'view' role to the 'dev-team' group in the 'testing' namespace.
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
This RoleBinding applies in the 'testing' namespace, grants the 'view' role to the 'dev-team' group.