1. We have deployed Ingress Controller, resources and applications. Explore the setup. Note: They are in different namespaces.
2. Which namespace is the Ingress Controller deployed in?
controlplane ~ ➜ k get svc -A
NAMESPACE NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
app-space default-backend-service ClusterIP 10.104.20.70 <none> 80/TCP 86s
app-space video-service ClusterIP 10.102.150.175 <none> 8080/TCP 86s
app-space wear-service ClusterIP 10.102.69.69 <none> 8080/TCP 86s
default kubernetes ClusterIP 10.96.0.1 <none> 443/TCP 2m5s
ingress-nginx ingress-nginx-controller NodePort 10.107.35.179 <none> 80:30080/TCP,443:32103/TCP 85s
ingress-nginx ingress-nginx-controller-admission ClusterIP 10.109.191.166 <none> 443/TCP 85s
kube-system kube-dns ClusterIP 10.96.0.10 <none> 53/UDP,53/TCP,9153/TCP 2m2s
answer : ingress-nginx
3. What is the name of the Ingress Controller Deployment?
2번 참조
answe : ingress-nginx-controller
4. Which namespace are the applications deployed in?
2번참조
answer : app-space
5. How many applications are deployed in the app-space namespace? Count the number of deployments in this namespace.
controlplane ~ ➜ k get pods -n app-space
NAME READY STATUS RESTARTS AGE
default-backend-78f6fb8b4-rlqhm 1/1 Running 0 4m45s
webapp-video-74bdc86cb8-25zwb 1/1 Running 0 4m45s
webapp-wear-6f8947f6cc-j4dcf 1/1 Running 0 4m45s
answer : 3
6. Which namespace is the Ingress Resource deployed in?
controlplane ~ ➜ k get ingress -A
NAMESPACE NAME CLASS HOSTS ADDRESS PORTS AGE
app-space ingress-wear-watch <none> * 10.107.35.179 80 5m45s
answer : app-space
7. What is the name of the Ingress Resource?
6번 참조
answer : ingress-wear-watch
8. What is the Host configured on the Ingress Resource? The host entry defines the domain name that users use to reach the application like http://www.google.com
answer : All Host(*)
9. What backend is the /wear path on the Ingress configured with?
controlplane ~ ➜ k get ingress -n app-space ingress-wear-watch -o yaml
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
annotations:
nginx.ingress.kubernetes.io/rewrite-target: /
nginx.ingress.kubernetes.io/ssl-redirect: "false"
creationTimestamp: "2024-08-13T12:36:28Z"
generation: 1
name: ingress-wear-watch
namespace: app-space
resourceVersion: "675"
uid: 565b2e8c-394c-4154-bb39-dcc2241cd2ac
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
status:
loadBalancer:
ingress:
- ip: 10.107.35.179
answer : wear-service
10. At what path is the video streaming application made available on the Ingress?
answer : /watch
11. If the requirement does not match any of the configured paths in the Ingress, to which service are the requests forwarded?
default-backend 의 정보를 알려면 ingress 가 배포된 deploy 를 확인해야 한다.
controlplane ~ ➜ k get deployments.apps -A
NAMESPACE NAME READY UP-TO-DATE AVAILABLE AGE
app-space default-backend 1/1 1 1 15m
app-space webapp-video 1/1 1 1 15m
app-space webapp-wear 1/1 1 1 15m
ingress-nginx ingress-nginx-controller 1/1 1 1 15m
kube-system coredns 2/2 2 2 16m
controlplane ~ ➜ k get deployments.apps -n ingress-nginx ingress-nginx-controller -o yaml
apiVersion: apps/v1
kind: Deployment
metadata:
annotations:
deployment.kubernetes.io/revision: "1"
creationTimestamp: "2024-08-13T12:36:28Z"
generation: 1
...
spec:
containers:
- args:
- /nginx-ingress-controller
- --publish-service=$(POD_NAMESPACE)/ingress-nginx-controller
- --election-id=ingress-controller-leader
- --watch-ingress-without-class=true
- --default-backend-service=app-space/default-backend-service
answer: default-bakend-service
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.
answer : 404 Erorr page
13. View the applications by appending /wear and /watch to the URL you opened in the previous step.
14. You are requested to change the URLs at which the applications are made available. Make the video application available at /stream.
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
annotations:
nginx.ingress.kubernetes.io/rewrite-target: /
nginx.ingress.kubernetes.io/ssl-redirect: "false"
creationTimestamp: "2024-08-13T12:36:28Z"
generation: 1
name: ingress-wear-watch
namespace: app-space
resourceVersion: "675"
uid: 565b2e8c-394c-4154-bb39-dcc2241cd2ac
spec:
rules:
- http:
paths:
- backend:
service:
name: wear-service
port:
number: 8080
path: /wear
pathType: Prefix
- backend:
service:
service:
name: video-service
port:
number: 8080
path: /stream ## 수정
pathType: Prefix
status:
loadBalancer:
ingress:
- ip: 10.107.35.179
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
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.
answer 404 Error page
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.
controlplane ~ ➜ k get deployments.apps -n app-space
NAME READY UP-TO-DATE AVAILABLE AGE
default-backend 1/1 1 1 25m
webapp-food 1/1 1 1 21s
webapp-video 1/1 1 1 25m
webapp-wear 1/1 1 1 25m
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.
위에 수정한 ingress-modify.yaml 안에 path를 추가함.
...
- 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.
아까는 안보이던 화면이 보임.
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.
controlplane ~ ➜ k get svc -A
NAMESPACE NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
critical-space pay-service ClusterIP 10.105.248.78 <none> 8282/TCP 36s
...
answer : critical-space
21. What is the name of the deployment of the new application?
controlplane ~ ➜ k get deployments.apps -n critical-space
NAME READY UP-TO-DATE AVAILABLE AGE
webapp-pay 1/1 1 1 2m35s
answer : webapp-pay
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.
controlplane ~ ➜ k get svc -n critical-space
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
pay-service ClusterIP 10.105.248.78 <none> 8282/TCP 8m9s
# namespace : critical-space
# port : 8282
# name : pay-service
...
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
annotations:
nginx.ingress.kubernetes.io/use-regex: "true"
nginx.ingress.kubernetes.io/rewrite-target: /$2
name: ingress-pay-service
namespace: critical-space
spec:
ingressClassName: nginx
rules:
- http:
paths:
- path: /pay
pathType: Prefix
backend:
service:
name: pay-service
port:
number: 8282
controlplane ~ ➜ k apply -f ingress-critical-space.yaml
ingress.networking.k8s.io/ingress-pay-service created
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.
웹확인 완료.,
'IT 기술 > k8s' 카테고리의 다른 글
[cka] Cluster Installation using Kubeadm (0) | 2024.08.25 |
---|---|
[cka] Ingress Networking - 2 (0) | 2024.08.13 |
[cka] CoreDNS in Kubernetes (0) | 2024.08.10 |
[cka] Service Networking (0) | 2024.08.09 |
[cka] Networking Weave (0) | 2024.08.09 |
댓글