# Cilium이 Gateway API를 지원하는지 확인
kubectl get crd | grep gateway
kubectl apply -f https://github.com/kubernetes-sigs/gateway-api/releases/download/v1.0.0/standard-install.yaml
# 간단한 웹 서버 배포
kubectl create deployment nginx --image=nginx
kubectl expose deployment nginx --port=80 --target-port=80
# gateway.yaml 파일 생성
apiVersion: gateway.networking.k8s.io/v1
kind: Gateway
metadata:
name: my-gateway
spec:
gatewayClassName: cilium
listeners:
- protocol: HTTP
port: 80
name: web
kubectl apply -f gateway.yaml
# route.yaml 파일 생성
apiVersion: gateway.networking.k8s.io/v1
kind: HTTPRoute
metadata:
name: nginx-route
spec:
parentRefs:
- name: my-gateway
rules:
- matches:
- path:
type: PathPrefix
value: /
backendRefs:
- name: nginx
port: 80
kubectl apply -f route.yaml
# Gateway IP 확인
kubectl get gateway my-gateway
# 서비스 확인
kubectl get svc | grep gateway
# 테스트 (IP 주소는 위에서 확인한 것 사용)
curl http://[GATEWAY-IP]/
성공하면: nginx 기본 페이지가 보입니다!
Gateway IP가 안 보이면:
# NodePort로 접근
kubectl get svc -o wide | grep gateway
# [NODE-IP]:[NODE-PORT] 로 접근
여전히 안되면:
# 포트포워딩으로 테스트
kubectl port-forward svc/[gateway-service-name] 8080:80
curl http://localhost:8080
끝! 🎉
총 5분이면 Cilium Gateway API가 작동하는지 확인할 수 있습니다.