Install Flux

Flux Architecture:

Flux Architecture

Create git repository which will be used by Flux in GitHub:

hub create -d "Flux repository for k8s-sockshop" -h "" ruzickap/k8s-flux-repository


A git remote named 'origin' already exists and is set to push to 'ssh://'.

Clone the git repository:

mkdir tmp
if [ ! -n "$(grep "^ " ~/.ssh/known_hosts)" ]; then ssh-keyscan >> ~/.ssh/known_hosts 2>/dev/null; fi
git config --global ""
git -C tmp clone


Cloning into 'k8s-flux-repository'...
warning: You appear to have cloned an empty repository.

Create initial Flux repository structure and add it into the git repository:

cp -v files/flux-repository/ tmp/k8s-flux-repository/
mkdir -v tmp/k8s-flux-repository/{namespaces,releases,workloads}

git -C tmp/k8s-flux-repository add .
git -C tmp/k8s-flux-repository commit -m "Initial commit"
git -C tmp/k8s-flux-repository push -q


'files/flux-repository/' -> 'tmp/k8s-flux-repository/'
mkdir: created directory 'tmp/k8s-flux-repository/namespaces'
mkdir: created directory 'tmp/k8s-flux-repository/releases'
mkdir: created directory 'tmp/k8s-flux-repository/workloads'
[master (root-commit) 01ec748] Initial commit
 1 file changed, 1 insertion(+)
 create mode 100644

Install fluxctl:

if [ ! -x /usr/local/bin/fluxctl ]; then
  sudo curl -L -o /usr/local/bin/fluxctl
  sudo chmod a+x /usr/local/bin/fluxctl

Set the namespace (flux) where flux was installed for running fluxctl:

export FLUX_TIMEOUT="30m0s"

Obtain the ssh public key through fluxctl:

fluxctl identity
if [ -x /usr/bin/chromium-browser ]; then chromium-browser &> /dev/null & fi


ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCyGvcJPcFxvsc9SHtJiOt7G6pvNQgmcf+PIIfy6PoEvXK2naXmKw68+dtKeIoMzvp63QxoNB+B6qamMbkWqaVCjS4glAXKmf68k/eCazcPNZaQRmL/YUmgmyZ8AF02fDmM/RQMz/2hUtUE6UYs/T5vYUdDwYb09nOmVMgclY6jbmQ4b0OgG18p6RnNYtJ4wysC6+wEoy5xVljKWRE03UxD3pJbVdk5KPcJ/mnX44tUwU/oE/Ezz7LaMjVXnXns8zKu3LOAIeolcCFVJUbUMQhOuvwrXp+Sag1VV3OG4Uy6P3/0wIajEumzHO4GvpAEJ1F1Ny4b692wP/TdUX/WWAIr

Add the ssh key to the GitHub "" -> "Settings" -> "Deploy keys" -> "Add new" -> "Allow write access"

Flux logo

Build container image

Fork the front-end repository:

hub -C tmp clone microservices-demo/front-end
hub -C tmp/front-end fork

Prepare Tekton pipelines:

envsubst < files/flux-repository/workloads/tekton-pipelineresource.yaml > tmp/k8s-flux-repository/workloads/tekton-pipelineresource.yaml
envsubst < files/flux-repository/workloads/tekton-task-pipeline.yaml    > tmp/k8s-flux-repository/workloads/tekton-task-pipeline.yaml
git -C tmp/k8s-flux-repository add --verbose .
git -C tmp/k8s-flux-repository commit -m "Add pipelines and pipelineresources"
git -C tmp/k8s-flux-repository push -q
sleep 15
fluxctl sync

Initiate PipelineRun which builds container image form git repository:

envsubst < files/flux-repository/workloads/tekton-pipelinerun.yaml > tmp/k8s-flux-repository/workloads/tekton-pipelinerun.yaml
git -C tmp/k8s-flux-repository add --verbose .
git -C tmp/k8s-flux-repository commit -m "Add pipeline and initiate build process"
git -C tmp/k8s-flux-repository push -q
fluxctl sync

Check if the build of docker image was completed:

kubectl wait --timeout=30m --for=condition=Succeeded pipelineruns/podinfo-build-docker-image-from-git-pipelinerun
kubectl get pipelineruns podinfo-build-docker-image-from-git-pipelinerun


NAME                                              SUCCEEDED   REASON      STARTTIME   COMPLETIONTIME
podinfo-build-docker-image-from-git-pipelinerun   True        Succeeded   7m48s       2m30s