This folder contains examples of k8s manifests to set up kubernetes gateways for Prod and Dev environments. Environments placed to different namespaces. Gateways configured to be bind only to particular namespaces for isolation. TLS secrets placed to separate namespace.
- Managed Kubernetes Cluster in Yandex Cloud.
- Installed and initialized yc cli.
- Public domain deletated to Cloud DNS service by Yandex Cloud.
- Install Gateway API from Marketplace. In console go to Managed Service for Kubernetes -> (Select your cluster) -> Marketplace -> Gateway API -> Use.
- Fill all necessary fields and install Gateway API.
yc vpc address create --name=prod --labels reserved=true --external-ipv4 zone=ru-central1-b # change to zone of your cluster
yc vpc address create --name=dev --labels reserved=true --external-ipv4 zone=ru-central1-b # change to zone of your clusteryc dns zone add-records --name my-domain --record '*.prod.example.com 60 A <ip_address>'
yc dns zone add-records --name my-domain --record '*.dev.example.com 60 A <ip_address>'Create separate namespace for tls secrets.
kubectl create namespace gateway-api-tls-secretsCreate certificate for prod gateway.
openssl req -x509 \
-newkey rsa:4096 \
-keyout gateway-key-prod.pem \
-out gateway-cert-prod.pem \
-nodes \
-days 365 \
-subj '/CN=*.prod.example.com'
kubectl create -n gateway-api-tls-secrets secret tls gateway-prod-tls \
--cert=gateway-cert-prod.pem \
--key=gateway-key-prod.pemCreate certificate for dev gateway.
openssl req -x509 \
-newkey rsa:4096 \
-keyout gateway-key-dev.pem \
-out gateway-cert-dev.pem \
-nodes \
-days 365 \
-subj '/CN=*.dev.example.com'
kubectl create -n gateway-api-tls-secrets secret tls gateway-dev-tls \
--cert=gateway-cert-dev.pem \
--key=gateway-key-dev.pemReplace <ip_address> in yaml files to real IPs created earlier and change example.com to your domains.
kubectl apply prod-gw.yaml
kubectl apply prod-app.yaml
kubectl apply prod-route.yaml
kubectl apply dev-gw.yaml
kubectl apply dev-app.yaml
kubectl apply dev-route.yamlCheck applications on app.prod.example.com and app.dev.example.com.