Terraform GitOps demo repository. In this repository I am going to demonstrate how to use a GitOps approach to Terraform and Kubernetes.
You can review the CI/CD implementation in the workflows directory. The scripts to setup the Terraform backend are located in hack. Terraform templates for Resource Groups and reusable modules are located in terraform. Kubernetes GitOps configuration files are located in clusters, Flux is used to provision Kubernetes manifests.
File | Description |
---|---|
workflows | CI/CD documentation |
hack | Scripts documentation |
terraform | Terraform documentation |
clusters | Kubernetes documentation |
docs | General & tools documentation |
Review the variables.sh script and run the setup.sh
az login
chmod +x ./hack/login.sh
chmod +x ./hack/variables.sh
chmod +x ./hack/secrets.sh
chmod +x ./hack/setup.sh
# Source the variables
source ./hack/variables.sh
# Create the initial environment
./hack/setup.sh
Make sure the pipeline is configured correctly, create AZURE_CREDENTIALS
inside of the GitHub action using the service principal created.
After kubernetes is setup run flux.sh, create a Personal access tokens via Settings/Developer settings/Personal access tokens
# Create a personal access token for GitHub
GITHUB_TOKEN=$GITHUB_TOKEN
# Setup gitops
./hack/flux.sh