실습
Introduction
Envoy Gateway 설치
helm install eg oci://docker.io/envoyproxy/gateway-helm \ --version v1.0.1 \ --namespace envoy-gateway-system \ --create-namespace
생성된 객체 확인
kubectl get all -n envoy-gateway-system
Envoy Gateway 설정 파일 확인
kubectl get cm -n envoy-gateway-system envoy-gateway-config -o yaml
GatewayClass 목록 확인
kubectl get gatewayclass -A
Envoy Proxy 사용자 지정 설정 추가
cat <<EOF | kubectl apply -f - apiVersion: gateway.envoyproxy.io/v1alpha1 kind: EnvoyProxy metadata: name: custom-proxy-config namespace: envoy-gateway-system spec: provider: type: Kubernetes kubernetes: envoyService: annotations: service.beta.kubernetes.io/aws-load-balancer-type: external service.beta.kubernetes.io/aws-load-balancer-nlb-target-type: ip service.beta.kubernetes.io/aws-load-balancer-scheme: internet-facing EOF
GatewayClass 생성
cat <<EOF | kubectl apply -f - apiVersion: gateway.networking.k8s.io/v1 kind: GatewayClass metadata: name: eg spec: controllerName: gateway.envoyproxy.io/gatewayclass-controller parametersRef: group: gateway.envoyproxy.io kind: EnvoyProxy namespace: envoy-gateway-system name: custom-proxy-config EOF
Gateway 생성
cat <<EOF | kubectl apply -f - apiVersion: gateway.networking.k8s.io/v1 kind: Gateway metadata: name: eg spec: gatewayClassName: eg listeners: - name: http protocol: HTTP port: 80 EOF
생성된 Gateway 확인
kubectl get gateway eg
Envoy Gateway가 설치된 네임스페이스에 추가로 생성된 객체 확인
kubectl get all -n envoy-gateway-system
Gateway의 주소로 접근 시도
curl $(kubectl get gateway eg -o=jsonpath='{.status.addresses[0].value}') -v
데모 애플리케이션 배포
{ kubectl create deployment nginx --image=nginx --port=80 kubectl expose deploy nginx }
HTTPRoute 생성
cat <<EOF | kubectl apply -f - apiVersion: gateway.networking.k8s.io/v1 kind: HTTPRoute metadata: name: nginx spec: parentRefs: - name: eg rules: - backendRefs: - name: nginx port: 80 EOF
생성된 HTTPRoute의 상세 내용 확인
kubectl describe httproute nginx
Gateway 엔드포인트 호출
curl $(kubectl get gateway eg -o=jsonpath='{.status.addresses[0].value}')
HTTPRoute 수정
cat <<EOF | kubectl apply -f - apiVersion: gateway.networking.k8s.io/v1 kind: HTTPRoute metadata: name: nginx spec: parentRefs: - name: eg hostnames: - nginx.example.com rules: - backendRefs: - name: nginx port: 80 EOF
Gateway 엔드포인트 호출
curl $(kubectl get gateway eg -o=jsonpath='{.status.addresses[0].value}') -v
HTTPRoute에 명시한 Host 이름을 HTTP 헤더값에 추가하고 Gateway 엔드포인트 호출
curl -H "Host: nginx.example.com" \ $(kubectl get gateway eg -o=jsonpath='{.status.addresses[0].value}')
리소스 삭제
{ kubectl delete httproute nginx kubectl delete svc nginx kubectl delete deploy nginx kubectl delete gateway eg kubectl delete gatewayclass eg kubectl delete envoyproxy custom-proxy-config -n envoy-gateway-system }
Envoy Gateway가 설치된 네임스페이스의 객체 목록 확인
kubectl get all -n envoy-gateway-system
aaa
Last updated