80 KiB
| slug | title | authors | tags | ||||
|---|---|---|---|---|---|---|---|
| seventh-blog-post | Seventh Blog Post |
|
|
import CodeBlock from '@site/src/components/CodeBloack';
- Set up a Flux CD on your DOKS cluster using the flux CLI.
- Keep your Kubernetes cluster apps in sync with a Git repository (using GitOps principles).
- Install and handle applications using Flux CD HelmReleases.
- Set up and manage the Sealed Secrets controller with Flux CD to secure important information.
- Keep things in sync: Flux CD will make sure your cluster stays updated by looking at the instructions in your GitRepository.
- Manage applications smoothly: It will handle Helm releases effortlessly, paying attention to the details outlined in your HelmRelease.
- HelmRelease: Helps in checking and updating your computer's state using something called Helm releases.
- Bucket: Assists in checking and updating your computer by looking at things stored in a special place called a bucket.
- Kustomization: Uses a set of instructions to organize your computer, stored in a special folder (Git) or a specific storage location (S3 bucket).
- Source Controller: Manages where you keep your plans, like Git, Helm, or a storage place. It fetches instructions to make sure your computer does what you want.
- Helm Controller: Handles special updates for your computer known as Helm releases.
- Kustomize Controller: Follows a set of rules for organizing your computer, ensuring it follows instructions stored in a special folder or storage place.
- A ready-to-go DOKS cluster: Think of this as your team of computer helpers. Follow the Starter Kit DOKS Setup Guide to get it set up.
- A special place on the internet: This is like a digital notebook (GitHub repository and branch). It's where we'll keep important information for Flux CD and your computer programs.
- A copying tool for the internet: We'll need a Git client to grab some helpful information. It's like a digital copy-paste tool.
- A talking tool for your DOKS cluster: This is called Kubectl CLI. It helps you talk to your DOKS cluster, telling it what to do. Follow some simple instructions to connect it.
- A special helper for Flux CD: Flux CLI is like a magic wand. It helps us deploy and talk to Flux CD, our smart assistant for computer programs.
- A secret keeper: Kubeseal is a tool for keeping secrets safe. It helps us lock away important information, and it's friends with the Sealed Secrets Controller.
<CodeBlock code={apiVersion: source.toolkit.fluxcd.io/v1beta1 kind: HelmRepository metadata: name: ambassador namespace: flux-system spec: interval: 10m0s url: https://app.getambassador.io } />
- <kind>: This tells Flux CD what type of setup we're using (like HelmRepository in the example).
- <metadata.name>: It's the name you give to this HelmRepository setup (like 'ambassador' in the example).
- <metadata.namespace>: Think of it as a special area for this HelmRepository (like 'flux-system' in the example).
- <spec.interval>: This is like setting how often Flux CD should check for new things from the place we're getting our charts (similar to saying 'helm repo update' in the command line).
- <spec.url>: It's the web address where Flux CD can find the charts we want to use for our computer.
- HelmRepository: This is like a store for Helm charts. HelmRelease can go here to get the chart it needs.
- GitRepository: Think of this as a library where HelmRelease can find charts stored in Git repositories.
- S3 Bucket: This is a special storage place where HelmRelease can find charts if they're kept in S3 compatible buckets.
<CodeBlock code={apiVersion: helm.toolkit.fluxcd.io/v2beta1 kind: HelmRelease metadata: name: ambassador-stack namespace: flux-system spec: chart: spec: chart: edge-stack sourceRef: kind: HelmRepository name: ambassador version: 7.3.2 install: createNamespace: true interval: 1m0s targetNamespace: ambassador } />
- <kind>: This tells Flux CD it's a type of setup called HelmRelease.
- <metadata.name>: It's like giving a name to this specific HelmRelease setup, such as 'ambassador-stack'.
- <metadata.namespace>: Think of this as a special area where your HelmRelease works, like 'flux-system'.
- <chart.spec.chart>: Specifies the name of the app's instruction manual (chart) to get from the HelmRepository, like 'ambassador'.
- <chart.spec.sourceRef.kind>: Tells Flux CD to use a resource called HelmRepository to find the app's instruction manual (it's like a helper for HelmRelease).
- <chart.spec.sourceRef.name>: This is the name of that HelmRepository helper.
- <chart.spec.version>: Specifies which version of the app's instruction manual to use.
- <spec.install.createNamespace>: Instructs Flux CD if it needs to create a special area for the app before installing it (like 'helm install --create-namespace' in commands).
- <spec.interval>: Tells Flux CD how often it should check and make sure everything is set up correctly.
- <spec.targetNamespace>: Specifies where the app's instruction manual should be placed, similar to saying 'helm install --namespace <name>' in commands.
- Using a values file: This is like giving Flux CD a file with all the changes you want to make. It's similar to saying 'helm install <name> <chart> -f values.yaml' in commands.
- Setting each value individually: Instead of using a file, you can tell Flux CD each change you want to make one by one. It's like saying 'helm install <name> <chart> --set <key> <value>' in commands.
- Inline Overrides (using <spec.values>): It's like telling Flux CD exactly what changes you want, similar to giving it a note with all the adjustments you need. This is the equivalent of saying 'helm install -f <values_file>' in commands.
- Individual Overrides (using <spec.valuesFrom>): Instead of giving Flux CD a note, you can talk to it one-on-one and say each change you want. It's like saying 'helm install --set <key> <value>' in commands, but in a more detailed way.
<CodeBlock code={spec: valuesFrom: - kind: Secret name: do-credentials valuesKey: spaces_access_key targetPath: aws.access_key_id } />
- <spec.valuesFrom.kind>: This tells Flux CD the type of secret vault or storage place to look into, like a hidden safe or a special storage box (in this case, it's a Kubernetes Secret, but it could also be a ConfigMap).
- <spec.valuesFrom.name>: It's like providing the name of the secret vault or storage box Flux CD should check for important information. This vault or box should be in the same special area as the HelmRelease.
- <spec.valuesFrom.valuesKey>: Think of this as a specific note inside the vault or box where Flux CD can find something important. If not set, Flux CD assumes it's a general set of instructions named 'values.yaml'.
- <spec.valuesFrom.targetPath>: This is like instructing Flux CD where to put the important information it finds. If not set, Flux CD puts the information in the main place.
- Basic Info: Like the everyday details your app uses, such as settings. You can keep these in a place called spec.values.
- Secret Info: Some things are secret, like passwords. You don't want these out in the open. Instead, you can point to a secret stash using spec.valuesFrom.
- Locking Secrets: Sealed Secrets locks up your secrets, making them like a secret code only your computer can understand.
- Safe Storage: You can put these locked-up secrets in a special storage place called Git. It's safe, even if it's a shared space, because nobody can open the locked-up secrets without the right key.
- Flux CD Help: When you need these secrets for your apps, Flux CD, your computer helper, sees the locked-up secrets in Git. It creates a special key to open the lock, revealing your original secrets.
- Unlocking for Apps: Another helper, the Sealed Secrets Controller, notices these unlocked secrets and turns them back into regular codes that your apps can use.
- Create a Special Key: Make a special key for your computer called a Personal Access Token (PAT). This key allows your computer to do specific tasks, like making a list of your apps.
- Share the Key with Your Computer: Once you have this special key, you share it with your computer. It's like saying, "Hey, computer, here's a key that lets you make lists. Use it!" Just replace some placeholders with the actual key.
<CodeBlock code={export GITHUB_TOKEN=<YOUR_PERSONAL_ACCESS_TOKEN_HERE>} />
<CodeBlock code={flux bootstrap github \ --owner=<YOUR_GITHUB_USER> \ --repository=<YOUR_GITHUB_REPOSITORY_NAME> \ --path=clusters/dev \ --personal } />
- --owner: This is like telling your computer who you are on GitHub, just saying, "It's me!
- --repository: Think of this as asking your computer to make a special folder for Flux CD on GitHub. If the folder isn't there, your computer will create it.
- --path: Imagine this as picking a specific spot inside that folder to keep all the important stuff. Flux CD will keep an eye on any changes happening in this particular spot.
<CodeBlock code={flux check} />
<CodeBlock code={Output► checking prerequisites ✔ Kubernetes 1.21.9 >=1.20.6-0 ► checking controllers ✔ helm-controller: deployment ready ► ghcr.io/fluxcd/helm-controller:v0.17.2 ✔ kustomize-controller: deployment ready ► ghcr.io/fluxcd/kustomize-controller:v0.21.1 ✔ notification-controller: deployment ready ► ghcr.io/fluxcd/notification-controller:v0.22.3 ✔ source-controller: deployment ready ► ghcr.io/fluxcd/source-controller:v0.21.2 ✔ all checks passed } />
<CodeBlock code={flux get all} />
<CodeBlock code={`OutputNAME READY MESSAGE REVISION SUSPENDED gitrepository/flux-system True Fetched revision: main/6e9b41b main/6e9b41b False
NAME READY MESSAGE REVISION SUSPENDED
kustomization/flux-system True Applied revision: main/6e9b41b main/6e9b41b False
`} />
<CodeBlock code={flux logs} />
<CodeBlock code={Output... 2022-03-17T10:47:21.976Z info Kustomization/flux-system.flux-system - server-side apply completed 2022-03-17T10:47:22.662Z info Kustomization/flux-system.flux-system - server-side apply completed 2022-03-17T10:47:22.702Z info Kustomization/flux-system.flux-system - Reconciliation finished in 9.631064885s, next run in 10m0s 2022-03-17T10:47:19.167Z info GitRepository/flux-system.flux-system - Discarding event, no alerts found for the involved object 2022-03-17T10:47:22.691Z info Kustomization/flux-system.flux-system - Discarding event, no alerts found for the involved object 2022-03-17T10:47:22.709Z info Kustomization/flux-system.flux-system - Discarding event, no alerts found for the involved object 2022-03-17T10:47:19.168Z info GitRepository/flux-system.flux-system - Reconciliation finished in 7.79283477s, next run in 1m0s 2022-03-17T10:48:20.594Z info GitRepository/flux-system.flux-system - Reconciliation finished in 1.424279853s, next run in 1m0s ... } />
<CodeBlock code={kubectl get gitrepositories.source.toolkit.fluxcd.io -n flux-system} />
<CodeBlock code={OutputNAME URL READY STATUS AGE flux-system ssh://git@github.com/test-starterkit/starterkit_fra1.git True Fetched revision: main/6e9b41b... 9m59s } />
- Get Your Flux CD Git Repository: Start by copying your Flux CD Git repository. It's like making a duplicate of your big box where all the important things are stored for looking after your DOKS cluster. Just fill in your details instead of the <> symbols. /<YOUR_GITHUB_REPOSITORY_NAME>.git`} />
Here's what those placeholders mean:- <YOUR_GITHUB_USER>: This is where you put your username on GitHub, the same one you used when you set up Flux CD.
- <YOUR_GITHUB_REPOSITORY_NAME>: This is the name of the special folder on GitHub where Flux CD keeps everything for your DOKS cluster. Remember, you set this up when you ran the "flux bootstrap" command.
<CodeBlock code={FLUXCD_SYNC_PATH="clusters/dev" FLUXCD_HELM_MANIFESTS_PATH="$ {FLUXCD_SYNC_PATH}/helm" mkdir -p "$ {FLUXCD_HELM_MANIFESTS_PATH}/repositories" mkdir -p "$ {FLUXCD_HELM_MANIFESTS_PATH}/releases" mkdir -p "$ {FLUXCD_HELM_MANIFESTS_PATH}/secrets" } />
<CodeBlock code={`Output# Ignore all YAML files containing the '-values-' string. -values-.yaml
Do not ignore sealed YAML files.
!*-sealed.yaml
`} />
<CodeBlock code={├── README.md ├── clusters │ └── dev │ ├── flux-system │ │ ├── gotk-components.yaml │ │ ├── gotk-sync.yaml │ │ └── kustomization.yaml │ └── helm │ ├── releases │ │ ├── ambassador-stack-v7.3.2.yaml │ │ ├── loki-stack-v2.6.4.yaml │ │ ├── prometheus-stack-v35.5.1.yaml │ │ ├── sealed-secrets-v2.4.0.yaml │ │ └── velero-v2.29.7.yaml │ ├── repositories │ │ ├── ambassador.yaml │ │ ├── grafana.yaml │ │ ├── prometheus-community.yaml │ │ ├── sealed-secrets.yaml │ │ └── vmware-tanzu.yaml │ └── secrets │ ├── do-api-credentials-sealed.yaml │ ├── do-spaces-credentials-sealed.yaml │ └── prometheus-stack-credentials-sealed.yaml └── pub-sealed-secrets-dev-cluster.pem } />
- Go to the folder where you cloned your Flux CD Git repository. Make sure the folder structure needed for this tutorial is set up and that you've set the FLUXCD_HELM_MANIFESTS_PATH environment variable.
- Create a file called Sealed Secrets HelmRepository manifest for Flux
<CodeBlock code={flux create source helm sealed-secrets \ --url="https://bitnami-labs.github.io/sealed-secrets" \ --interval="10m" \ --export > "$ {FLUXCD_HELM_MANIFESTS_PATH}/repositories/sealed-secrets.yaml" } />
<CodeBlock code={apiVersion: source.toolkit.fluxcd.io/v1beta1 kind: HelmRepository metadata: name: sealed-secrets namespace: flux-system spec: interval: 10m0s url: https://bitnami-labs.github.io/sealed-secrets } />
<CodeBlock code={SEALED_SECRETS_CHART_VERSION="2.4.0" curl "https://raw.githubusercontent.com/digitalocean/Kubernetes-Starter-Kit-Developers/main/06-kubernetes-secrets/assets/manifests/sealed-secrets-values-v$ {SEALED_SECRETS_CHART_VERSION}.yaml" > "sealed-secrets-values-v$ {SEALED_SECRETS_CHART_VERSION}.yaml" } />
<CodeBlock code={SEALED_SECRETS_CHART_VERSION="2.4.0" flux create helmrelease "sealed-secrets-controller" \ --release-name="sealed-secrets-controller" \ --source="HelmRepository/sealed-secrets" \ --chart="sealed-secrets" \ --chart-version "$ SEALED_SECRETS_CHART_VERSION" \ --values="sealed-secrets-values-v$ {SEALED_SECRETS_CHART_VERSION}.yaml" \ --target-namespace="flux-system" \ --crds=CreateReplace \ --export > "$ {FLUXCD_HELM_MANIFESTS_PATH}/releases/sealed-secrets-v$ {SEALED_SECRETS_CHART_VERSION}.yaml" } />
- --release-name: This is the name you want to give to your Helm release. If you don't specify one, it will use a default name based on the target namespace and HelmRelease name.
- --source: This tells Flux where to find the chart. It should be in the format kind/name.namespace. The kind can be HelmRepository, GitRepository, or Bucket.
- --chart: This is the name of the Helm chart you want to use.
- --chart-version: Specify the version of the Helm chart you want to use.
- --values: This is the path to a file containing values for configuring the Helm chart.
- --target-namespace: This is the namespace where you want to install this Helm release.
- --crds: This option determines what to do with Custom Resource Definitions (CRDs). You can choose to skip, create, or create/replace them.
- --export: This option makes the command output the information in YAML format on the screen
<CodeBlock code={--- apiVersion: helm.toolkit.fluxcd.io/v2beta1 kind: HelmRelease metadata: name: sealed-secrets-controller namespace: flux-system spec: chart: spec: chart: sealed-secrets sourceRef: kind: HelmRepository name: sealed-secrets version: 2.4.0 interval: 1m0s releaseName: sealed-secrets-controller targetNamespace: flux-system install: crds: Create upgrade: crds: CreateReplace values: ingress: enabled: false } />
<CodeBlock code={SEALED_SECRETS_CHART_VERSION="2.4.0" git add "$ {FLUXCD_HELM_MANIFESTS_PATH}/repositories/sealed-secrets.yaml" git add "$ {FLUXCD_HELM_MANIFESTS_PATH}/releases/sealed-secrets-v$ {SEALED_SECRETS_CHART_VERSION}.yaml" git commit -am "Adding Sealed Secrets manifests for Flux CD" git push origin } />
<CodeBlock code={flux reconcile source git flux-system} />
<CodeBlock code={flux get helmrelease sealed-secrets-controller} />
<CodeBlock code={NAME READY MESSAGE REVISION SUSPENDED sealed-secrets-controller True Release reconciliation succeeded 2.4.0 False } />
- The MESSAGE column will show "Reconciliation in progress" while the HelmController is installing the specified Helm chart. If there's an issue, you'll see a different message explaining what went wrong, so it's important to keep an eye on the Helm release status.
- You can use the --watch flag like this: flux get helmrelease <name> --wait, to wait until the installation finishes. Just know that when using this flag, your terminal will be busy until the default timeout of 5 minutes passes (you can change this with the --timeout flag).
- If something doesn't go as planned, you can search through the Flux logs and focus only on HelmRelease messages:
<CodeBlock code={flux logs --kind=HelmRelease} />
<CodeBlock code={kubectl describe helmrelease sealed-secrets-controller -n flux-system} />
- Go to the folder where you cloned your Flux CD Git repository.Follow these steps (replace any <> placeholders as needed):
pub-sealed-secrets-.pem`} />
If you're having trouble with the kubeseal certificate fetch command, or if you get an empty or invalid certificate file, you can try these steps to fix it: - Open a new terminal window. Use this command to make the Sealed Secrets Controller service accessible on your computer (you can press CTRL - C to stop it after you've fetched the public key):
<CodeBlock code={curl --retry 5 --retry-connrefused localhost:8080/v1/cert.pem > pub-sealed-secrets-<YOUR_DOKS_CLUSTER_NAME_HERE>.pem} />
<CodeBlock code={git add pub-sealed-secrets-<YOUR_DOKS_CLUSTER_NAME_HERE>.pem git commit -m "Adding Sealed Secrets public key for cluster <YOUR_DOKS_CLUSTER_NAME_HERE>" git push origin } />
- Go to the folder where you saved your Flux CD Git repository. Make sure you have the right folders set up for this tutorial, and that you've set the FLUXCD_HELM_MANIFESTS_PATH environment variable (you can find instructions for this in Step 4 - Cloning the Flux CD Git Repository and Preparing the Layout).
- Next, download the Jetstack HelmRepository manifest file from the Starter Kit Git repository.
"$ {FLUXCD_HELM_MANIFESTS_PATH}/repositories/jetstack.yaml"`} />
- Next, get the Cert-Manager HelmRelease manifest file from the Starter Kit Git repository:
"$ {FLUXCD_HELM_MANIFESTS_PATH}/releases/cert-manager-v$ {CERT_MANAGER_CHART_VERSION}.yaml" `} /> - Next, open the downloaded HelmRelease manifest file in a text editor. It's a good idea to use one with support for YAML linting, like VS Code. Make any necessary adjustments to fit your requirements. If you see placeholders like <>, be sure to replace them with the correct information.
- Lastly, upload the Git changes to the remote repository:
<CodeBlock code={flux reconcile source git flux-system} />
<CodeBlock code={flux get helmrelease cert-manager} />
<CodeBlock code={OutputNAME READY MESSAGE REVISION SUSPENDED cert-manager True Release reconciliation succeeded v1.6.1 False } />
- The MESSAGE column shows 'Reconciliation in progress' while Flux CD is setting up the Helm chart. If there's a problem, you'll see a different message explaining it, so it's important to check the Helm release status.
- You can use the --watch flag, like this: flux get helmrelease <name> --wait, to wait until everything's done. Just know that your terminal will be busy until it finishes (you can change the timeout if needed).
- If something goes wrong, you can search the Flux logs for HelmRelease messages.
<CodeBlock code={kubectl describe helmrelease cert-manager -n flux-system} />
- Ambassador Ingress Helm Release
- Nginx Ingress Helm Release
- Navigate to Your Flux CD Git Repository: Go to the folder where you stored your Flux CD Git repository. Make sure the required folders are set up correctly (if you're unsure, check Step 4 of the tutorial for details).
- Fetch the HelmRepository File: Now, grab the file that tells Flux CD how to handle Helm charts. Choose the option that matches the Ingress Controller you want (either Ambassador or Nginx). This file helps set up the necessary configurations.
<CodeBlock code={curl "https://raw.githubusercontent.com/digitalocean/Kubernetes-Starter-Kit-Developers/main/14-continuous-delivery-using-gitops/assets/manifests/fluxcd/helm/repositories/ambassador.yaml" > "$ {FLUXCD_HELM_MANIFESTS_PATH}/repositories/ambassador.yaml"} />
<CodeBlock code={curl "https://raw.githubusercontent.com/digitalocean/Kubernetes-Starter-Kit-Developers/main/14-continuous-delivery-using-gitops/assets/manifests/fluxcd/helm/repositories/kubernetes-community-nginx.yaml" > "$ {FLUXCD_HELM_MANIFESTS_PATH}/repositories/kubernetes-community-nginx.yaml"} />
<CodeBlock code={AMBASSADOR_CHART_VERSION="7.3.2" curl "https://raw.githubusercontent.com/digitalocean/Kubernetes-Starter-Kit-Developers/main/14-continuous-delivery-using-gitops/assets/manifests/fluxcd/helm/releases/ambassador-stack-v$ {AMBASSADOR_CHART_VERSION}.yaml" > "$ {FLUXCD_HELM_MANIFESTS_PATH}/releases/ambassador-stack-v$ {AMBASSADOR_CHART_VERSION}.yaml" } />
<CodeBlock code={NGINX_CHART_VERSION="4.1.3" curl "https://raw.githubusercontent.com/digitalocean/Kubernetes-Starter-Kit-Developers/main/14-continuous-delivery-using-gitops/assets/manifests/fluxcd/helm/releases/nginx-v$ {NGINX_CHART_VERSION}.yaml" > "$ {FLUXCD_HELM_MANIFESTS_PATH}/releases/nginx-v$ {NGINX_CHART_VERSION}.yaml" } />
<CodeBlock code={AMBASSADOR_CHART_VERSION="7.3.2" code "$ {FLUXCD_HELM_MANIFESTS_PATH}/releases/ambassador-stack-v$ {AMBASSADOR_CHART_VERSION}.yaml" } />
<CodeBlock code={NGINX_CHART_VERSION="4.1.3" code "$ {FLUXCD_HELM_MANIFESTS_PATH}/releases/nginx-v$ {NGINX_CHART_VERSION}.yaml" } />
<CodeBlock code={... install: createNamespace: true remediation: retries: 3 upgrade: remediation: retries: 3 ... } />
<CodeBlock code={AMBASSADOR_CHART_VERSION="7.3.2" git add "$ {FLUXCD_HELM_MANIFESTS_PATH}/repositories/ambassador.yaml" git add "$ {FLUXCD_HELM_MANIFESTS_PATH}/releases/ambassador-stack-v$ {AMBASSADOR_CHART_VERSION}.yaml" git commit -am "Adding Ambassador manifests for Flux CD" git push origin } />
<CodeBlock code={NGINX_CHART_VERSION="4.1.3" git add "$ {FLUXCD_HELM_MANIFESTS_PATH}/repositories/kubernetes-community-nginx.yaml" git add "$ {FLUXCD_HELM_MANIFESTS_PATH}/releases/nginx-v$ {NGINX_CHART_VERSION}.yaml" git commit -am "Adding Nginx manifests for Flux CD" git push origin } />
<CodeBlock code={flux get helmrelease ambassador-stack} />
<CodeBlock code={OutputNAME READY MESSAGE REVISION SUSPENDED ambassador-stack True Release reconciliation succeeded 7.3.2 False } />
<CodeBlock code={flux get helmrelease ingress-nginx} />
<CodeBlock code={OutputNAME READY MESSAGE REVISION SUSPENDED ingress-nginx True Release reconciliation succeeded 4.1.3 False } />
- While the HelmController is busy installing the Helm chart, the 'MESSAGE' column will show 'Reconciliation in progress'. If anything goes wrong, you'll see a different message explaining the issue. So, keep an eye on the Helm release status.
- If you want to wait for the installation to finish, you can use the command 'flux get helmrelease <name> --wait'. Just know that in this mode, your terminal will be busy until it finishes or reaches the default timeout of 5 minutes (you can change this with the --timeout flag).
- If there's a problem, you can check the Flux logs for HelmRelease messages. Here's how to do it:
<CodeBlock code={flux logs --kind=HelmRelease} />
<CodeBlock code={kubectl describe helmrelease ingress-nginx -n flux-system} />
- hange Directory: Go to the directory where you cloned your Flux CD Git repository. Make sure everything's set up correctly according to the tutorial's directory structure. If you're unsure, check Step 4 for guidance.
- Fetch Prometheus HelmRepository Manifest: Get the Prometheus HelmRepository manifest from the Starter Kit Git repository. This will give you the necessary files to set up Prometheus.
"$ {FLUXCD_HELM_MANIFESTS_PATH}/repositories/prometheus-community.yaml"`} />
<CodeBlock code={SEALED_SECRETS_PUB_KEY="<YOUR_SEALED_SECRETS_PUB_KEY_NAME_HERE>" GRAFANA_ADMIN_PASSWORD="<YOUR_GRAFANA_ADMIN_PASSWORD_HERE>" kubectl create secret generic "prometheus-stack-credentials" \ --namespace flux-system \ --from-literal=grafana_admin_password="$ {GRAFANA_ADMIN_PASSWORD}" \ --dry-run=client -o yaml | kubeseal --cert="$ {SEALED_SECRETS_PUB_KEY}" \ --format=yaml > "$ {FLUXCD_HELM_MANIFESTS_PATH}/secrets/prometheus-stack-credentials-sealed.yaml" } />
<CodeBlock code={PROMETHEUS_CHART_VERSION="35.5.1" curl "https://raw.githubusercontent.com/digitalocean/Kubernetes-Starter-Kit-Developers/main/14-continuous-delivery-using-gitops/assets/manifests/fluxcd/helm/releases/prometheus-stack-v$ {PROMETHEUS_CHART_VERSION}.yaml" > "$ {FLUXCD_HELM_MANIFESTS_PATH}/releases/prometheus-stack-v$ {PROMETHEUS_CHART_VERSION}.yaml" } />
<CodeBlock code={`PROMETHEUS_CHART_VERSION="35.5.1"
code " {FLUXCD_HELM_MANIFESTS_PATH}/releases/prometheus-stack-v {PROMETHEUS_CHART_VERSION}.yaml"`} />
<CodeBlock code={LOKI_CHART_VERSION="2.6.4" git add "$ {FLUXCD_HELM_MANIFESTS_PATH}/repositories/grafana.yaml" git add "$ {FLUXCD_HELM_MANIFESTS_PATH}/releases/loki-stack-v$ {LOKI_CHART_VERSION}.yaml" git add "$ {FLUXCD_HELM_MANIFESTS_PATH}/secrets/do-spaces-credentials-sealed.yaml" git commit -am "Adding Loki stack manifests for Flux CD" git push origin } />
<CodeBlock code={flux get helmrelease kube-prometheus-stack} />
<CodeBlock code={OutputNAME READY MESSAGE REVISION SUSPENDED kube-prometheus-stack True Release reconciliation succeeded 35.5.1 False } />
- Keep an eye on the 'MESSAGE' column; it will show 'Reconciliation in progress' while the HelmController is setting up the Helm chart. If anything goes awry, you'll see a different message explaining the issue, so be sure to check the status.
- You can use a special command like this: 'flux get helmrelease <name> --wait' and it will keep you updated until it's done. Just know that your terminal might be tied up during this time, and it might take up to 5 minutes (though you can change this if needed).
- If something doesn't work out, you can look in the Flux logs. Specifically, filter for messages related to HelmRelease, and that might give you clues on what went wrong
<CodeBlock code={flux logs --kind=HelmRelease} />
<CodeBlock code={kubectl describe helmrelease kube-prometheus-stack -n flux-system} />
<CodeBlock code={kubectl get secret prometheus-stack-credentials -n flux-system} />
- To see the Prometheus dashboard, run: 'kubectl port-forward svc/kube-prom-stack-kube-prome-prometheus 9090:9090 -n monitoring'. It's like opening a window to peek inside.
- For Grafana dashboards, try this: 'kubectl --namespace monitoring port-forward svc/kube-prom-stack-grafana 3000:80'. It's another way to look at things.
- Lastly, to check the storage where Prometheus keeps its data, run: 'kubectl get pvc -n monitoring'. This is like checking the space where all the important stuff is stored.
- Start by going to the folder where you cloned your Flux CD Git repository. Check if you've set up the folders the way we explained.
- Now, grab the Loki magic instructions we have stored. It's like getting a special recipe from a cookbook – we're fetching it from the Starter Kit Git place.
"$ {FLUXCD_HELM_MANIFESTS_PATH}/repositories/grafana.yaml" `} /> - First, make sure you've shared a special key with your computer, as we explained in the part about exporting the Sealed Secrets Controller Public Key. If you haven't done that yet, make sure to replace any empty spots with the right information:
<CodeBlock code={SEALED_SECRETS_PUB_KEY="<YOUR_SEALED_SECRETS_PUB_KEY_NAME_HERE>" DO_SPACES_ACCESS_KEY="<YOUR_DO_SPACES_ACCESS_KEY_HERE>" DO_SPACES_SECRET_KEY="<YOUR_DO_SPACES_SECRET_KEY_HERE>" kubectl create secret generic "do-spaces-credentials" \ --namespace flux-system \ --from-literal=access_key_id="$ {DO_SPACES_ACCESS_KEY}" \ --from-literal=secret_access_key="$ {DO_SPACES_SECRET_KEY}" \ --dry-run=client -o yaml | kubeseal --cert="$ {SEALED_SECRETS_PUB_KEY}" \ --format=yaml > "$ {FLUXCD_HELM_MANIFESTS_PATH}/secrets/do-spaces-credentials-sealed.yaml"} />
<CodeBlock code={LOKI_CHART_VERSION="2.6.4" curl "https://raw.githubusercontent.com/digitalocean/Kubernetes-Starter-Kit-Developers/main/14-continuous-delivery-using-gitops/assets/manifests/fluxcd/helm/releases/loki-stack-v$ {LOKI_CHART_VERSION}.yaml" > "$ {FLUXCD_HELM_MANIFESTS_PATH}/releases/loki-stack-v$ {LOKI_CHART_VERSION}.yaml" } />
<CodeBlock code={LOKI_CHART_VERSION="2.6.4" code "$ {FLUXCD_HELM_MANIFESTS_PATH}/releases/loki-stack-v$ {LOKI_CHART_VERSION}.yaml" } />
<CodeBlock code={LOKI_CHART_VERSION="2.6.4" git add "$ {FLUXCD_HELM_MANIFESTS_PATH}/repositories/grafana.yaml" git add "$ {FLUXCD_HELM_MANIFESTS_PATH}/releases/loki-stack-v$ {LOKI_CHART_VERSION}.yaml" git add "$ {FLUXCD_HELM_MANIFESTS_PATH}/secrets/do-spaces-credentials-sealed.yaml" git commit -am "Adding Loki stack manifests for Flux CD" git push origin } />
<CodeBlock code={flux get helmrelease loki-stack} />
- As the HelmController installs the setup, the 'MESSAGE' column will say 'Reconciliation in progress.' If something doesn't go as planned, you'll see a different message explaining what happened. Make sure to keep an eye on how things are going.
- To wait until everything finishes, you can use a special command with '--watch' like this: 'flux get helmrelease <name> --wait.' It's like keeping an eye on the cooking timer.
- Just remember, your computer might pause for up to 5 minutes in this mode, but you can change this time if needed. If things go wrong, you can check the Flux logs to find messages related to the setup using a filter.
<CodeBlock code={flux logs --kind=HelmRelease} />
<CodeBlock code={kubectl describe helmrelease loki-stack -n flux-system} />
<CodeBlock code={kubectl get secret do-spaces-credentials -n flux-system} />
Now, let's move on to the next step! We're going to create the instructions for Velero, and Flux CD will take care of setting it up automatically. It's like giving your computer a list of steps, and it does the work for you!
- Start by heading to the folder where you saved your Flux CD Git repository. Make sure everything is set up correctly by checking the directories and making sure the FLUXCD_HELM_MANIFESTS_PATH environment variable is set. If you're unsure, refer back to the section where we explained how to clone the Flux CD Git Repository and set up the layout.
- Next, grab the Velero HelmRepository instructions from the Starter Kit Git repository. It's like picking up a helpful guide to get Velero ready on your computer using Flux CD.
"$ {FLUXCD_HELM_MANIFESTS_PATH}/repositories/vmware-tanzu.yaml"`} />
- Create and encrypt a special space for Velero HelmRelease to use a secret code. Make sure you have the Sealed Secrets key exported, as explained in "Exporting the Sealed Secrets Controller Public Key" (replace <> placeholders accordingly).
" DO_API_TOKEN="" kubectl create secret generic "do-api-credentials" \ --namespace flux-system \ --from-literal=do_api_token="$ {DO_API_TOKEN}" \ --dry-run=client -o yaml | kubeseal --cert="$ {SEALED_SECRETS_PUB_KEY}" \ --format=yaml > "$ {FLUXCD_HELM_MANIFESTS_PATH}/secrets/do-api-credentials-sealed.yaml" `} />
- --namespace: Picture this as telling the computer in which specific area (like a room) of the Kubernetes system it should keep the secret.
- --from-literal: Imagine you're instructing the computer, "Hey, create a secret and put this special code (your DO API token) inside it." This special code is used by Velero within the Kubernetes environment.
- --dry-run=client: It's akin to practicing before you actually do it. This part helps you see what the secret looks like without actually storing it in the computer's memory within the Kubernetes system. It's like making a draft first.
<CodeBlock code={VELERO_CHART_VERSION="2.29.7" curl "https://raw.githubusercontent.com/digitalocean/Kubernetes-Starter-Kit-Developers/main/14-continuous-delivery-using-gitops/assets/manifests/fluxcd/helm/releases/velero-v$ {VELERO_CHART_VERSION}.yaml" > "$ {FLUXCD_HELM_MANIFESTS_PATH}/releases/velero-v$ {VELERO_CHART_VERSION}.yaml" } />
<CodeBlock code={VELERO_CHART_VERSION="2.29.7" code "$ {FLUXCD_HELM_MANIFESTS_PATH}/releases/velero-v$ {VELERO_CHART_VERSION}.yaml" } />
- You can understand how the secrets named do-api-credentials and do-spaces-credentials are used in the Velero HelmRelease instructions by checking the following part:
- Remember, the secret information we talked about earlier is placed in a special area called environment variables (look for configuration.extraEnvVars in the instructions). Keep in mind that if you check the Velero deployment details, these values might be visible in plain text. On real-world systems, you can add extra security measures (like RBAC) to limit who can see this information, especially in important places like production environments.
<CodeBlock code={kubectl describe deployment velero -n velero | grep AWS_ACCESS_KEY_ID} />
- Lastly, save your changes in Git by committing them to the remote branch.
<CodeBlock code={VELERO_CHART_VERSION="2.29.7" git add "$ {FLUXCD_HELM_MANIFESTS_PATH}/repositories/vmware-tanzu.yaml" git add "$ {FLUXCD_HELM_MANIFESTS_PATH}/releases/velero-v$ {VELERO_CHART_VERSION}.yaml" git add "$ {FLUXCD_HELM_MANIFESTS_PATH}/secrets/do-api-credentials-sealed.yaml" git commit -am "Adding Velero manifests for Flux CD" git push origin } />
<CodeBlock code={OutputNAME READY MESSAGE REVISION SUSPENDED velero-stack True Release reconciliation succeeded 2.29.7 False } />
- When the system is working to install the Helm chart, you'll see a message saying "Reconciliation in progress" in the MESSAGE column. If there's a problem, a different message will explain what went wrong. So, keep an eye on the status of your Helm release.
- You can use a command like flux get helmrelease <name> --wait --watch to patiently wait until everything is done. Just note that your terminal will be occupied until it's finished or a default timeout of 5 minutes passes (you can change this with the --timeout option).
- If things don't go well, you can check the Flux logs. Specifically, you can filter them to only show messages related to HelmRelease.
<CodeBlock code={flux logs --kind=HelmRelease} />
<CodeBlock code={kubectl describe helmrelease velero-stack -n flux-system} />
<CodeBlock code={kubectl get secret do-api-credentials -n flux-system} />