Shoulder.dev Logo Shoulder.dev

Understanding the various CRDs available in Flux v2

Flux v2 is a GitOps tool for Kubernetes that enables declarative infrastructure updates. It uses Custom Resource Definitions (CRDs) to extend the Kubernetes API with custom resources. In this documentation, we will cover the various CRDs available in Flux v2, including:

  • GitRepository
  • OCIRepository
  • HelmRepository
  • HelmChart
  • Bucket
  • Kustomization
  • HelmRelease
  • ImageRepository
  • ImagePolicy
  • ImageUpdateAutomation

What is Custom Resource Definitions (CRDs)?

Custom Resource Definitions (CRDs) are a way to extend the Kubernetes API with custom resources. CRDs define a new type of resource that can be managed by Kubernetes. They consist of a schema that defines the structure of the custom resource, and a controller that manages the lifecycle of the resource.

Learn more about CRDs in the Kubernetes documentation

Why is Custom Resource Definitions (CRDs) important?

CRDs are important because they allow you to define custom resources that can be managed by Kubernetes. This enables you to extend the capabilities of Kubernetes to meet the specific needs of your application.

For example, Flux v2 uses CRDs to manage Git repositories, Helm repositories, Helm charts, and more. By defining these resources as CRDs, Flux v2 is able to manage them as first-class citizens in the Kubernetes cluster.

GitRepository

The GitRepository CRD represents a Git repository that Flux can manage. It includes fields for the Git URL, branch, and commit ref.

apiVersion: sourceright.io/v1beta1
      kind: GitRepository
      metadata:
      name: my-repo
      spec:
      url: [email protected]:username/repo.git
      branch: main
      commitRef: refs/heads/main
      

Learn more about the GitRepository CRD in the Flux documentation

OCIRepository

The OCIRepository CRD represents an OCI registry that Flux can manage. It includes fields for the registry URL and the authentication method.

apiVersion: sourceright.io/v1beta1
      kind: OCIRepository
      metadata:
      name: my-registry
      spec:
      url: registry.example.com
      auth:
      ocicredHelper:
      name: my-ocicred-helper
      

Learn more about the OCIRepository CRD in the Flux documentation

HelmRepository

The HelmRepository CRD represents a Helm repository that Flux can manage. It includes fields for the Helm chart repository URL and the chart version.

apiVersion: helm.fluxcd.io/v1beta1
      kind: HelmRepository
      metadata:
      name: my-repo
      spec:
      url: https://example.com/charts
      interval: 30m
      

Learn more about the HelmRepository CRD in the Flux documentation

HelmChart

The HelmChart CRD represents a Helm chart that Flux can manage. It includes fields for the Helm chart repository, chart name, and release name.

apiVersion: helm.fluxcd.io/v1beta1
      kind: HelmChart
      metadata:
      name: my-chart
      spec:
      repository:
      url: https://example.com/charts
      chart:
      name: my-chart
      version: 1.0.0
      release:
      name: my-release
      namespace: my-namespace
      

Learn more about the HelmChart CRD in the Flux documentation

Bucket

The Bucket CRD represents a cloud storage bucket that Flux can manage. It includes fields for the cloud provider, bucket name, and access key.

apiVersion: sourceright.io/v1beta1
      kind: Bucket
      metadata:
      name: my-bucket
      spec:
      provider:
      name: aws
      name: my-bucket
      accessKey: my-access-key
      

Learn more about the Bucket CRD in the Flux documentation

Kustomization

The Kustomization CRD represents a Kustomization file that Flux can manage. It includes fields for the patch files and the base directory.

apiVersion: kustomize.config.k8s.io/v1beta1
      kind: Kustomization
      metadata:
      name: my-kustomization
      spec:
      patches:
      - patch: |
      apiVersion: v1
      kind: Pod
      metadata:
      name: my-pod
      spec:
      containers:
      - name: my-container
      image: my-image
      

Learn more about the Kustomization CRD in the Flux documentation

HelmRelease

The HelmRelease CRD represents a Helm release that Flux can manage. It includes fields for the Helm chart, release name, and namespace.

apiVersion: helm.fluxcd.io/v1beta1
      kind: HelmRelease
      metadata:
      name: my-release
      spec:
      chart:
      repository:
      url: https://example.com/charts
      name: my-chart
      version: 1.0.0
      release:
      name: my-release
      namespace: my-namespace
      

Learn more about the HelmRelease CRD in the Flux documentation

ImageRepository

The ImageRepository CRD represents an image registry that Flux can manage. It includes fields for the registry URL and the authentication method.

apiVersion: sourceright.io/v1beta1
      kind: ImageRepository
      metadata:
      name: my-registry
      spec:
      url: registry.example.com
      auth:
      secretRef:
      name: my-secret
      

Learn more about the ImageRepository CRD in the Flux documentation

ImagePolicy

The ImagePolicy CRD represents an image policy that Flux can manage. It includes fields for the image repository, image tag, and the image scanning provider.

apiVersion: security.fluxcd.io/v1beta1
      kind: ImagePolicy
      metadata:
      name: my-policy
      spec:
      repository:
      url: registry.example.com
      tag: latest
      scan:
      provider:
      name: trivy
      

Learn more about the ImagePolicy CRD in the Flux documentation

ImageUpdateAutomation

The ImageUpdateAutomation CRD represents an image update automation that Flux can manage. It includes fields for the image repository, image tag, and the image scanning provider.

Explanation