This document provides a step-by-step guide on how to build and start the fluxcd/flux2-kustomize-helm-example
project. Follow the instructions closely to set up your environment and get the project running.
Prerequisites
Kubernetes Cluster: You need a Kubernetes cluster version 1.28 or newer. For a local test, you can use Kubernetes kind, but any Kubernetes setup will work.
GitHub Account: Create a personal access token that has permissions to create repositories (ensure all permissions under
repo
are checked).Flux CLI Installation:
- For macOS or Linux, install the Flux CLI using Homebrew:
brew install fluxcd/tap/flux
- Alternatively, download the precompiled binaries with:
curl -s https://fluxcd.io/install.sh | sudo bash
- For macOS or Linux, install the Flux CLI using Homebrew:
Step-by-Step Instructions
1. Fork the Repository
First, fork the fluxcd/flux2-kustomize-helm-example
repository to your personal GitHub account.
2. Set Up Environment Variables
Export your GitHub access token, username, and repository name. Replace the placeholders with your actual values.
export GITHUB_TOKEN=<your_github_token>
export GITHUB_USER=<your_github_username>
export GITHUB_REPO=<your_github_repo_name>
3. Clone the Repository Locally
Clone your forked repository to your local machine:
git clone https://github.com/${GITHUB_USER}/${GITHUB_REPO}.git
cd ${GITHUB_REPO}
4. Prepare the Cluster Configuration
To add a cluster to your fleet:
Create a directory inside
clusters
for your cluster name:mkdir -p clusters/dev
Copy the sync manifests from the staging configuration:
cp clusters/staging/infrastructure.yaml clusters/dev cp clusters/staging/apps.yaml clusters/dev
(Optional) Create a dev overlay inside
apps
. Ensure to change thespec.path
insideclusters/dev/apps.yaml
:# Change the path in apps.yaml to point to the new overlay spec: path: ./apps/dev
5. Commit and Push Changes
After configuring your cluster, push the changes to the main branch:
git add -A && git commit -m "add dev cluster" && git push
6. Verify the Staging Cluster
Check that your staging cluster meets all prerequisites:
flux check --pre
7. Bootstrap Flux for Staging
Set the kubectl context to your staging cluster and execute the bootstrap command:
flux bootstrap github \
--context=staging \
--owner=${GITHUB_USER} \
--repository=${GITHUB_REPO} \
--branch=main \
--personal \
--path=clusters/staging
This command will:
- Commit the manifests for the Flux components in the
clusters/staging/flux-system
directory. - Create a deploy key with read-only access on GitHub to allow pulling changes inside the cluster.
8. (Optional) Bootstrap Flux for Development Cluster
To bootstrap the Flux for the development cluster, switch to the development context:
flux bootstrap github \
--context=dev \
--owner=${GITHUB_USER} \
--repository=${GITHUB_REPO} \
--branch=main \
--personal \
--path=clusters/dev
Conclusion
Following the steps above will set up the fluxcd/flux2-kustomize-helm-example
project with the necessary configurations for both staging and development clusters. Ensure that you have completed each step carefully to avoid common pitfalls that can occur during setup.
For additional details and commands, visit the official Flux documentation.