fix: resolved several issues with flux tasks (#1209)

* fixed several issues with flux tasks

* removed unnecessary default

* added note for longhorn addon

* added note for longhorn addon
This commit is contained in:
Benjamin Runnels authored and GitHub committed 2024-01-20 18:18:56 -05:00
1 parent 1ec59d1559
commit bc0d8e1261
2 files changed
+14 -8

No files matched your search

+11 -8
View File
@@ -27,15 +27,15 @@ tasks:
- kubectl apply --kubeconfig {{.KUBECONFIG_FILE}} --server-side --filename {{.CLUSTER_SETTINGS_USER_FILE}} - kubectl apply --kubeconfig {{.KUBECONFIG_FILE}} --server-side --filename {{.CLUSTER_SETTINGS_USER_FILE}}
- kubectl apply --kubeconfig {{.KUBECONFIG_FILE}} --server-side --kustomize {{.KUBERNETES_DIR}}/flux/config - kubectl apply --kubeconfig {{.KUBECONFIG_FILE}} --server-side --kustomize {{.KUBERNETES_DIR}}/flux/config
preconditions: preconditions:
- { msg: "Flux already installed", sh: "kubectl get namespace flux-system &>/dev/null && exit 1 || exit 0" }
- { msg: "Missing kubeconfig", sh: "test -f {{.KUBECONFIG_FILE}}" } - { msg: "Missing kubeconfig", sh: "test -f {{.KUBECONFIG_FILE}}" }
- { msg: "Flux already installed", sh: "kubectl get namespace flux-system --kubeconfig {{.KUBECONFIG_FILE}} &>/dev/null && exit 1 || exit 0" }
- { msg: "Missing Sops Age key file", sh: "test -f {{.SOPS_AGE_FILE}}" } - { msg: "Missing Sops Age key file", sh: "test -f {{.SOPS_AGE_FILE}}" }
apply: apply:
desc: Apply a Flux Kustomization resource for a cluster desc: Apply a Flux Kustomization resource for a cluster
summary: | summary: |
Args: Args:
path: Path containing the Flux Kustomization resource (ks.yaml) (required) path: Path under {{.KUBERNETES_DIR}}/apps/ containing the Flux Kustomization resource (ks.yaml) (required)
ns: Namespace the Flux Kustomization exists in (default: flux-system) ns: Namespace the Flux Kustomization exists in (default: flux-system)
cmd: | cmd: |
flux --kubeconfig {{.KUBECONFIG_FILE}} build ks $(basename {{.path}}) \ flux --kubeconfig {{.KUBECONFIG_FILE}} build ks $(basename {{.path}}) \
@@ -47,24 +47,27 @@ tasks:
kubectl apply --kubeconfig {{.KUBECONFIG_FILE}} --server-side \ kubectl apply --kubeconfig {{.KUBECONFIG_FILE}} --server-side \
--field-manager=kustomize-controller -f - --field-manager=kustomize-controller -f -
requires: requires:
vars: ["path", "ns"] vars: ["path"]
vars: vars:
ns: '{{.ns | default "flux-system"}}'
ks: ks:
sh: flux --kubeconfig {{.KUBECONFIG_FILE}} --namespace {{.ns}} get kustomizations $(basename {{.path}}) 2>&1 sh: |
[ -f {{.KUBECONFIG_FILE}} ] || exit 0;
flux --kubeconfig {{.KUBECONFIG_FILE}} --namespace {{.ns}} get kustomizations $(basename {{.path}}) 2>&1
preconditions: preconditions:
- { msg: "Flux already installed", sh: "kubectl get namespace flux-system &>/dev/null && exit 1 || exit 0" }
- { msg: "Missing Flux Kustomization", sh: "test -f {{.KUBERNETES_DIR}}/apps/{{.path}}/ks.yaml" }
- { msg: "Missing kubeconfig", sh: "test -f {{.KUBECONFIG_FILE}}" } - { msg: "Missing kubeconfig", sh: "test -f {{.KUBECONFIG_FILE}}" }
- { msg: "Namespace {{.ns}} does not exist", sh: "kubectl get namespace {{.ns}} --kubeconfig {{.KUBECONFIG_FILE}} &>/dev/null && exit 0 || exit 1" }
- { msg: "Missing Flux Kustomization for app {{.path}}", sh: "test -f {{.KUBERNETES_DIR}}/apps/{{.path}}/ks.yaml" }
reconcile: reconcile:
desc: Force update Flux to pull in changes from your Git repository desc: Force update Flux to pull in changes from your Git repository
cmd: flux --kubeconfig {{.KUBECONFIG_FILE}} reconcile --namespace flux-system kustomization cluster --with-source cmd: flux --kubeconfig {{.KUBECONFIG_FILE}} reconcile --namespace flux-system kustomization cluster --with-source
preconditions: preconditions:
- { msg: "Flux not installed", sh: "kubectl get namespace flux-system" }
- { msg: "Missing kubeconfig", sh: "test -f {{.KUBECONFIG_FILE}}" } - { msg: "Missing kubeconfig", sh: "test -f {{.KUBECONFIG_FILE}}" }
- { msg: "Flux not installed", sh: "kubectl get namespace flux-system --kubeconfig {{.KUBECONFIG_FILE}} &>/dev/null && exit 0 || exit 1" }
github-deploy-key: github-deploy-key:
cmd: sops --decrypt {{.KUBERNETES_DIR}}/bootstrap/github-deploy-key.sops.yaml | kubectl apply --kubeconfig {{.KUBECONFIG_FILE}} --server-side --filename - cmd: sops --decrypt {{.KUBERNETES_DIR}}/bootstrap/github-deploy-key.sops.yaml | kubectl apply --kubeconfig {{.KUBECONFIG_FILE}} --server-side --filename -
preconditions: preconditions:
- { msg: "Flux already installed", sh: "kubectl get namespace flux-system &>/dev/null && exit 1 || exit 0" }
- { msg: "Missing kubeconfig", sh: "test -f {{.KUBECONFIG_FILE}}" } - { msg: "Missing kubeconfig", sh: "test -f {{.KUBECONFIG_FILE}}" }
- { msg: "Flux not installed", sh: "kubectl get namespace flux-system --kubeconfig {{.KUBECONFIG_FILE}} &>/dev/null && exit 0 || exit 1" }
+3
View File
@@ -67,4 +67,7 @@ longhorn:
# Longhorn is currently unsupported in Talos # Longhorn is currently unsupported in Talos
# Note: Consider enabling volsync if you would like to configure snapshots # Note: Consider enabling volsync if you would like to configure snapshots
# and backups to durable storage. # and backups to durable storage.
# Note: You must label any node that you want to allocate storage to longhorn
# with label node.longhorn.io/create-default-disk="true"
# ie: kubectl label --overwrite node <node name> node.longhorn.io/create-default-disk="true"
enabled: false enabled: false