forked from xunholy/k8s-gitops
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathflux.sh
executable file
·46 lines (34 loc) · 1.41 KB
/
flux.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#!/usr/bin/env bash
set -eou pipefail
CLEAN=${CLEAN:-true}
if [[ ! $(fluxctl) ]]; then
echo "Fluxctl needs to be manually installed - https://docs.fluxcd.io/en/latest/references/fluxctl/"
exit 1
fi
# Untaint master nodes
# TODO: Enable Ansible to allow configuring the taints to be added/removed.
[[ ! $(kubectl taint nodes --all node-role.kubernetes.io/master-) ]] && echo "Masters untainted"
# Ignore if namespace already exists
[[ ! $(kubectl get ns flux) ]] && kubectl create ns flux
if [[ -f .secrets/k8s-secret-fluxcd-ssh.yaml ]]; then
echo "Applying existing SSH key pair"
kubectl apply -f .secrets/k8s-secret-fluxcd-ssh.yaml
fi
if [[ -f .secrets/k8s-secret-fluxcd-ssh.yaml ]]; then
echo "Applying existing sealed-secret key"
kubectl apply -f .secrets/k8s-secret-sealed-secret-private-key.yaml
fi
helm repo add fluxcd https://charts.fluxcd.io
helm template fluxcd/flux \
--name-template=default \
--namespace=flux \
--version=1.5.0 \
--values=config/flux/values.yaml > flux.yaml
[[ -f flux.yaml ]] && kubectl apply -f flux.yaml
echo -e "\nCompleted..."
echo "Note: Follow these instructions to setup SSH keys if this is your first time: https://docs.fluxcd.io/en/latest/tutorials/get-started/#giving-write-access"
if [[ -f "flux.yaml" && $CLEAN == true ]]; then
echo -e "\nCleaning up manifests."
echo "Set CLEAN=false if you wish for this not to occur."
rm -rf flux.yaml
fi