From bc0d8e126174e072a8b7f33263840650bd1a64a2 Mon Sep 17 00:00:00 2001 From: Benjamin Runnels Date: Sat, 20 Jan 2024 17:18:56 -0600 Subject: [PATCH] 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 --- .taskfiles/Flux/Taskfile.yaml | 19 +++++++++++-------- bootstrap/vars/addons.sample.yaml | 3 +++ 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/.taskfiles/Flux/Taskfile.yaml b/.taskfiles/Flux/Taskfile.yaml index 818851dc2d4..bf0c4f08a3e 100644 --- a/.taskfiles/Flux/Taskfile.yaml +++ b/.taskfiles/Flux/Taskfile.yaml @@ -27,15 +27,15 @@ tasks: - kubectl apply --kubeconfig {{.KUBECONFIG_FILE}} --server-side --filename {{.CLUSTER_SETTINGS_USER_FILE}} - kubectl apply --kubeconfig {{.KUBECONFIG_FILE}} --server-side --kustomize {{.KUBERNETES_DIR}}/flux/config 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: "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}}" } apply: desc: Apply a Flux Kustomization resource for a cluster summary: | 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) cmd: | flux --kubeconfig {{.KUBECONFIG_FILE}} build ks $(basename {{.path}}) \ @@ -47,24 +47,27 @@ tasks: kubectl apply --kubeconfig {{.KUBECONFIG_FILE}} --server-side \ --field-manager=kustomize-controller -f - requires: - vars: ["path", "ns"] + vars: ["path"] vars: + ns: '{{.ns | default "flux-system"}}' 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: - - { 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: "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: 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 preconditions: - - { msg: "Flux not installed", sh: "kubectl get namespace flux-system" } - { 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: cmd: sops --decrypt {{.KUBERNETES_DIR}}/bootstrap/github-deploy-key.sops.yaml | kubectl apply --kubeconfig {{.KUBECONFIG_FILE}} --server-side --filename - 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: "Flux not installed", sh: "kubectl get namespace flux-system --kubeconfig {{.KUBECONFIG_FILE}} &>/dev/null && exit 0 || exit 1" } diff --git a/bootstrap/vars/addons.sample.yaml b/bootstrap/vars/addons.sample.yaml index 1407bf38831..e2e3628c8ea 100644 --- a/bootstrap/vars/addons.sample.yaml +++ b/bootstrap/vars/addons.sample.yaml @@ -67,4 +67,7 @@ longhorn: # Longhorn is currently unsupported in Talos # Note: Consider enabling volsync if you would like to configure snapshots # 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.longhorn.io/create-default-disk="true" enabled: false