KILLERCODA - CKAD - Ingress Create 오답노트

hyereen·2025년 2월 1일

Kubernetes

목록 보기
44/53

1
There are two existing Deployments in Namespace world which should be made accessible via an Ingress.
First: create ClusterIP Services for both Deployments for port 80 . The Services should have the same name as the Deployments.

정답

  • 네임스페이스를 빼먹지 말자
k -n world expose deploy europe --port 80
k -n world expose deploy asia --port 80

2
The Nginx Ingress Controller has been installed.
Create a new Ingress resource called world for domain name world.universe.mine . The domain points to the K8s Node IP via /etc/hosts .
The Ingress resource should have two routes pointing to the existing Services:
http://world.universe.mine:30080/europe/
and
http://world.universe.mine:30080/asia/

정답

  • ingressClassName: nginx # k get ingressclass 이 부분 빼먹으면 틀린다.
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: world
  namespace: world
spec:
  ingressClassName: nginx # k get ingressclass
  rules:
  - host: "world.universe.mine"
    http:
      paths:
      - path: /europe
        pathType: Prefix
        backend:
          service:
            name: europe
            port:
              number: 80
      - path: /asia
        pathType: Prefix
        backend:
          service:
            name: asia
            port:
              number: 80

0개의 댓글