ExamGecko
Question list
Search
Search

List of questions

Search

Question 53 - CKA discussion

Report
Export

Score: 7%

Task

Create a new NetworkPolicy named allow-port-from-namespace in the existing namespace echo.

Ensure that the new NetworkPolicy allows Pods in namespace my-app to connect to port 9000 of

Pods in namespace echo.

Further ensure that the new NetworkPolicy:

• does not allow access to Pods, which don't listen on port 9000

• does not allow access from Pods, which are not in namespace my-app

A.
See the solution below.
Answers
A.
See the solution below.
Suggested answer: A

Explanation:

Solution:

#network.yaml

apiVersion: networking.k8s.io/v1

kind: NetworkPolicy

metadata:

name: allow-port-from-namespace

namespace: internal

spec:

podSelector:

matchLabels: {

}

policyTypes:

- Ingress

ingress:

- from:

- podSelector: {

}

ports:

- protocol: TCP

port: 8080

#spec.podSelector namespace pod

kubectl create -f network.yaml

asked 18/09/2024
Paramdeep Saini
39 questions
User
Your answer:
0 comments
Sorted by

Leave a comment first