Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Terraform install example #58

Merged
merged 2 commits into from
Jul 2, 2024
Merged

Add Terraform install example #58

merged 2 commits into from
Jul 2, 2024

Conversation

stefanprodan
Copy link
Member

@stefanprodan stefanprodan commented Jul 1, 2024

This PR adds an example under config/terraform to demonstrate how to deploy Flux on a Kubernetes cluster using Terraform and the flux-operator and flux-instance Helm charts.

Note

The flux-instance Helm chart is needed because the Hashicorp Kubernetes provider can't do CRDs and CRs in the same module, xref: hashicorp/terraform-provider-kubernetes#1367

Usage

Create a Kubernetes cluster using KinD:

kind create cluster --name flux

Install the Flux Operator and deploy the Flux instance on the cluster:

terraform apply \
  -var flux_version="2.x" \
  -var flux_registry="ghcr.io/fluxcd" \
  -var git_token="${GITHUB_TOKEN}" \
  -var git_url="https://github.com/fluxcd/flux2-kustomize-helm-example.git" \
  -var git_ref="refs/heads/main" \
  -var git_path="clusters/production"

Verify the Flux components are running:

kubectl -n flux-system get pods

Verify the Flux instance is syncing the cluster state from the Git repository:

kubectl -n flux-system get fluxreport/flux -o yaml

The output should show the sync status:

apiVersion: fluxcd.controlplane.io/v1
kind: FluxReport
metadata:
  name: flux
  namespace: flux-system
spec:
  # Distribution status omitted for brevity
  sync:
    id: kustomization/flux-system
    path: clusters/production
    ready: true
    source: https://github.com/fluxcd/flux2-kustomize-helm-example.git
    status: 'Applied revision: refs/heads/main@sha1:21486401be9bcdc37e6ebda48a3b68f8350777c9'

Signed-off-by: Stefan Prodan <[email protected]>
@stefanprodan stefanprodan added the documentation Improvements or additions to documentation label Jul 1, 2024
@stefanprodan stefanprodan merged commit d40e28f into main Jul 2, 2024
1 check passed
@stefanprodan stefanprodan deleted the terraform-example branch July 2, 2024 06:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant