Code Monkey home page Code Monkey logo

yc-mk8s-gateway-api-samples's Introduction

Gateway API usecases for Managed Kubernetes

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.

Prerequires

  • Managed Kubernetes Cluster in Yandex Cloud.
  • Installed and initialized yc cli.
  • Public domain deletated to Cloud DNS service by Yandex Cloud.

Gateway installation

  • 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.

Example of Prod and Dev gateways and environments

Create reserved IP addresses

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 cluster

Create prod and dev records to your zone

yc 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 tls certificate (optional) and separate namespace for tls secrets

Create separate namespace for tls secrets.

kubectl create namespace gateway-api-tls-secrets

Create 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.pem

Create 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.pem

Configure your IP adresses and domains

Replace <ip_address> in yaml files to real IPs created earlier and change example.com to your domains.

Apply manifests

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.yaml

Check applications

Check applications on app.prod.example.com and app.dev.example.com.

yc-mk8s-gateway-api-samples's People

Contributors

nettworker avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.