Skip to content

Instantly share code, notes, and snippets.

@scottrigby
Last active December 27, 2022 18:12
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save scottrigby/82b224804052726624fd46d5f042146c to your computer and use it in GitHub Desktop.
Save scottrigby/82b224804052726624fd46d5f042146c to your computer and use it in GitHub Desktop.
Hands-On GitOps Patterns for Helm Users

Hands-On GitOps Patterns for Helm Users

  1. Install Flux CLI and Kind:

    $ brew reinstall flux kind
    $ kind --version
    kind version 0.10.0
    $ flux --version
    flux version 0.9.1
  2. Make Personal Access Token for creating repositories

    1. Check all permissions under repo
    2. Copy PAT to buffer
  3. Export env vars locally

    $ export GITHUB_TOKEN=[paste PAT]
  4. Create local demo cluster

    $ kind create cluster
    (took 27s)
  5. Simple bootstrap:

    the more complex your org is, the more complex your directory structure and patterns are

    there is no gold standard

    flux is not opinionated about how directories are structured, rather it tries to be as flexible as possible to accommodate different patterns

    $ flux bootstrap github --owner scottrigby --personal  --repository hands-on-gitops-patterns-for-helm-users --branch main --path=clusters/dev
    ► connecting to github.com
    ✔ repository created
    ✔ repository cloned
    ✚ generating manifests
    ✔ components manifests pushed
    ► installing components in flux-system namespace
    
    ◎ verifying installation
    ✔ install completed
    ► configuring deploy key
    ✔ deploy key configured
    ► generating sync manifests
    ✔ sync manifests pushed
    ► applying sync manifests
    ◎ waiting for cluster sync
    ✔ bootstrap finished
    (took 39s)
  6. Clone the newly created git repo to your local workspace

    $ cd ~/code/github.com/scottrigby
    $ git clone git@github.com:scottrigby/hands-on-gitops-patterns-for-helm-users.git
    $ tree
    .
    ├── README.md
    └── clusters
        └── dev
            └── flux-system
                ├── gotk-components.yaml
                ├── gotk-sync.yaml
                └── kustomization.yaml
  7. Create a Source Custom Resource locally

    $ flux create source helm podinfo \
    --url=https://stefanprodan.github.io/podinfo \
    --interval=10m \
    --export > clusters/dev/source-helmrepo-podinfo.yaml
  8. Create a Helm Release Custom Resource locally in the "app1" namespace dir

    $ flux create hr app1 \
    --interval=10m \
    --source=HelmRepository/podinfo \
    --chart=podinfo \
    --chart-version=">4.0.0" \
    --export > ./clusters/dev/podinfo-helmrelease.yaml
  9. From this point on, you are now doing GitOps:

    $ git add .
    $ git commit -m 'Configure podinfo Helm Repo source and app1 Helm Release'
    $ git push
  10. Cleanup demo cluster

    $ kind delete cluster
@haimari
Copy link

haimari commented Mar 23, 2021

Hello @scott

Can you please check out my question at the GitHub Discussion and provide a gist example ? It is different case then presented here.

Thank you

@bogdanbarna
Copy link

Hi. Thanks for the demo! Did the flux cli installation change? It's brew install fluxcd/tap/flux now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment