GAP Documentation
GitHub Toggle Dark/Light/Auto mode Toggle Dark/Light/Auto mode Toggle Dark/Light/Auto mode Back to homepage

Applying patches

When some feature is missing from the gap.yaml it is possible to patch the generated kubernetes manifests with patch files. Patching is applied as the last stage of the manifest generation. All yaml files prefixed with gap_patch_* are included for the actual environment. These patch files have to be valid Kubernetes yaml files. You can find more information about kustomize patches in the docs.

It’s important to have the following fields in the patch yaml matching to the yaml file you want to modify.

apiVersion: your-resource-api-version
kind: your-resource-kind
metadata:
  name: your-resource-name
  • apiVersion: the api version has to be the following depending on the kind type:
    • Deployment, Service: apps/v1
    • Ingress: networking.k8s.io/v1
  • kind: the kubernetes resource type
  • name: the name of your resource is constructed in the following way: {appName}-{deployments[i].name}.

For example consider the following gap.yaml file (gap-setup):

name: my-application
namespace: default
deployments:
  web:
    ingress: 
      enabled: true
    command: ["node", "web/index.js"]
  worker:
    command: ["node", "worker/index.js"]

In this example you get the following name for your web deployment/service/ingress: my-application-web

Place your patch yaml file in the gap/ folder to be applied on both environments or the environment folder (gap/production or gap/staging) depending on your needs.

Example patches

You can define your patches in a single file. You need to separate your yaml definitions with ---.
  • Changing Replicas
# gap/gap_patch_deployments.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
  name: my-application-someworker
spec:
  replicas: 0
---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: my-application-otherworker
spec:
  replicas: 2
  • Changing CronJob limits
# gap/gap_patch_cronjobs.yaml
apiVersion: batch/v1
kind: CronJob
metadata:
  # the name of the cronjob is based on the applicationName specified in gap.yaml, with an added "-periodic-job" at the end
  name: my-application-periodic-job
spec:
  jobTemplate:
    spec:
      template:
        spec:
          containers:
          - name: periodic-job
            resources:
              limits:
                cpu: "1"
                memory: 1000Mi
              requests:
                cpu: "1"
                memory: 500Mi
  • Changing deployment limits
# gap/gap_patch_deployments.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
  name: my-application-web
spec:
  template:
    spec:
      containers:
        - name: web
          resources:
            limits:
              cpu: 2000m
              memory: 5000Mi
            requests:
              cpu: 1000m
              memory: 2500Mi