TrueFoundry allows you to tweak the most common parameters of the deployment through the service spec. However, there might be situations in which you might want to override some fields that are not exposed in the TrueFoundry Service spec. You can then use Kustomize to add, patch or delete the Kubernetes resources that TrueFoundry deploys on the cluster.

Kustomize enables you to

  • Patch the rendered Kubernetes resources generated by the TrueFoundry Application. E.g. Adding extra annotations for Prometheus / Datadog
  • Add extra Kubernetes resources along with your TrueFoundry Application. E.g. Adding extra ConfigMap, Secret, Istio VirtualService, etc

Supported Application Types

  • Service
  • Job
  • Helm

Using Kustomize

You can add patches and resources using the kustomize field of the spec

Resources are patched/added in the same namespace

Patches and new resources are applied to the same namespace as the application

Here is an example that

  1. Adds Prometheus scrape annotations to the pod spec patches in Kubernetes Deployment resource that will be generated for the Service. Here we use the patch section of the kustomize because we only want to add extra annotations to an existing resource.
  2. Adds a new complete ConfigMap resource. Here we use additions as we define the complete spec of the new resource.

Viewing Resources Generated by TrueFoundry

You can view all the resources rendered by the Application in the Application Spec Tab and then selecting Applied K8s Manifest

type: service
name: my-service
image:
  type: image
  image_uri: nginx:latest
  ...
ports:
  - port: 8000
    ...
kustomize:
  patch:
    patchesStrategicMerge:
      - |
        kind: Deployment
        apiVersion: apps/v1
        metadata:
          name: my-service
          namespace: my-workspace-name # Note that this is workspace name. Not FQN.
        spec:
          template:
            metadata:
              annotations:
                prometheus.io/port: "8000"
                prometheus.io/scrape: "true"
  additions:
    - apiVersion: v1
      data:
        test: data
      kind: ConfigMap
      metadata:
        name: configmap-1

Data Types

  • kustomize.patch is an object. The most commonly used key under it is patchesStrategicMerge which is a list of strings. Each string member is a patch in YAML format
  • kustomize.additions is a list of objects. Each object is a Kubernetes resource definition.

You can configure the same using the UI by enabling the Advanced Fields and then enabling Kustomize