Skip to content

Instantly share code, notes, and snippets.

@chancez
Last active December 13, 2019 18:39
Show Gist options
  • Save chancez/ce655dc6edd2babbc7c5ea66ae678550 to your computer and use it in GitHub Desktop.
Save chancez/ce655dc6edd2babbc7c5ea66ae678550 to your computer and use it in GitHub Desktop.
#!/bin/bash
set -u
set -x
FLUX_GIT_DEPLOY_KEY_SECRET=flux-git-deploy
FLUX_DEPLOY_KEY_PATH="${FLUX_DEPLOY_KEY_PATH:?}"
FLUX_GIT_REPO='git@github.com:chancez/flux-get-started.git'
HELM_BIN="${HELM_BIN:-helm2}"
# Setup helm creds
kubectl -n kube-system create sa tiller \
--dry-run -o yaml | kubectl -n kube-system apply -f -
kubectl create clusterrolebinding tiller-cluster-rule \
--clusterrole=cluster-admin \
--serviceaccount=kube-system:tiller \
--dry-run -o yaml | kubectl apply -f -
# Install helm
"$HELM_BIN" init \
--skip-refresh --upgrade \
--service-account tiller --history-max 10 \
--wait
# add the flux helm chart repository
"$HELM_BIN" repo add fluxcd https://charts.fluxcd.io
# Install the HelmRelease CRD
kubectl apply \
-f https://raw.githubusercontent.com/fluxcd/flux/helm-0.10.1/deploy-helm/flux-helm-release-crd.yaml
# Setup flux creds
kubectl create ns flux
# TODO: when helm-operator supports https deploy tokens/personal access tokens switch to that
kubectl create -n flux \
secret generic $FLUX_GIT_DEPLOY_KEY_SECRET \
--from-file=identity="$FLUX_DEPLOY_KEY_PATH" \
--dry-run -o yaml | kubectl -n flux apply -f -
# install flux using helm
"$HELM_BIN" upgrade --install \
flux \
--namespace flux \
--set git.url="$FLUX_GIT_REPO" \
--set git.secretName=$FLUX_GIT_DEPLOY_KEY_SECRET \
--set 'additionalArgs[0]=--sync-garbage-collection' \
--set prometheus.serviceMonitor.create=true \
--set helmOperator.create=true \
--set helmOperator.createCRD=false \
--set helmOperator.workers=5 \
--set helmOperator.git.pollInterval=1m \
--set helmOperator.chartsSyncInterval=1m \
--set helmOperator.logReleaseDiffs=true \
--set helmOperator.prometheus.serviceMonitor.create=true \
fluxcd/flux
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment