CKA (Certified Kubernetes Administrator)/Kode Kloud

07. Networking - Ingress Networking (1)

seulseul 2022. 2. 3. 14:44
07. Networking

01. Explore Environment
02. CNI weave
03. Deploy Network Solution
04. Networking Weave
05. Service Networking
06. CoreDNS in Kubernetes
07. CKA – Ingress Networking – 1  Ingress Networking (1)
08. CKA – Ingress Networking – 2 Ingress Networking (2)
 

01. We have deployed Ingress Controller, resources and applications. Explore the setuIngress Controller, 리소스 및 애플리케이션을 배포했습니다. 설정을 탐색합니다.

Note: They are in different namespaces.

 

 

02. Which namespace is the Ingress Controller deployed in?

 

ask : nginx-ingress

root@controlplane:~# k get pod --all-namespaces
NAMESPACE       NAME                                        READY   STATUS    RESTARTS   AGE
app-space       default-backend-5cf9bfb9d-t8qmm             1/1     Running   0          8m48s
app-space       webapp-video-84f8655bd8-t8fll               1/1     Running   0          8m49s
app-space       webapp-wear-6ff9445955-7hzvr                1/1     Running   0          8m48s
ingress-space   nginx-ingress-controller-697cfbd4d9-87rd5   1/1     Running   0          8m48s
kube-system     coredns-74ff55c5b-fjlbt                     1/1     Running   0          14m
kube-system     coredns-74ff55c5b-p6wtj                     1/1     Running   0          14m
kube-system     etcd-controlplane                           1/1     Running   0          14m
kube-system     kube-apiserver-controlplane                 1/1     Running   0          14m
kube-system     kube-controller-manager-controlplane        1/1     Running   0          14m
kube-system     kube-flannel-ds-j4k7c                       1/1     Running   0          14m
kube-system     kube-proxy-zmttd                            1/1     Running   0          14m
kube-system     kube-scheduler-controlplane                 1/1     Running   0          14m

 

03. What is the name of the Ingress Controller Deployment?

 

 

ask : nginx-ingress-controller

 

root@controlplane:~# k get all -n ingress-space
NAME                                            READY   STATUS    RESTARTS   AGE
pod/nginx-ingress-controller-697cfbd4d9-87rd5   1/1     Running   0          9m43s

NAME                      TYPE       CLUSTER-IP      EXTERNAL-IP   PORT(S)                      AGE
service/ingress-service   NodePort   10.104.71.243   <none>        80:30080/TCP,443:32293/TCP   9m45s

NAME                                       READY   UP-TO-DATE   AVAILABLE   AGE
deployment.apps/nginx-ingress-controller   1/1     1            1           9m45s

NAME                                                  DESIRED   CURRENT   READY   AGE
replicaset.apps/nginx-ingress-controller-697cfbd4d9   1         1         1       9m45s

 

04. Which namespace are the applications deployed in?

 

ask : app-space

 

root@controlplane:~# k get deploy --all-namespaces
NAMESPACE       NAME                       READY   UP-TO-DATE   AVAILABLE   AGE
app-space       default-backend            1/1     1            1           11m
app-space       webapp-video               1/1     1            1           11m
app-space       webapp-wear                1/1     1            1           11m
ingress-space   nginx-ingress-controller   1/1     1            1           11m
kube-system     coredns                    2/2     2            2           17m

 

05. How many applications are deployed in the app-space namespace?

 

Count the number of deployments in this namespace.

 

ask : 3

 

06. Which namespace is the Ingress Resource deployed in?

 

ask : app-space

 

root@controlplane:~# kubectl get ingress --all-namespaces
NAMESPACE   NAME                 CLASS    HOSTS   ADDRESS   PORTS   AGE
app-space   ingress-wear-watch   <none>   *                 80      12m

 

07. What is the name of the Ingress Resource?

 

ask : ingress-wear-watch

 

08. What is the Host configured on the Ingress Resource?

The host entry defines the domain name that users use to reach the application like www.google.com

호스트 항목은 사용자가 www.google.com과 같은 애플리케이션에 연결하는 데 사용하는 도메인 이름을 정의합니다.

 

ask : All Host

 

09. What backend is the /wear path on the Ingress configured with?

 

ask : wear-service

 

spec:
  rules:
  - http:
      paths:
      - backend:
          service:
            name: wear-service
            port:
              number: 8080
        path: /wear
        pathType: Prefix
      - backend:
          service:
            name: video-service
            port:
              number: 8080
        path: /watch
        pathType: Prefix

 

10. At what path is the video streaming application made available on the Ingress?

Ingress에서 비디오 스트리밍 애플리케이션을 사용할 수 있는 경로는 무엇입니까?

 

ask : /watch

 

11. If the requirement does not match any of the configured paths what service are the requests forwarded to?

요구 사항이 구성된 경로와 일치하지 않는 경우 요청이 전달되는 서비스는 무엇입니까?

1) default-backend

2) The last service configured

3) No Service

4) default-http-backend

 

Default backend:  default-http-backend:80 (<error: endpoints "default-http-backend" not found>)

 

12. Now view the Ingress Service using the tab at the top of the terminal. Which page do you see?

Click on the tab named Ingress.

1) Apparel Service

2) Blank

3) Video Service

4) 404 Error page

 

13. View the applications by appending /wear and /watch to the URL you opened in the previous step.

이전 단계에서 연 URL에 /wear 및 /watch를 추가하여 애플리케이션을 봅니다.

 

14. You are requested to change the URLs at which the applications are made available.

Make the video application available at /stream.

응용 프로그램을 사용할 수 있는 URL을 변경해야 합니다.

/stream에서 비디오 애플리케이션을 사용할 수 있도록 합니다.


  • Ingress: ingress-wear-watch
  • Path: /stream
  • Backend Service: video-service
  • Backend Service Port: 8080

 

Run the command: 

kubectl edit ingress --namespace app-space

and change the path to the video streaming application to /stream.

 

15. View the Video application using the /stream URL in your browser.

Click on the Ingress tab above your terminal,

if its not open already, and append /stream to the URL in the browser.

/stream

 

16. A user is trying to view the /eat URL on the Ingress Service. Which page would he see?

If not open already, click on the Ingress tab above your terminal,

and append /eat to the URL in the browser.

사용자가 Ingress 서비스에서 /eat URL을 보려고 합니다. 그는 어떤 페이지를 보게 될까요?

아직 열지 않았다면 터미널 위의 Ingress 탭을 클릭하고,

브라우저의 URL에 /eat를 추가합니다.

 

1) 404 Error page

2) Blank

3) Video Service

4) Apparel Service

 

17. Due to increased demand, your business decides to take on a new venture.

You acquired a food delivery company.

Their applications have been migrated over to your cluster.

수요 증가로 인해 귀하의 비즈니스는 새로운 벤처를 시작하기로 결정했습니다.

음식 배달 회사를 인수했습니다.

해당 애플리케이션이 클러스터로 마이그레이션되었습니다.

Inspect the new deployments in the app-space namespace.

root@controlplane:~# k get all -n app-space
NAME                                  READY   STATUS    RESTARTS   AGE
pod/default-backend-5cf9bfb9d-t8qmm   1/1     Running   0          35m
pod/webapp-food-7785c59d7d-n542g      1/1     Running   0          42s
pod/webapp-video-84f8655bd8-t8fll     1/1     Running   0          35m
pod/webapp-wear-6ff9445955-7hzvr      1/1     Running   0          35m

NAME                           TYPE        CLUSTER-IP       EXTERNAL-IP   PORT(S)    AGE
service/default-http-backend   ClusterIP   10.108.28.49     <none>        80/TCP     35m
service/food-service           ClusterIP   10.108.193.230   <none>        8080/TCP   42s
service/video-service          ClusterIP   10.110.48.144    <none>        8080/TCP   35m
service/wear-service           ClusterIP   10.96.141.67     <none>        8080/TCP   35m

NAME                              READY   UP-TO-DATE   AVAILABLE   AGE
deployment.apps/default-backend   1/1     1            1           35m
deployment.apps/webapp-food       1/1     1            1           42s
deployment.apps/webapp-video      1/1     1            1           35m
deployment.apps/webapp-wear       1/1     1            1           35m

NAME                                        DESIRED   CURRENT   READY   AGE
replicaset.apps/default-backend-5cf9bfb9d   1         1         1       35m
replicaset.apps/webapp-food-7785c59d7d      1         1         1       42s
replicaset.apps/webapp-video-84f8655bd8     1         1         1       35m
replicaset.apps/webapp-wear-6ff9445955      1         1         1       35m

 

18. You are requested to add a new path to your ingress to make the food delivery application available to your customers.

고객이 음식 배달 애플리케이션을 사용할 수 있도록 하려면 수신에 새 경로를 추가해야 합니다.

Make the new application available at /eat.


/eat에서 새 응용 프로그램을 사용할 수 있도록 합니다.


  • Ingress: ingress-wear-watch
  • Path: /eat
  • Backend Service: food-service
  • Backend Service Port: 8080
Run the command: kubectl edit ingress --namespace app-space and add a new Path entry for the new service.
spec:
  rules:
  - http:
      paths:
      - backend:
          service:
            name: wear-service
            port:
              number: 8080
        path: /wear
        pathType: Prefix
      - backend:
          service:
            name: video-service
            port:
              number: 8080
        path: /stream
        pathType: Prefix

      - backend:
          service:
            name: food-service
            port:
              number: 8080
        path: /eat
        pathType: Prefix
Solution manifest file to add a new path to our ingress service to make the application available at /eat as follows:

apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  annotations:
    nginx.ingress.kubernetes.io/rewrite-target: /
    nginx.ingress.kubernetes.io/ssl-redirect: "false"
  name: ingress-wear-watch
  namespace: app-space
spec:
  rules:
  - http:
      paths:
      - backend:
          service:
            name: wear-service
            port: 
              number: 8080
        path: /wear
        pathType: Prefix
      - backend:
          service:
            name: video-service
            port: 
              number: 8080
        path: /stream
        pathType: Prefix
      - backend:
          service:
            name: food-service
            port: 
              number: 8080
        path: /eat
        pathType: Prefix

 

19. View the Food delivery application using the /eat URL in your browser.

 

Click on the Ingress tab above your terminal, if its not open already, and append /eat to the URL in the browser.

Ok

 

 

20. A new payment service has been introduced. Since it is critical, the new application is deployed in its own namespace.

새로운 결제 서비스가 도입되었습니다. 중요하므로 새 응용 프로그램은 자체 네임스페이스에 배포됩니다.

Identify the namespace in which the new application is deployed.

1) default

2) kube-public

3) easy-pay

4) pay-space

5) critical-space

21. What is the name of the deployment of the new application?

 

ask : webapp-pay

 

root@controlplane:~# k get all -n critical-space
NAME                            READY   STATUS    RESTARTS   AGE
pod/webapp-pay-f74b9fc6-xf4p4   1/1     Running   0          102s

NAME                  TYPE        CLUSTER-IP    EXTERNAL-IP   PORT(S)    AGE
service/pay-service   ClusterIP   10.111.62.4   <none>        8282/TCP   102s

NAME                         READY   UP-TO-DATE   AVAILABLE   AGE
deployment.apps/webapp-pay   1/1     1            1           102s

NAME                                  DESIRED   CURRENT   READY   AGE
replicaset.apps/webapp-pay-f74b9fc6   1         1         1       102s

 

22. You are requested to make the new application available at /pay.


Identify and implement the best approach to making this application available on the ingress controller and test to make sure its working. Look into annotations: rewrite-target as well.

인그레스 컨트롤러에서 이 애플리케이션을 사용할 수 있도록 하는 최상의 접근 방식을 식별 및 구현하고 작동하는지 테스트합니다. 

주석을 살펴보십시오. rewrite-target도 마찬가지입니다.

 

 

  • Ingress Created
  • Path: /pay
  • Configure correct backend service
  • Configure correct backend port
Create a new Ingress for the new pay application in the critical-space namespace.

Use the command 

kubectl get svc -n critical-space

to know the service and port details.
Solution manifest file to create a new ingress service to make the application available at /pay as follows:

---
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: test-ingress
  namespace: critical-space
  annotations:
    nginx.ingress.kubernetes.io/rewrite-target: /
    nginx.ingress.kubernetes.io/ssl-redirect: "false"
spec:
  rules:
  - http:
      paths:
      - path: /pay
        pathType: Prefix
        backend:
          service:
           name: pay-service
           port:
            number: 8282

 

23. View the Payment application using the /pay URL in your browser.

 

Click on the Ingress tab above your terminal, if its not open already, and append /pay to the URL in the browser.