Skip to content

Kustomize

The Windsor CLI facilitates building Kubernetes systems by introducing a rational approach to composing Kubernetes configuration using Flux and Kustomize.

Folder Structure

The following files and folders are relevant when working with Kubernetes in a Windsor project.

contexts/
└── local/
    ├── .kube/
    │   └── config
    └── blueprint.yaml
kustomize/
└── my-app/
    ├── prometheus/
    │   ├── kustomization.yaml
    │   └── service-monitor.yaml
    ├── kustomization.yaml
    ├── deployment.yaml
    └── service.yaml

In this example structure, the app my-app consists of a simple deployment and service. It also includes a Kustomize component. The component pattern is used heavily by the Windsor project. In this example, the component adds Prometheus support.

Blueprint

The following example blueprint.yaml now references my-app:

kind: Blueprint
apiVersion: blueprints.windsorcli.dev/v1alpha1
metadata:
  name: example-project
  description: This blueprint outlines example resources
repository:
  url: http://github.com/my-org/example-project
  ref:
    branch: main
  secretName: flux-system
sources:
- name: core
  url: github.com/windsorcli/core
  ref:
    branch: main
terraform:
- source: core
  path: cluster/talos
- source: core
  path: gitops/flux
kustomize:
- name: my-app
  path: my-app
  components:
    - prometheus

Each entry under kustomize follows the Flux Kustomization spec. As such, you may include patches and any other necessary settings for modifying the behavior of my-app.

When running windsor up --install or windsor install, all Kustomization resources are applied to your cluster. This involves creating GitRepository resources from the corresponding repository and sources, as well as Kustomizations.

You can observe these resources on your cluster by running the following commands,

To see the GitRepository resources run:

kubectl get gitrepository -A

To see Kustomizations, run:

kubectl get kustomizations -A

You will find these all placed in the system-gitops namespace.

Importing Resources

You can import Kustomize resources from remote sources. To import a component from core, add the following under the blueprint's kustomize section:

...
kustomize:
  - name: system-csi
    path: system-csi
    source: core
    components:
      - longhorn

This would result in importing the system-csi resource from core, and specifically using the longhorn driver. By including the source field referencing core, this reference will be used when the Kustomization is generated on your cluster.