# Ingress 테스트 — ext-client(외부 사용자 모사) → ingressgateway → web-a / web-b # # 검증 대상 3가지: # 1) TLS termination: gateway가 사설 CA 발급 인증서(credentialName: www-lab-tls, # istio-system ns의 tls secret — README ②단계에서 생성)로 종단. 폐쇄망은 공인 CA가 # 애초에 불가하므로 사설 CA가 제약이 아니라 정상 경로다. # 2) host 라우팅: www.lab.external 만 이 Gateway가 받는다. # 3) path 라우팅: /b → web-b, 나머지 → web-a (백엔드 2개가 분기 증거). # # HTTP:80도 함께 연다 — CA 배포 전 첫 스모크(평문)와 TLS 경로를 분리해 실패 원인을 # 고립하기 위함(80이 되고 443이 안 되면 인증서·secret 쪽, 둘 다 안 되면 라우팅 쪽). # # web-a/web-b는 nginx가 정체("web-a\n")만 응답하는 최소 백엔드 — sidecar 주입됨(mesh 안). --- apiVersion: v1 kind: ConfigMap metadata: { name: web-a-conf, namespace: lab-apps } data: default.conf: | server { listen 80; default_type text/plain; location / { return 200 "web-a\n"; } } --- apiVersion: v1 kind: ConfigMap metadata: { name: web-b-conf, namespace: lab-apps } data: default.conf: | server { listen 80; default_type text/plain; location / { return 200 "web-b\n"; } } --- apiVersion: apps/v1 kind: Deployment metadata: { name: web-a, namespace: lab-apps, labels: { app: web-a } } spec: replicas: 1 selector: { matchLabels: { app: web-a } } template: metadata: labels: { app: web-a } spec: containers: - name: nginx image: docker.io/library/nginx:1.27-alpine ports: [{ containerPort: 80 }] volumeMounts: - { name: conf, mountPath: /etc/nginx/conf.d/default.conf, subPath: default.conf } volumes: - name: conf configMap: { name: web-a-conf } --- apiVersion: apps/v1 kind: Deployment metadata: { name: web-b, namespace: lab-apps, labels: { app: web-b } } spec: replicas: 1 selector: { matchLabels: { app: web-b } } template: metadata: labels: { app: web-b } spec: containers: - name: nginx image: docker.io/library/nginx:1.27-alpine ports: [{ containerPort: 80 }] volumeMounts: - { name: conf, mountPath: /etc/nginx/conf.d/default.conf, subPath: default.conf } volumes: - name: conf configMap: { name: web-b-conf } --- apiVersion: v1 kind: Service metadata: { name: web-a, namespace: lab-apps } spec: selector: { app: web-a } ports: [{ name: http, port: 80, targetPort: 80 }] --- apiVersion: v1 kind: Service metadata: { name: web-b, namespace: lab-apps } spec: selector: { app: web-b } ports: [{ name: http, port: 80, targetPort: 80 }] --- # Gateway 리소스는 gateway workload와 같은 ns(istio-system)에 둔다 — 60-egress.yaml의 # lab-egress와 동일 규율(PILOT_SCOPE_GATEWAY_TO_NAMESPACE 대비)로 랩 전체 통일. # credentialName secret(www-lab-tls)도 같은 이유로 istio-system에 있다. apiVersion: networking.istio.io/v1beta1 kind: Gateway metadata: name: lab-ingress namespace: istio-system spec: selector: istio: ingressgateway # istio-system의 공용 ingress gateway pod에 바인딩 servers: - port: number: 80 name: http protocol: HTTP hosts: - "www.lab.external" - port: number: 443 name: https protocol: HTTPS tls: mode: SIMPLE credentialName: www-lab-tls # gateway workload ns(istio-system)의 tls secret hosts: - "www.lab.external" --- # VS는 라우팅 대상 앱과 같은 ns(lab-apps)에 두고, 다른 ns의 Gateway는 # / 정규화 형식으로 참조한다. apiVersion: networking.istio.io/v1beta1 kind: VirtualService metadata: name: www-lab namespace: lab-apps spec: hosts: - "www.lab.external" gateways: - istio-system/lab-ingress http: - match: - uri: { prefix: /b } route: - destination: host: web-b.lab-apps.svc.cluster.local port: { number: 80 } - route: - destination: host: web-a.lab-apps.svc.cluster.local port: { number: 80 }