본문 바로가기
cloud/k8s(문제풀이)

[cka] kodekloud-Network Policies

by mozi2 2022. 7. 1.
반응형

1.How many network policies do you see in the environment?

We have deployed few web applications, services and network policies. Inspect the environment.

k get networkpolicy
k get netpol

A) 1

 

2. What is the name of the Network Policy?

 

A)payroll-policy

 

3.Which pod is the Network Policy applied on?

 

A) payroll

 

4.What type of traffic is this Network Policy configured to handle?

k describe networkpolicy

A) Ingress

 

5. What is the impact of the rule configured on this Network Policy?

 

A) Traffic From Internal to Payroll POD is allowed 

6.What is the impact of the rule configured on this Network Policy?

A) Internal ~~~ 8080 ~~

 

7. Access the UI of these applications using the link given above the terminal.

8. Perform a connectivity test using the User Interface in these Applications to access the payroll-service at port 8080.

 

A) Only ~~~ payroll service 

 

9. Perform a connectivity test using the User Interface of the Internal Application to access the external-service at port 8080.

 

A) success

 

10.Create a network policy to allow traffic from the Internal application only to the payroll-service and db-service.

Use the spec given below. You might want to enable ingress traffic to the pod to test your rules in the UI.

  • Policy Name: internal-policy

  • Policy Type: Egress

  • Egress Allow: payroll

  • Payroll Port: 8080

  • Egress Allow: mysql

  • MySQL Port: 3306

apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata:
  name: internal-policy
  namespace: default
spec:
  podSelector:
    matchLabels:
      name: internal
  policyTypes:
  - Egress
  - Ingress
  ingress:
    - {}
  egress:
  - to:
    - podSelector:
        matchLabels:
          name: mysql
    ports:
    - protocol: TCP
      port: 3306

  - to:
    - podSelector:
        matchLabels:
          name: payroll
    ports:
    - protocol: TCP
      port: 8080

  - ports:
    - port: 53
      protocol: UDP
    - port: 53
      protocol: TCP

 

 

 

 

 

 

 

728x90
반응형