[Home-K8S] #22 FluxCD 계층과 분리 / 다중 클러스터 리소스 공유와 설정 분리
FluxCD - yaml 앞서 fluxcd 를 이용해서 helm chart 를 구성했습니다. 그 외에 일반적인 yaml
기존에는 flannel CNI를 사용하면서 nginx-ingress 를 사용해 왔지만, cilium 로 변경하면서 Cilium Gateway 로 전환했습니다.
Gateway API 는 k8s 의 Ingress, Load Balancing, Service Mesh APIs 의 차세대 프로젝트로 더 확장 가능한 구조를 가지고 있습니다.
(nginx는 권장하지도 않으면서 annotation 으로 다 해야하는게 별로이긴 합니다.)
kubectl kustomize "github.com/kubernetes-sigs/gateway-api/config/crd?ref=v1.3.0" | kubectl apply -f -cilium install \
--set gatewayAPI.enabled=true \
--set installCRDs=truespec:
acme:
server: https://acme-v02.api.letsencrypt.org/directory
email:
privateKeySecretRef:
name: letsencrypt-prod
solvers:
# - http01:
# ingress:
# ingressClassName: nginx
- http01:
gatewayHTTPRoute:
parentRefs:
- name: cilium-gateway
namespace: cilium
kind: GatewayapiVersion: cert-manager.io/v1
kind: Certificate
metadata:
name: dogring-kr-tls
namespace: cilium
spec:
secretName: dogring-kr-tls
issuerRef:
name: letsencrypt-prod
kind: ClusterIssuer
dnsNames:
- dogring.kr
- www.dogring.kr
# 필요한 서브도메인 추가
usages:
- digital signature
- key enciphermentapiVersion: gateway.networking.k8s.io/v1
kind: Gateway
metadata:
name: cilium-gateway
namespace: cilium
annotations:
cert-manager.io/cluster-issuer: letsencrypt-prod
spec:
gatewayClassName: cilium
listeners:
- name: http
protocol: HTTP
port: 80
allowedRoutes:
namespaces:
from: All
- name: https
port: 443
protocol: HTTPS
allowedRoutes:
namespaces:
from: All
tls:
mode: Terminate
certificateRefs:
- kind: Secret
name: dogring-kr-tls
namespace: ciliumapiVersion: gateway.networking.k8s.io/v1
kind: HTTPRoute
metadata:
name: http-to-https-redirect
namespace: cilium
spec:
parentRefs:
- name: cilium-gateway
namespace: cilium
sectionName: http
rules:
- filters:
- type: RequestRedirect
requestRedirect:
scheme: https
statusCode: 301apiVersion: gateway.networking.k8s.io/v1
kind: HTTPRoute
metadata:
name: app-dogring-kr
namespace: app # App Service 의 namespace
spec:
parentRefs:
- name: cilium-gateway
namespace: cilium # Gateway 의 namespace
sectionName: https # Gateway Listenser name 설정
hostnames:
- dogring.kr # 도메인 설정
rules:
- matches:
- path:
type: PathPrefix
value: /
backendRefs:
- name: app-service
port: 80
namespace: appapiVersion: cilium.io/v2
kind: CiliumEnvoyConfig
metadata:
name: body-size-limit
namespace: cilium
spec:
services:
- name: app-service
namespace: app
resources:
- "@type": type.googleapis.com/envoy.config.route.v3.RouteConfiguration
name: ghost-route
virtual_hosts:
- name: ghost
domains:
- "dogring.kr"
routes:
- match:
prefix: "/"
route:
cluster: app-service
per_filter_config:
envoy.filters.http.buffer:
"@type": type.googleapis.com/envoy.extensions.filters.http.buffer.v3.BufferPerRoute
buffer:
max_request_bytes: 104857600 # 100MB
Comments