Table of Contents

First part optional

minikube start --cpus 4 --memory 8192 docker-env --disk-size=80GB
minikube profile list
|----------|-----------|---------|--------------|------|---------|---------|-------|
| Profile  | VM Driver | Runtime |      IP      | Port | Version | Status  | Nodes |
|----------|-----------|---------|--------------|------|---------|---------|-------|
| minikube | parallels | docker  | 10.211.55.27 | 8443 | v1.20.2 | Running |     1 |
|----------|-----------|---------|--------------|------|---------|---------|-------|

Enable Internal Container Registry and Registry Aliases

minikube addons enable registry-aliases
minikube addons enable registry
    β–ͺ Using image quay.io/rhdevelopers/core-dns-patcher
    β–ͺ Using image alpine:3.11
    β–ͺ Using image gcr.io/google_containers/pause:3.1
🌟  The 'registry-aliases' addon is enabled
    β–ͺ Using image registry:2.7.1
    β–ͺ Using image gcr.io/google_containers/kube-registry-proxy:0.4
πŸ”Ž  Verifying registry addon...
🌟  The 'registry' addon is enabled

minikube addon list

minikube addons list

|-----------------------------|----------|--------------|
|         ADDON NAME          | PROFILE  |    STATUS    |
|-----------------------------|----------|--------------|
| ambassador                  | minikube | disabled     |
| auto-pause                  | minikube | disabled     |
| csi-hostpath-driver         | minikube | disabled     |
| dashboard                   | minikube | disabled     |
| default-storageclass        | minikube | enabled βœ…   |
| efk                         | minikube | disabled     |
| freshpod                    | minikube | disabled     |
| gcp-auth                    | minikube | disabled     |
| gvisor                      | minikube | disabled     |
| helm-tiller                 | minikube | disabled     |
| ingress                     | minikube | disabled     |
| ingress-dns                 | minikube | disabled     |
| istio                       | minikube | disabled     |
| istio-provisioner           | minikube | disabled     |
| kubevirt                    | minikube | disabled     |
| logviewer                   | minikube | disabled     |
| metallb                     | minikube | disabled     |
| metrics-server              | minikube | disabled     |
| nvidia-driver-installer     | minikube | disabled     |
| nvidia-gpu-device-plugin    | minikube | disabled     |
| olm                         | minikube | disabled     |
| pod-security-policy         | minikube | disabled     |
| registry                    | minikube | enabled βœ…   |
| registry-aliases            | minikube | enabled βœ…   |
| registry-creds              | minikube | disabled     |
| storage-provisioner         | minikube | enabled βœ…   |
| storage-provisioner-gluster | minikube | disabled     |
| volumesnapshots             | minikube | disabled     |
|-----------------------------|----------|--------------|

Link for the installation of FLUX https://fluxcd.io/docs/installation/

install flux on Mac

brew install fluxcd/tap/flux
brew install kustomize

install flux on Windows

1. download the file https://github.com/fluxcd/flux2/releases/download/v0.15.3/flux_0.15.3_windows_amd64.zip 

2. create a new path into "Program Files x86"
3. unzip the file content of flux_0.15.3_windows_amd64.zip into the folder created
4. add the PATH into Windows PATH

install flux on Linux

curl -s https://fluxcd.io/install.sh | sudo bash

# enable completions in ~/.bash_profile
. <(flux completion bash)

Open a command shell and check if flux is working

flux check --pre


Updating Homebrew...
==> Auto-updated Homebrew!
Updated 1 tap (homebrew/core).
==> Updated Formulae
Updated 1 formula.

==> Installing flux from fluxcd/tap
==> Downloading https://github.com/fluxcd/flux2/releases/download/v0.13.1/flux_0.13.1_darwin_amd64.tar.gz
==> Downloading from https://github-releases.githubusercontent.com/258469100/d3d9a980-a423-11eb-9ead-25f455a1f24e?X-Amz-Algorithm=AWS4-HMAC-SHA256&X
######################################################################## 100.0%
Info: flux 0.13.0 is already installed
To upgrade to 0.13.1, run:
  brew upgrade fluxcd/tap/flux
Warning: kustomize 4.1.2 is already installed and up-to-date.
To reinstall 4.1.2, run:
  brew reinstall kustomize
β–Ί checking prerequisites
βœ— flux 0.13.0 <0.13.1 (new version is available, please upgrade)
βœ” kubectl 1.19.0 >=1.18.0-0
βœ” Kubernetes 1.20.2 >=1.16.0-0
βœ” prerequisites checks passed

flux bootstrap github

flux bootstrap github \
--owner=fsbaraglia \
--repository=sre-gitops \
--path=dev-cluster \
--branch=master \
--personal=true \
--private=true


β–Ί connecting to github.com
β–Ί cloning branch "master" from Git repository "https://github.com/fsbaraglia/sre-gitops.git"
βœ” cloned repository
β–Ί generating component manifests
βœ” generated component manifests
βœ” committed sync manifests to "master" ("42b314f1cc795c1a5dc65361146bb4e83a4cb1a9")
β–Ί pushing component manifests to "https://github.com/fsbaraglia/sre-gitops.git"
β–Ί installing toolkit.fluxcd.io CRDs
β—Ž waiting for CRDs to be reconciled
βœ” CRDs reconciled successfully
β–Ί installing components in "flux-system" namespace
βœ” installed components
βœ” reconciled components
β–Ί determining if source secret "flux-system/flux-system" exists
βœ” source secret up to date
β–Ί generating sync manifests
βœ” generated sync manifests
βœ” committed sync manifests to "master" ("730785e6c9c3e3d7c4442706d4f3d57d88226ca9")
β–Ί pushing sync manifests to "https://github.com/fsbaraglia/sre-gitops.git"
β–Ί applying sync manifests
βœ” reconciled sync configuration
β—Ž waiting for Kustomization "flux-system/flux-system" to be reconciled
βœ” Kustomization reconciled successfully
β–Ί confirming components are healthy
βœ” source-controller: deployment ready
βœ” kustomize-controller: deployment ready
βœ” helm-controller: deployment ready
βœ” notification-controller: deployment ready
βœ” all components are healthy

adding docker auth to minikube (Optional only for private repo)

docker login

cat ~/.docker/config.json

kubectl create secret generic regcred \
--from-file=.dockerconfigjson=~/.docker/config.json \
--type=kubernetes.io/dockerconfigjson
secret/regcred created

export REGISTRY_SERVER=https://index.docker.io/v1/
export REGISTRY_USER=xxx
export REGISTRY_PASS=xxx
export REGISTRY_EMAIL=xxxx

kubectl create secret docker-registry regcred \
--docker-server=$REGISTRY_SERVER \
--docker-username=$REGISTRY_USER \
--docker-password=$REGISTRY_PASS \
--docker-email=$REGISTRY_EMAIL \
--namespace=cybersec-chaos

kubectl create secret docker-registry regcred \
--docker-server=$REGISTRY_SERVER \
--docker-username=$REGISTRY_USER \
--docker-password=$REGISTRY_PASS \
--docker-email=$REGISTRY_EMAIL \
--namespace=default

kubectl create secret docker-registry regcred \
--docker-server=$REGISTRY_SERVER \
--docker-username=$REGISTRY_USER \
--docker-password=$REGISTRY_PASS \
--docker-email=$REGISTRY_EMAIL \
--namespace=monitoring

let's check the flux source configuration

% flux get sources git
NAME       	READY	MESSAGE                                                          	REVISION                                       	SUSPENDED
flux-system	True 	Fetched revision: master/e630bb6e65d9d10957e24046801ec2fbbcca59d5	master/e630bb6e65d9d10957e24046801ec2fbbcca59d5	False

flux reconcile ks flux-system
β–Ί annotating Kustomization flux-system in flux-system namespace
βœ” Kustomization annotated
β—Ž waiting for Kustomization reconciliation
βœ” Kustomization reconciliation completed
βœ” applied revision master/730785e6c9c3e3d7c4442706d4f3d57d88226ca9

adding image build

Image Automation controller isn’t installed by default (since it’s an alpha feature) et you need to reconfigure Flux. ## The flux bootstrap command is idempotent and you can run it again with the new parameters:

flux bootstrap github \
--owner=fsbaraglia \
--components-extra=image-reflector-controller,image-automation-controller --repository=sre-gitops \
--path=dev-cluster \
--branch=master \
--personal=true \
--private=true

play with flux

-> suspend flux
flux suspend ks flux-system
β–Ί suspending kustomizations flux-system in flux-system namespace
βœ” kustomizations suspended

-> flux kustomization status print
flux get kustomizations


-> resume flux
flux resume ks flux-system

-> push to download changes
flux reconcile ks flux-system