Running this blog on Kubernetes - Part 2

  1. Get the fluxctl binary and save it on your path

    wget -O fluxctl https://github.com/fluxcd/flux/releases/download/1.18.0/fluxctl_linux_amd64
    sudo mv fluxctl_linux_amd64 /usr/local/sbin/fluxctl
    
  2. Create the namespace

    ./create-flux.sh
    

Save the fluxcd ID and paste that into GitHub

fluxctl identity --k8s-fwd-ns flux

NOTE: If using a private registry for your images (such as Azure Container Registry), you will have to do a few more steps as described bellow.

  1. Create a secret with the credentials for the registry

    
    DOCKER_USERNAME=dcasati
    DOCKER_PASSWORD=UNJl/4wPOX94rRj64l2F6LM91SUSN0B7
    DOCKER_EMAIL=diego.casati@gmail.com
    DOCKER_SERVER=dcasati.azurecr.io/dcasati.net
    
    kubectl create secret docker-registry acrcreds          \
    --docker-server=dcasati.azurecr.io                  \
    --docker-username=${DOCKER_USERNAME}                \
    --docker-password=${DOCKER_PASSWORD}                \
    --docker-email=diego.casati@gmail.com               \
    -n dcasati-net
    
  2. Patch the service account so it has access to the secrets.

    kubectl patch serviceaccount default -p '{"imagePullSecrets": [{"name": "acrcreds"}]}'
    

XXX Need to test this

kubectl patch serviceaccount default -p '{"imagePullSecrets": [{"name": "acrcreds"}]}' -n flux
kubectl patch serviceaccount flux -p '{"imagePullSecrets": [{"name": "acrcreds"}]}' -n flux

You can manually do a sync at this point to validate that everything is working.

fluxctl sync --k8s-fwd-ns flux
  1. Setting up a LoadBalancer with a static IP address:

    az aks show -g dcasatinet -n alpha --query nodeResourceGroup -o tsv
    
    az network public-ip create -g MC_dcasati-net_alpha_southcentralus -n alpha-pip --allocation-method static --sku Standard
    

Add this IP address to the service.yaml file. It will look like this:

IPADDRESS=$(az network public-ip list -g  MC_dcasati-net_alpha_southcentralus --query "[?name=='alpha-pip']" -o json | jq  '.[0].ipAddress')
sed -E "s/(loadBalancerIP:)(.*)/\1 `echo $IPADDRESS | tr '"' " "`/" ../manifests/service.yaml | k apply -f -