Hi Team, For Mock Test 3 (Question: 5), How will I test the connectivity ? Can y . . .

Manas Sahoo:
Hi Team, For Mock Test 3 (Question: 5), How will I test the connectivity ? Can you please help me to give all the steps required ?

Mohamed Ayman:
in CKA course or CKAD?

Manas Sahoo:
in CKA course

Mohamed Ayman:
You need first to create a NetworkPolicy that allows incoming connections to the service over port 80.
Check the following:

apiVersion: <http://networking.k8s.io/v1|networking.k8s.io/v1>
kind: NetworkPolicy
metadata:
  name:  ingress-to-nptest
spec:
  podSelector:
    matchLabels:
      run: np-test-1
  policyTypes:
  - Ingress
  - Egress
  ingress:
  - ports:
    - protocol: TCP
      port: 80

Mohamed Ayman:
You can use nc command with the busybox image to test the connectivity on port 80.
Check this:

kubectl run test-svc-connection --rm -it --image=busybox:1.28 --restart=Never -- nc -z -v -w 2 np-test-service 80

Manas Sahoo:
Thanks a lot MAyman…

Mohamed Ayman:
You’re welcome