Table of Contents
Kubernetes – ingress-nginx 디버깅하기
argocd 를 예제로 ingress-nginx 디버깅하는 방법을 정리해 봅니다.
정말 ingress-nginx 문제일까?
ingress-nginx 를 의심하기 전에 먼저 서비스는 정상적으로 작동중인지 확인합니다.
CNI 작동 테스트
Ready 상태인지 확인합니다.
kubectl get nodes
NAME STATUS ROLES AGE VERSION
es-search01 Ready control-plane 12d v1.26.0
es-search02 Ready control-plane 12d v1.26.0
es-search03 Ready control-plane 12d v1.26.0
es-search04 Ready <none> 12d v1.26.0
es-search05 Ready <none> 12d v1.26.0
Calico
curl -L https://github.com/projectcalico/calico/releases/download/v3.24.5/calicoctl-linux-amd64 -o calicoctl
chmod 700 calicoctl
sudo mv calicoctl /usr/bin/
sudo calicoctl node status
Calico process is running.
IPv4 BGP status
+--------------+-------------------+-------+------------+-------------+
| PEER ADDRESS | PEER TYPE | STATE | SINCE | INFO |
+--------------+-------------------+-------+------------+-------------+
| 172.16.0.202 | node-to-node mesh | up | 2023-01-10 | Established |
| 172.16.0.203 | node-to-node mesh | up | 2023-01-10 | Established |
| 172.16.0.204 | node-to-node mesh | up | 2023-01-10 | Established |
| 172.16.0.205 | node-to-node mesh | up | 2023-01-10 | Established |
+--------------+-------------------+-------+------------+-------------+
IPv6 BGP status
No IPv6 peers found.
flannel
ip -4 a | grep inet
inet 127.0.0.1/8 scope host lo
inet 192.168.122.77/24 brd 192.168.122.255 scope global dynamic eth0
inet 18.16.29.0/16 scope global flannel.1
inet 18.16.29.1/24 scope global docker0
weave
kubectl get pods --all-namespaces
NAMESPACE NAME READY STATUS RESTARTS AGE
[...]
kube-system weave-net-4mylt 2/2 Running 0 18m
kube-system weave-net-dwueb 2/2 Running 0 18m
kube-system weave-net-tj1xv 2/2 Running 0 18m
Pod 접속 테스트
master node
kubectl get pods -n argocd -o wide
NAME READY STATUS RESTARTS AGE IP NODE NOMINATED NODE READINESS GATES
argocd-server-66fcf976bf-zhk2c 1/1 Running 0 97m 192.168.140.8 es-search05 <none> <none>
worker node
Pod 접속은 worker node 에서만 가능합니다.
도커 이미지상의 포트를 미리 확인해 놓습니다.
curl http://192.168.140.8:8080/
리턴이 오면 정상입니다.
서비스 디버깅
master node
kubectl get svc -n argocd -o wide
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE SELECTOR
argocd-server ClusterIP 10.103.116.185 <none> 80/TCP,443/TCP 21h app.kubernetes.io/name=argocd-server
worker node
서비스 접속도 worker node 에서만 가능합니다.
curl http://10.103.116.185/
리턴이 오면 정상입니다.
방화벽 쪽 디버깅
외부에서 접속을 시도해 봅니다.
하다못해 nginx 오류 페이지 조차 안나오면 방화벽 문제 또는 ingress-nginx 설정 자체가 문제입니다.
더불어 nginx 오류 페이지가 나오긴 하는데 한참 걸려 나오면 역시나 방화벽 문제입니다.
이 경우는 A 서버만 방화벽 오픈하고 B 서버는 열지 않았는데 Pod 가 B 서버에 있어서 막히는 케이스입니다.
ingress-nginx 살펴보기
여기 를 참조하여 ingress-nginx 가 구성된 상태입니다.
argocd-server:80 (192.168.140.8:8080)
와 같이 정확히 서비스 포트와 Pod 포트를 표시하고 있으면 정상이라고 보면 됩니다.
kubectl describe ing ingress-argocd -n argocd
Name: ingress-argocd
Labels: <none>
Namespace: argocd
Address: 172.16.0.101,172.16.0.102,172.16.0.103,172.16.0.104,172.16.0.105
Ingress Class: <none>
Default backend: <default>
TLS:
argocd-argocd-svc-cluster-local terminates argocd.argocd.svc.cluster.local
Rules:
Host Path Backends
---- ---- --------
argocd.argocd.svc.cluster.local
/ argocd-server:80 (192.168.140.8:8080)
Annotations: kubernetes.io/ingress.class: nginx
Events:
Type Reason Age From Message
---- ------ ---- ---- -------
Normal Sync 33m (x2 over 33m) nginx-ingress-controller Scheduled for sync