Prerequisites
- A Kubernetes cluster with a kubeconfig file set up to access the cluster remotely. You can use
minikube
(https://github.com/kubernetes/minikube/releases) to set it up in your local environment faster. flux
cli tool — use your favorite package manager for your OS to install it. For me it’s Chocolatey on Windows.
choco install flux
After it’s installed, let’s check our cluster to confirm it satisfies the flux prerequisites:
$ flux check --pre
► checking prerequisites
✔ kubernetes 1.23.4 >=1.20.6-0
✔ kubectl 1.23.4 >=1.20.6-0
✔ prerequisites checks passed
Now we can bootstrap our cluster. Check out the fluxCD getting started page for more information on this.
Creating a Git Repository
Resource
We’ll need to create a GitRepository
source which the SourceController uses to create an artifact that can be referenced later.
In your Terminal, type/paste the following command:
$ flux create source git eck-operator --url=https://github.com/elastic/cloud-on-k8s --tag="2.2.0" --branch=main --namespace=flux-system --interval=5m
With the expected output:
apiVersion: source.toolkit.fluxcd.io/v1beta1
kind: GitRepository
metadata:
name: eck-operator
namespace: flux-system
spec:
interval: 5m
url: https://github.com/elastic/cloud-on-k8s
ref:
branch: master
A few things to note here:
name
defines the name of the artifact.namespace
defines the namespace it will operate in. flux docs set it atdefault
orflux-system
.spec.interval
defines how often the Source Controller checks for updates.spec.url
defines the repository. For aGitRepository
resource, this is the repository URL for whichever Helm chart you want to deploy — it must be the root, otherwise it won’t work.
Creating a HelmRelease
Resource
We need to create a HelmRelease
resource to apply the Helm chart by referencing the artifact created by our SourceController above.
In your Terminal, type/paste the following command:
$ flux create hr eck-operator --interval=1m --source=GitRepository/eck-operator --chart=./deploy/eck-operator --namespace=flux-system
With the expected output:
apiVersion: helm.toolkit.fluxcd.io/v2beta1
kind: HelmRelease
metadata:
name: eck-operator
namespace: flux-system
spec:
interval: 5m
chart:
spec:
chart: ./deploy/eck-operator
sourceRef:
kind: GitRepository
name: eck-operator
namespace: flux-system
interval: 1m
A few things to note:
Most of the definitions are the same as above.
spec.interval
references the interval at which we reconcile the HelmRelease.chart.spec.chart
the relative path of the Helm chart in the Git repo.chart.spec.sourceRef
defines what SourceRef the HelmRelease should pull from. In this case we’re referencing ourGitRepository
eck-operator
SourceRef in theflux-system
namespace.chart.spec.interval
defines how often we check the Source (ourGitRepository
Source) for updates. Default is the previously definedHelmReleaseSpec.Interval
.
Awesome! So now we can run a command to check out our HelmRelease deploy:
$ flux get helmreleases --all-namespaces
And…
NAMESPACE NAME REVISION SUSPENDED READY MESSAGE
flux-system eck-operator False False install retries exhausted
Oops.
Troubleshooting
So I came across a problem that’s an ongoing discussion as a GitHub issue. Applying the solution and…
NAMESPACE NAME REVISION SUSPENDED READY MESSAGE
flux-system eck-operator 2.2.0 False True Release reconciliation succeeded
Success!
Turns out the Helm release states were broken and suspending and resuming them solves the problem. But we are not done yet. Let’s check out our pods to see that they are actually running.
$ kubectl get pods --all-namespaces
Ok, so our namespace is flux-system
and our pod is elastic-operator-0
and we can see that it’s running.
Great!
What next?
Well, we’ve successfully deployed the ECK operator on minikube via a Helm chart on the Elastic git repo, with flux. Pretty cool, right? But what’s the point? We can now start deploying Elastic apps via the ECK operator which I’ll be covering as we go along.
Thanks for stopping by.