본문 바로가기

CKA &. CKAD/Networking

Practice Test - CKA -Ingress Networking

ㅁ We have deployed Ingress Controller, resources and applications, Explore the setup.

Note: They are in different namespaces.

 

$ kubectl get all --all-namespaces
NAMESPACE       NAME                                            READY   STATUS              RESTARTS   AGE
app-space       pod/default-backend-5cf9bfb9d-rdknk             0/1     ContainerCreating   0          98s
app-space       pod/webapp-video-84f8655bd8-bb2sg               0/1     ContainerCreating   0          98s
app-space       pod/webapp-wear-6ff9445955-xstsl                0/1     ContainerCreating   0          98s
ingress-space   pod/nginx-ingress-controller-697cfbd4d9-nsrc5   1/1     Running             0          97s
kube-system     pod/coredns-f9fd979d6-d7pcq                     1/1     Running             0          3m1s
kube-system     pod/coredns-f9fd979d6-xtx79                     1/1     Running             0          3m1s
kube-system     pod/etcd-controlplane                           1/1     Running             0          3m9s
kube-system     pod/kube-apiserver-controlplane                 1/1     Running             0          3m9s
kube-system     pod/kube-controller-manager-controlplane        1/1     Running             0          3m9s
kube-system     pod/kube-flannel-ds-amd64-chl6k                 1/1     Running             0          3m2s
kube-system     pod/kube-flannel-ds-amd64-tvn4b                 1/1     Running             1          2m51s
kube-system     pod/kube-proxy-48qwx                            1/1     Running             1          2m51s
kube-system     pod/kube-proxy-49rb6                            1/1     Running             0          3m2s
kube-system     pod/kube-scheduler-controlplane                 1/1     Running             0          3m9s

NAMESPACE       NAME                           TYPE        CLUSTER-IP       EXTERNAL-IP   PORT(S)                      AGE
app-space       service/default-http-backend   ClusterIP   10.110.201.71    <none>        80/TCP                       98s
app-space       service/video-service          ClusterIP   10.110.199.73    <none>        8080/TCP                     98s
app-space       service/wear-service           ClusterIP   10.99.2.241      <none>        8080/TCP                     98s
default         service/kubernetes             ClusterIP   10.96.0.1        <none>        443/TCP                      3m18s
ingress-space   service/ingress-service        NodePort    10.105.129.171   <none>        80:30080/TCP,443:31721/TCP   98s
kube-system     service/kube-dns               ClusterIP   10.96.0.10       <none>        53/UDP,53/TCP,9153/TCP       3m16s

NAMESPACE     NAME                                     DESIRED   CURRENT   READY   UP-TO-DATE   AVAILABLE   NODE SELECTOR            AGE
kube-system   daemonset.apps/kube-flannel-ds-amd64     2         2         2       2            2           <none>                   3m14s
kube-system   daemonset.apps/kube-flannel-ds-arm       0         0         0       0            0           <none>                   3m14s
kube-system   daemonset.apps/kube-flannel-ds-arm64     0         0         0       0            0           <none>                   3m14s
kube-system   daemonset.apps/kube-flannel-ds-ppc64le   0         0         0       0            0           <none>                   3m13s
kube-system   daemonset.apps/kube-flannel-ds-s390x     0         0         0       0            0           <none>                   3m13s
kube-system   daemonset.apps/kube-proxy                2         2         2       2            2           kubernetes.io/os=linux   3m16s

NAMESPACE       NAME                                       READY   UP-TO-DATE   AVAILABLE   AGE
app-space       deployment.apps/default-backend            0/1     1            0           98s
app-space       deployment.apps/webapp-video               0/1     1            0           98s
app-space       deployment.apps/webapp-wear                0/1     1            0           98s
ingress-space   deployment.apps/nginx-ingress-controller   1/1     1            1           98s
kube-system     deployment.apps/coredns                    2/2     2            2           3m16s

NAMESPACE       NAME                                                  DESIRED   CURRENT   READY   AGE
app-space       replicaset.apps/default-backend-5cf9bfb9d             1         1         0       98s
app-space       replicaset.apps/webapp-video-84f8655bd8               1         1         0       98s
app-space       replicaset.apps/webapp-wear-6ff9445955                1         1         0       98s
ingress-space   replicaset.apps/nginx-ingress-controller-697cfbd4d9   1         1         1       98s
kube-system     replicaset.apps/coredns-f9fd979d6                     2         2         2       3m1s

 

ㅁ Which namespace is the Ingress Controller deployed in?

[INGRESS-SPACE]

$ kubectl get deployment --all-namespaces
NAMESPACE       NAME                       READY   UP-TO-DATE   AVAILABLE   AGE
app-space       default-backend            1/1     1            1           2m47s
app-space       webapp-video               1/1     1            1           2m47s
app-space       webapp-wear                1/1     1            1           2m47s
ingress-space   nginx-ingress-controller   1/1     1            1           2m47s
kube-system     coredns                    2/2     2            2           4m25s

ㅁ What is the name of the Ingress Controller Deployment?

[NGINX-INGRESS-CONTROLLER]

$ kubectl get deployment --all-namespaces
NAMESPACE       NAME                       READY   UP-TO-DATE   AVAILABLE   AGE
app-space       default-backend            1/1     1            1           2m47s
app-space       webapp-video               1/1     1            1           2m47s
app-space       webapp-wear                1/1     1            1           2m47s
ingress-space   nginx-ingress-controller   1/1     1            1           2m47s
kube-system     coredns                    2/2     2            2           4m25s

ㅁ Which namespace are the applications deployed in?

[APP-SPACE]

$ kubectl get deployment --all-namespaces
NAMESPACE       NAME                       READY   UP-TO-DATE   AVAILABLE   AGE
app-space       default-backend            1/1     1            1           2m47s
app-space       webapp-video               1/1     1            1           2m47s
app-space       webapp-wear                1/1     1            1           2m47s
ingress-space   nginx-ingress-controller   1/1     1            1           2m47s
kube-system     coredns                    2/2     2            2           4m25s

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

[3]

$ kubectl get deploy --namespace=app-space

NAME              READY   UP-TO-DATE   AVAILABLE   AGE
default-backend   1/1     1            1           7m6s
webapp-video      1/1     1            1           7m6s
webapp-wear       1/1     1            1           7m6s

 

ㅁ Which namespace is the Ingress Resource deployed in?

[APP-SPACE]

$ kubectl get ingress --all-namespaces

Warning: extensions/v1beta1 Ingress is deprecated in v1.14+, unavailable in v1.22+; use networking.k8s.io/v1 Ingress
NAMESPACE   NAME                 CLASS    HOSTS   ADDRESS   PORTS   AGE
app-space   ingress-wear-watch   <none>   *                 80      9m54s

ㅁ What is the name of the Ingress Resource?

[INGRESS-WEAR-WATCH]

$ kubectl get ingress -n app-space

Warning: extensions/v1beta1 Ingress is deprecated in v1.14+, unavailable in v1.22+; use networking.k8s.io/v1 Ingress
NAMESPACE   NAME                 CLASS    HOSTS   ADDRESS   PORTS   AGE
app-space   ingress-wear-watch   <none>   *                 80      9m54s

 

ㅁ 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  

 

[ALL HOSTS(*)] 

아래 yaml 내용에서 특별히 host가 지정되지 않음

 $ kubectl get ingress ingress-wear-watch -n app-space -o yaml
 
Warning: extensions/v1beta1 Ingress is deprecated in v1.14+, unavailable in v1.22+; use networking.k8s.io/v1 Ingress
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  annotations:
    nginx.ingress.kubernetes.io/rewrite-target: /
    nginx.ingress.kubernetes.io/ssl-redirect: "false"
  creationTimestamp: "2021-03-31T12:36:43Z"
  generation: 1
  managedFields:
  - apiVersion: extensions/v1beta1
    fieldsType: FieldsV1
    fieldsV1:
      f:metadata:
        f:annotations:
          .: {}
          f:nginx.ingress.kubernetes.io/rewrite-target: {}
          f:nginx.ingress.kubernetes.io/ssl-redirect: {}
      f:spec:
        f:rules: {}
    manager: kubectl-create
    operation: Update
    time: "2021-03-31T12:36:43Z"
  - apiVersion: extensions/v1beta1
    fieldsType: FieldsV1
    fieldsV1:
      f:status:
        f:loadBalancer:
          f:ingress: {}
    manager: nginx-ingress-controller
    operation: Update
    time: "2021-03-31T12:38:20Z"
  name: ingress-wear-watch
  namespace: app-space
  resourceVersion: "1101"
  selfLink: /apis/extensions/v1beta1/namespaces/app-space/ingresses/ingress-wear-watch
  uid: 750199ee-1af5-43ba-a0d4-f3edd1b5ed20
spec:
  rules:
  - http:
      paths:
      - backend:
          serviceName: wear-service
          servicePort: 8080
        path: /wear
        pathType: ImplementationSpecific
      - backend:
          serviceName: video-service
          servicePort: 8080
        path: /watch
        pathType: ImplementationSpecific
status:
  loadBalancer:
    ingress:
    - {}

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

[WEAR-SERVICE]

 

위의 yaml 출력 파일 확인

 

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

[/WATCH]

 

위의 yaml 출력 파일 확인

 

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

[DEFAULT-HTTP-BACKEND]

$ kubectl describe ingress -n app-space

Warning: extensions/v1beta1 Ingress is deprecated in v1.14+, unavailable in v1.22+; use networking.k8s.io/v1 Ingress
Name:             ingress-wear-watch
Namespace:        app-space
Address:          
Default backend:  default-http-backend:80 (<error: endpoints "default-http-backend" not found>)
Rules:
  Host        Path  Backends
  ----        ----  --------
  *           
              /wear    wear-service:8080    10.244.1.4:8080)
              /watch   video-service:8080   10.244.1.3:8080)
Annotations:  nginx.ingress.kubernetes.io/rewrite-target: /
              nginx.ingress.kubernetes.io/ssl-redirect: false
Events:
  Type    Reason  Age   From                      Message
  ----    ------  ----  ----                      -------
  Normal  CREATE  19m   nginx-ingress-controller  Ingress app-space/ingress-wear-watch
  Normal  UPDATE  19m   nginx-ingress-controller  Ingress app-space/ingress-wear-watch

 

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

[404 ERROR PAGE]

 

ㅁ View the applications by appending /wear and /watch to the URL you opend in the previous step

 

$ kubectl describe ingress -n app-space
 
Warning: extensions/v1beta1 Ingress is deprecated in v1.14+, unavailable in v1.22+; use networking.k8s.io/v1 Ingress
Name:             ingress-wear-watch
Namespace:        app-space
Address:          
Default backend:  default-http-backend:80 (<error: endpoints "default-http-backend" not found>)
Rules:
  Host        Path  Backends
  ----        ----  --------
  *           
              /wear    wear-service:8080    10.244.1.4:8080)
              /watch   video-service:8080   10.244.1.3:8080)
Annotations:  nginx.ingress.kubernetes.io/rewrite-target: /
              nginx.ingress.kubernetes.io/ssl-redirect: false
Events:
  Type    Reason  Age   From                      Message
  ----    ------  ----  ----                      -------
  Normal  CREATE  21m   nginx-ingress-controller  Ingress app-space/ingress-wear-watch
  Normal  UPDATE  21m   nginx-ingress-controller  Ingress app-space/ingress-wear-watch

ㅁ  Your are requested to change the URLs at which the applications are made available. 

- Ingress: ingress-wear-watch

- Path: /stream

- Backend Service: video-service

- Backend Service Port: 8080

 

kubectl edit ingress ingress-wear-watch -n app-space

수행 후 아래 부분을

spec:
  rules:
  - http:
      paths:
      - backend:
          serviceName: wear-service
          servicePort: 8080
        path: /wear
        pathType: ImplementationSpecific
      - backend:
          serviceName: video-service
          servicePort: 8080
        path: /watch
        pathType: ImplementationSpecific

 

아래와 같이 수정

spec:
  rules:
  - http:
      paths:
      - backend:
          serviceName: wear-service
          servicePort: 8080
        path: /wear
        pathType: ImplementationSpecific
      - backend:
          serviceName: video-service
          servicePort: 8080
        path: /stream
        pathType: ImplementationSpecific

ㅁ View the video application using the /stream URL in your browser.

[CLICK WEB SITE + /video]

 

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

[404 ERROR PAGE]

 

ㅁ Due to increase demand, your business decides to take on a new venture. You acquired a food d elivery company. Their applications have been migrated over to your cluster. 

(Inspect the new deployments in the app-space)

 

$ kubectl get deployment -n app-space

NAME              READY   UP-TO-DATE   AVAILABLE   AGE
default-backend   1/1     1            1           33m
webapp-food       1/1     1            1           71s
webapp-video      1/1     1            1           33m
webapp-wear       1/1     1            1           33m

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

- Ingress: ingress-wear-watch

- Path: /eat

- Backend Service: food-service

- Backend Service Port: 8080

kubectl edit ingress ingress-wear-watch -n app-space

수행 후 아래와 같이 수정

spec:
  rules:
  - http:
      paths:
      - backend:
          serviceName: wear-service
          servicePort: 8080
        path: /wear
        pathType: ImplementationSpecific
      - backend:
          serviceName: video-service
          servicePort: 8080
        path: /stream
        pathType: ImplementationSpecific
      - backend:
          serviceName: food-service
          servicePort: 8080
        path: /eat

 

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

Identify the namemspace in which the new application is deploy

[CRITICAL-SPACE]

 

$ kubectl get deployment --all-namespaces

NAMESPACE        NAME                       READY   UP-TO-DATE   AVAILABLE   AGE
app-space        default-backend            1/1     1            1           37m
app-space        webapp-food                1/1     1            1           5m31s
app-space        webapp-video               1/1     1            1           37m
app-space        webapp-wear                1/1     1            1           37m
critical-space   webapp-pay                 1/1     1            1           53s
ingress-space    nginx-ingress-controller   1/1     1            1           37m
kube-system      coredns                    2/2     2            2           38m

 

ㅁ What is the name of the deployment of the new application?

[webapp-pay]

 

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

- Ingress Created

- Path: /pay

- Configure correct backend service

- Configure correct backend port

apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  name: ingress-pay-watch
  namespace: critical-space
spec:
  rules:
  - http:
      paths:
      - backend:
          serviceName: pay-service
          servicePort: 8282
        path: /pay
        pathType: ImplementationSpecific

 

'CKA &. CKAD > Networking' 카테고리의 다른 글

Practice Test - CKA - Ingress Networking - 2  (0) 2021.04.01
Ingress - Annotations and rewrite-target  (0) 2021.03.31
INGRESS  (0) 2021.03.31
Practice Test CoreDNS in Kubernetes  (0) 2021.03.31
How kubernetes implement DNS  (0) 2021.03.31