Search code examples
kubernetesyamlskaffold

Kubernetes Ingress Skaffold Documentation


I am trying to add ingress to my Kubernetes documentation. I was able to add the ingress.yaml file, and there is plenty of documentation on ingress.yaml, but I am using a skaffold.yaml to handle the nitty-gritty of the Kubernetes deployment. And I cannot find any documentation on creating a skaffold file for ingress. ( that simply uses googleCloudBuild, buildpacks, and minikube ) all the documentation I come across is for NGINX.

My project looks like the following:

kubernetes-manifests:
--- frontend_service.deployment.yaml
--- frontend_service.service.yaml 
--- ingress.yaml
--- login_service.deployment.yaml
--- login_service.service.yaml
--- recipes_service.deployment.yaml
--- recipes_service.service.yaml

and my current skaffold file is the following:

apiVersion: skaffold/v2beta4
kind: Config
build:
  tagPolicy:
    sha256: {}
  # defines where to find the code at build time and where to push the resulting image
  artifacts:
  - image: frontend-service
    context: src/frontend
  - image: login-service
    context: src/login
  - image: recipes-service
    context: src/recipes
# defines the Kubernetes manifests to deploy on each run
deploy:
  kubectl:
    manifests:
    - ./kubernetes-manifests/*.service.yaml
    - ./kubernetes-manifests/*.deployment.yaml
profiles:
# use the cloudbuild profile to build images using Google Cloud Build
- name: cloudbuild
  build:
    googleCloudBuild: {}
- name: buildpacks
  build:
    artifacts:
    - image: frontend-service
      context: src/frontend
      buildpack:
        builder: "gcr.io/buildpacks/builder:v1"
    - image: login-service
      context: src/login
      buildpack:
        builder: "gcr.io/buildpacks/builder:v1"
    - image: recipes-service
      context: src/recipes
      buildpack:
        builder: "gcr.io/buildpacks/builder:v1"

This current skaffold file does not deploy in an ingress architecture, it uses a backend and a frontend tier.


Solution

  • Ingress definitions are just Kubernetes Resources, so you just add your ingress.yaml into the manifests to be deployed:

    deploy:
      kubectl:
        manifests:
        - ./kubernetes-manifests/ingress.yaml
        - ./kubernetes-manifests/*.service.yaml
        - ./kubernetes-manifests/*.deployment.yaml