/kubula

Repo holding Flux state for bootstrapping clusters

Primary LanguageShell

Kubula - Flux Bootstrapper for Kubernetes

Kubula

What is Kubula?

Kubula is a tool that helps you bootstrap your Kubernetes cluster using Flux. It is a wrapper around Flux that helps you get started with Flux and Kubernetes.

Components

  • Argo CD
  • Prometheus

Prerequisites

Bootstrap

This repository will serve as the source of truth for your cluster. You can clone this repository, change the remote, make changes to it and commit. The changes will be applied to your cluster.

  1. Install flux CLI. Follow these instructions: https://fluxcd.io/docs/installation/
  2. Create PAT (Personal Access Token) with repo scope from GitHub
  3. Bootstrap
export GITHUB_TOKEN=<your-token>
export GITHUB_USER=<your-username>
export GITHUB_REPO=<your-repo>
export CLUSTER_NAME=<your-cluster-name>
flux bootstrap github \
    --owner=$GITHUB_USER \
    --repository=$GITHUB_REPO \
    —-path="clusters/$CLUSTER_NAME" \
    --token-auth \
    --personal \
    --branch=main
  1. Wait for the bootstrap to complete. You can check the status using flux get sources git. It should look like this:
$ flux get sources git
NAME            REVISION                SUSPENDED       READY   MESSAGE
flux-system     main@sha1:2e619003      False           True    stored artifact for revision 'main@sha1:2e619003'
  1. Check the pods in flux-system namespace. It should look like this:
$ kubectl get pods -n flux-system
NAME                                       READY   STATUS    RESTARTS   AGE
helm-controller-5f9f9f6f8f-4q9qz           1/1     Running   0          2m
kustomize-controller-7f9f9f6f8f-2q9qz      1/1     Running   0          2m
notification-controller-7f9f9f6f8f-2q9qz   1/1     Running   0          2m
source-controller-7f9f9f6f8f-2q9qz         1/1     Running   0          2m
  1. Install Flamingo
flamingo install

Install Argo CD

We can now use Flux to install Argo CD. We will use a HelmRelease to install Argo CD. The HelmRelease is defined in clusters/$CLUSTER_NAME/argo-cd/argocd-helmrelease.yaml. You can change the values in clusters/$CLUSTER_NAME/argo-cd/02-argo-cd-helmrelease.yaml to customize the installation. Once you are done, commit the changes and push them to the repository. Flux will apply the changes to your cluster.

$ git add .
$ git commit -m "Install Argo CD"
$ git push origin main

You can check the status of the HelmRelease using flux get helmrelease --all-namespaces. It should look like this:

$ flux get helmrelease --all-namespaces
NAMESPACE       NAME    REVISION        SUSPENDED       READY   MESSAGE
argocd          argocd  5.51.0          False           True    Helm install succeeded for release argocd/argocd-argocd.v1 with chart argo-cd@5.51.0

Install Prometheus

Similar to Argo CD, we can use a HelmRelease to install the Prometheus Kube Stack. The HelmRelease is defined in clusters/$CLUSTER_NAME/prometheus/03-prom-helmrelease.yaml. You can change the values in clusters/$CLUSTER_NAME/prometheus/03-prome-helmrelease.yaml to customize the installation. Once you are done, commit the changes and push them to the repository. Flux will apply the changes to your cluster.

$ git add .
$ git commit -m "Install Prometheus"
$ git push origin main

References

Contributing

  1. Fork it!
  2. Create your feature branch: git checkout -b my-new-feature
  3. Commit your changes: git commit -am 'Add some feature'
  4. Push to the branch: git push origin my-new-feature
  5. Submit a pull request :D

Credits

Lead Developer - Mitchell Murphy

License

The MIT License (MIT)

Copyright (c) 2023 Mitchell Murphy

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.