generated from onedr0p/cluster-template
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathClusterTasks.yml
45 lines (38 loc) · 1.73 KB
/
ClusterTasks.yml
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
---
version: "3"
tasks:
verify:
desc: Verify flux meets the prerequisites
cmds:
- flux check --pre
install:
desc: Install Flux into your cluster
cmds:
- kubectl apply --kustomize {{.CLUSTER_DIR}}/bootstrap/
- cat {{.SOPS_AGE_KEY_FILE}} | kubectl -n flux-system create secret generic sops-age --from-file=age.agekey=/dev/stdin --save-config --dry-run=client -o yaml | kubectl apply -f -
- kubectl apply --kustomize {{.CLUSTER_DIR}}/flux/flux-system/
- task: reconcile
preconditions:
- sh: test -f {{.SOPS_AGE_KEY_FILE}}
msg: |
Age key file is not found. Did you forget to create it?
vars:
SOPS_AGE_KEY_FILE: ~/.config/sops/age/keys.txt
reconcile:
desc: Force update Flux to pull in changes from your Git repository
cmds:
- flux reconcile -n flux-system source git flux-cluster
- flux reconcile -n flux-system kustomization flux-cluster
list-dockerhub:
desc: What dockerhub images are running in my cluster
cmds:
- kubectl get pods --all-namespaces -o=jsonpath="{range .items[*]}{'\n'}{range .spec.containers[*]}{.image}{'\n'}{end}{end}" | sort | uniq | grep -Ev 'quay|gcr|ghcr|ecr|us-docker' | grep -Ev 'bitnami|rook|intel|grafana' | sed -e 's/docker\.io\///g' | sort | uniq
delete-failed-pods:
desc: Deletes failed pods
cmds:
- kubectl delete pods --field-selector status.phase=Failed -A --ignore-not-found=true
hr-restart:
desc: Restart all failed Helm Releases
cmds:
- kubectl get hr --all-namespaces | grep False | awk '{print $2, $1}' | xargs -l bash -c 'flux suspend hr $0 -n $1'
- kubectl get hr --all-namespaces | grep False | awk '{print $2, $1}' | xargs -l bash -c 'flux resume hr $0 -n $1'