배포된 ingress resource의 이름은 무엇인가요?
controlplane ~ ➜ kubectl get ingress -A
NAMESPACE NAME CLASS HOSTS ADDRESS PORTS AGE
app-space ingress-wear-watch <none> * 172.20.49.254 80 16m
ingress resource의 host는 무엇으로 설정되어 있나요?
HOSTS는 *이므로 All hosts
/wear path에 설정된 backend는 어떤 것인가요?
controlplane ~ ✖ kubectl describe ingress ingress-wear-watch -n app-space
Name: ingress-wear-watch
Labels: <none>
Namespace: app-space
Address: 172.20.49.254
Ingress Class: <none>
Default backend: <default>
Rules:
Host Path Backends
---- ---- --------
*
/wear wear-service:8080 (172.17.0.4:8080)
/watch video-service:8080 (172.17.0.5:8080)
Annotations: nginx.ingress.kubernetes.io/rewrite-target: /
nginx.ingress.kubernetes.io/ssl-redirect: false
Events:
Type Reason Age From Message
---- ------ ---- ---- -------
Normal Sync 20m (x2 over 20m) nginx-ingress-controller Scheduled for sync
/stream path를 통해 video service를 접속 가능하게 하세요
Ingress: ingress-wear-watch
Path: /stream
Backend Service: video-service
Backend Service Port: 8080
controlplane ~ ✖ kubectl edit ingress ingress-wear-watch -n app-space
# Please edit the object below. Lines beginning with a '#' will be ignored,
# and an empty file will abort the edit. If an error occurs while saving this file will be
# reopened with the relevant failures.
#
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
annotations:
nginx.ingress.kubernetes.io/rewrite-target: /
nginx.ingress.kubernetes.io/ssl-redirect: "false"
creationTimestamp: "2025-01-07T09:00:20Z"
generation: 1
name: ingress-wear-watch
namespace: app-space
resourceVersion: "793"
uid: 1f866776-0aff-471d-bf79-2892d73b9a84
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
status:
loadBalancer:
ingress:
- ip: 172.20.49.254
or
controlplane ~ ➜ kubectl get ingress ingress-wear-watch -n app-space -o yaml > ./ingress.yaml
controlplane ~ ➜ ls
ingress.yaml
controlplane ~ ➜ vim ingress.yaml
controlplane ~ ➜ kubectl apply -f ingress.yaml --force
manifest를 직접 수정
/eat path에 backend를 할당하세요
Ingress: ingress-wear-watch
Path: /eat
Backend Service: food-service
Backend Service Port: 8080
controlplane ~ ➜ kubectl get svc -n app-space
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
default-backend-service ClusterIP 172.20.196.54 <none> 80/TCP 48m
food-service ClusterIP 172.20.167.205 <none> 8080/TCP 2m5s
video-service ClusterIP 172.20.64.190 <none> 8080/TCP 48m
wear-service ClusterIP 172.20.178.95 <none> 8080/TCP 48m
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
annotations:
nginx.ingress.kubernetes.io/rewrite-target: /
nginx.ingress.kubernetes.io/ssl-redirect: "false"
creationTimestamp: "2025-01-07T09:00:20Z"
generation: 1
name: ingress-wear-watch
namespace: app-space
resourceVersion: "793"
uid: 1f866776-0aff-471d-bf79-2892d73b9a84
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
status:
loadBalancer:
ingress:
- ip: 172.20.49.254
controlplane ~ ➜ kubectl apply -f ingress.yaml --force
ingress.networking.k8s.io/ingress-wear-watch configured
/pay path에 새로운 service를 할당하세요
Ingress Created
Path: /pay
Configure correct backend service
Configure correct backend port
먼저 네임스페이스를 찾고
controlplane ~ ➜ kubectl get deploy -A
NAMESPACE NAME READY UP-TO-DATE AVAILABLE AGE
app-space default-backend 1/1 1 1 50m
app-space webapp-food 1/1 1 1 3m55s
app-space webapp-video 1/1 1 1 50m
app-space webapp-wear 1/1 1 1 50m
critical-space webapp-pay 1/1 1 1 58s
ingress-nginx ingress-nginx-controller 1/1 1 1 50m
kube-system coredns 2/2 2 2 52m
네임스페이스에서 svc의 이름을 찾음
controlplane ~ ➜ kubectl get svc -n critical-space
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
pay-service ClusterIP 172.20.150.176 <none> 8282/TCP 2m16s
귀찮으니 네임스페이스를 옮기고
controlplane ~ ➜ kubectl config set-context --current --namespace=critical-space
Context "kubernetes-admin@kubernetes" modified.
controlplane ~ ➜ kubectl get svc
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
pay-service ClusterIP 172.20.150.176 <none> 8282/TCP 4m49s
controlplane ~ ➜ kubectl get ingress
No resources found in critical-space namespace.
ingress가 없으니 만들어주자
*** 여기서 주의해야할 점은, get svc를 했을 때 PORT가 8080이 아닌 8282로 되어있음
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: critical-space
spec:
rules:
- http:
paths:
- backend:
service:
name: pay-service
port:
number: 8282
path: /pay
pathType: Prefix
controlplane ~ ➜ kubectl apply -f ingress.yaml --force
ingress.networking.k8s.io/ingress-wear-watch configured
'DevOps' 카테고리의 다른 글
CKA 예제 리마인더 - 33. Cluster Installation using Kubeadm (0) | 2025.01.09 |
---|---|
CKA 예제 리마인더 - 32. Ingress Networking - 2 (0) | 2025.01.08 |
CKA 예제 리마인더 - 30. Service Networking (0) | 2025.01.03 |
CKA 예제 리마인더 - 29. Networking Weave (0) | 2025.01.03 |
CKA 예제 리마인더 - 28. CNI (0) | 2024.12.19 |