Skip to content

Commit

Permalink
[tasks] improved multiple taskfiles cli
Browse files Browse the repository at this point in the history
  • Loading branch information
gruberdev committed Sep 19, 2023
1 parent a03d4f9 commit d2a9f4c
Show file tree
Hide file tree
Showing 13 changed files with 190 additions and 382 deletions.
10 changes: 8 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,14 @@ config/k3s/*.yaml
config/talos/**/*.yaml
config/talos/**/*.talosconfig
config/talos/**/talosconfig
config/**/*.yaml
config/docker/**/talosconfig
apps/services/changedetection/base/svc.yaml
!config/talos/controller-patch.yaml
!config/talos/patch.yaml
!config/talos/worker-patch.yaml
config/**/*.yaml
apps/services/changedetection/base/svc.yaml
!config/docker/controller-patch.yaml
!config/docker/patch.yaml
!config/docker/worker-patch.yaml
!config/manifests/calico.yaml
aggregated_output.json
94 changes: 23 additions & 71 deletions Taskfile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,61 +3,32 @@ version: '3'
silent: true

includes:
cli: ./tasks/cli.yaml
postgres: ./tasks/postgres.yaml
tailscale: ./tasks/tailscale.yaml
argocd: ./tasks/argocd.yaml
vault: ./tasks/vault.yaml
vultr: ./tasks/vultr.yaml
tf: ./tasks/terraform.yaml
secrets: ./tasks/secrets.yaml
longhorn: ./tasks/longhorn.yaml
cluster: ./tasks/cluster.yaml
matrix: ./tasks/matrix.yaml
test: ./tasks/test.yaml
talos: ./tasks/talos.yaml
commit: ./tasks/commit.yaml
milvus: ./tasks/milvus.yaml

vars:
CYAN: tput setaf 6
RED: tput setaf 1
YELLOW: tput setaf 3
GREEN: tput setaf 2
BLUE: tput setaf 1
PURPLE: tput setaf 5
BG_B: tput setab 0
BOLD: tput bold
RESET: tput sgr0
CLEAR: tput reset
PATH_ERROR: is not installed or correctly configured in PATH.
K8S_VERSION: 1.28.1

dotenv: ['.env']

tasks:
clear:

cmds:
- sleep 0.1 && {{.CLEAR}}

highlight_bg:
cmds:
- |
sleep 0.1 && \
{{.CYAN}} && \
{{.BOLD}} && \
{{.BG_B}}
highlight_normal:
cmds:
- |
sleep 0.1 && \
{{.CYAN}} && \
{{.BOLD}}
reset:
cmds:
- |
sleep 0.1 && \
{{.RESET}}
explain:
desc: Explains a certain Task command more in-detail
cmds:
Expand Down Expand Up @@ -94,31 +65,12 @@ tasks:
msg: "kubeconform {{.PATH_ERROR}}"
desc: Validates your Yaml objects in the repository using Kubeconform
cmds:
# yamllint disable-line rule:line-length
- sleep 0.1 && {{.CYAN}} && {{.BOLD}} && {{.BG_B}} && echo -e "\nValidating Yaml files using Kubeconform..." && {{.RESET}}
- sleep 0.1 && {{.CYAN}} && echo -e "\nService object files" && {{.RESET}}
- find . -maxdepth 20 -name svc.yaml -exec kubeconform -summary -exit-on-error -ignore-missing-schemas -kubernetes-version "{{.K8S_VERSION}}" -schema-location default {} \;
- sleep 0.1 && {{.CYAN}} && echo -e "\nDeployment object files" && {{.RESET}}
- find . -maxdepth 20 -name deployment.yaml -exec kubeconform -summary -exit-on-error -ignore-missing-schemas -kubernetes-version "{{.K8S_VERSION}}" -schema-location default {} \;
- sleep 0.1 && {{.CYAN}} && echo -e "\nSecret object files" && {{.RESET}}
- find . -maxdepth 20 -name \*secret.yaml -exec kubeconform -summary -exit-on-error -ignore-missing-schemas -kubernetes-version "{{.K8S_VERSION}}" -schema-location default {} \;
- sleep 0.1 && {{.CYAN}} && echo -e "\nconfigMap object files" && {{.RESET}}
- find . -maxdepth 20 -name cm.yaml -exec kubeconform -summary -exit-on-error -ignore-missing-schemas -kubernetes-version "{{.K8S_VERSION}}" -schema-location default {} \;
- sleep 0.1 && {{.CYAN}} && echo -e "\nPVC object files" && {{.RESET}}
- find . -maxdepth 20 -name pvc.yaml -exec kubeconform -summary -exit-on-error -ignore-missing-schemas -kubernetes-version "{{.K8S_VERSION}}" -schema-location default {} \;
- sleep 0.1 && {{.CYAN}} && echo -e "\nPV object files" && {{.RESET}}
- find . -maxdepth 10 -name pv.yaml -exec kubeconform -summary -exit-on-error -ignore-missing-schemas -kubernetes-version "{{.K8S_VERSION}}" -schema-location default {} \;
# yamllint disable-line rule:line-length
# - sleep 0.1 && {{.CYAN}} && echo -e "\nCustomRoleBinding object files" && {{.RESET}}
# - find . -maxdepth 10 -name crb.yaml -exec kubeval {} \;
- sleep 0.1 && {{.CYAN}} && echo -e "\nRole object files" && {{.RESET}}
- find . -maxdepth 20 -name role.yaml -exec kubeconform -summary -exit-on-error -ignore-missing-schemas -kubernetes-version "{{.K8S_VERSION}}" -schema-location default {} \;
- sleep 0.1 && {{.CYAN}} && echo -e "\nServiceAccount object files" && {{.RESET}}
- find . -maxdepth 20 -name sa.yaml -exec kubeconform -summary -exit-on-error -ignore-missing-schemas -kubernetes-version "{{.K8S_VERSION}}" -schema-location default {} \;
- sleep 0.1 && {{.CYAN}} && echo -e "\nClusterRole object files" && {{.RESET}}
- find . -maxdepth 20 -name cr.yaml -exec kubeconform -summary -exit-on-error -ignore-missing-schemas -kubernetes-version "{{.K8S_VERSION}}" -schema-location default {} \;
- sleep 0.1 && {{.CYAN}} && echo -e "\nRole Binding object files" && {{.RESET}}
- find . -maxdepth 20 -name rb.yaml -exec kubeconform -summary -exit-on-error -ignore-missing-schemas -kubernetes-version "{{.K8S_VERSION}}" -schema-location default {} \;
- |
objectTypes=("svc" "deployment" "*secret" "cm" "pvc" "pv" "role" "sa" "cr" "rb");
for obj in "${objectTypes[@]}"; do
echo -e "\nValidating ${obj^} object files";
find . -maxdepth 20 -name ${obj}.yaml -exec kubeconform -summary -exit-on-error -ignore-missing-schemas -kubernetes-version "{{.K8S_VERSION}}" -schema-location default {} \;
done
silent: true

calc:
Expand Down Expand Up @@ -148,12 +100,12 @@ tasks:
name configured on the file ('k3d-demo'), as to avoid creating those
resoures on non-local clusters that may be on KUBECONFIG file as well.
cmds:
- task: clear
- task: cli:clear
- k3d cluster delete --config config/k3d.yaml
- k3d cluster create --config config/k3d.yaml
- task: highlight_normal
- task: cli:highlight_normal
- echo -e "\nYour cluster has been created. Type 'k3d cluster list' to confirm."
- task: reset
- task: cli:reset
ignore_error: true

test:k3d:destroy:
Expand All @@ -162,11 +114,11 @@ tasks:
- sh: "which k3d"
msg: "k3d {{.PATH_ERROR}}"
cmds:
- task: clear
- task: cli:clear
- k3d cluster delete --config config/k3d.yaml
- task: highlight_normal
- task: cli:highlight_normal
- echo -e "\nYour cluster has been destroyed."
- task: reset
- task: cli:reset
ignore_error: true

repos:
Expand All @@ -175,10 +127,10 @@ tasks:
- sh: "which helm"
msg: "helm {{.PATH_ERROR}}"
cmds:
- task: clear
- task: highlight_bg
- task: cli:clear
- task: cli:highlight_bg
- echo -e "This will add new repositories to your local Helm\n"
- task: reset
- task: cli:reset
- helm repo add chaos-mesh https://charts.chaos-mesh.org
- helm repo add hashicorp https://helm.releases.hashicorp.com
- helm repo add bitnami https://charts.bitnami.com/bitnami
Expand All @@ -200,11 +152,11 @@ tasks:
- helm repo add eraser https://azure.github.io/eraser/charts
- helm repo add vmware-tanzu https://vmware-tanzu.github.io/helm-charts
- helm repo add mayastor https://openebs.github.io/mayastor-extensions/
- task: clear
- task: cli:clear
- echo -e "This will add new repositories to your local Helm\n"
- task: highlight_normal
- task: cli:highlight_normal
- echo -e "Finished adding repositories. Updating them now.\n"
- task: reset
- task: cli:reset
- helm repo update
ignore_error: true

Expand All @@ -222,11 +174,11 @@ tasks:
user to reverse those changes, avoiding pollution on your hosts
(or equivalent) file.
cmds:
- task: clear
- task: cli:clear
- sleep 0.01 && {{if eq OS "windows"}}hostctl add k8s -q < config/.etchosts{{else}}sudo hostctl add k8s -q < config/.etchosts{{end}}
- task: highlight_normal
- task: cli:highlight_normal
- echo -e "Added 'k8s.localhost' and related domains to your hosts file!"
- task: reset
- task: cli:reset
ignore_error: true

run:
Expand Down
25 changes: 19 additions & 6 deletions apps/argocd/base/mlops/milvus.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,22 @@ spec:
- ApplyOutOfSyncOnly=false
- Prune=true
- ServerSideApply=true
retry:
limit: 5
backoff:
duration: 20s
factor: 2
maxDuration: 15m
info:
- name: 'Github Repository:'
value: >-
https://github.com/zilliztech/milvus-operator
- name: 'Manifests example folder:'
value: >-
https://github.com/zilliztech/milvus-operator/tree/main/config/samples
- name: 'Official Website:'
value: >-
https://milvus.io
- name: 'Documentation:'
value: >-
https://milvus.io/docs/install_standalone-operator.md
retry:
limit: 5
backoff:
duration: 20s
factor: 2
maxDuration: 15m
39 changes: 39 additions & 0 deletions tasks/cli.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
version: '3'

silent: true

vars:
CYAN: tput setaf 6
RED: tput setaf 1
YELLOW: tput setaf 3
GREEN: tput setaf 2
BLUE: tput setaf 1
PURPLE: tput setaf 5
BG_B: tput setab 0
BOLD: tput bold
RESET: tput sgr0
CLEAR: tput reset

tasks:
clear:
cmds:
- sleep 0.1 && {{.CLEAR}}

highlight_bg:
cmds:
- |
sleep 0.1 && \
{{.CYAN}} && \
{{.BOLD}} && \
{{.BG_B}}
highlight_normal:
cmds:
- |
sleep 0.1 && \
{{.CYAN}} && \
{{.BOLD}}
reset:
cmds:
- |
sleep 0.1 && \
{{.RESET}}
12 changes: 1 addition & 11 deletions tasks/cluster.yaml
Original file line number Diff line number Diff line change
@@ -1,15 +1,5 @@
version: '3'
vars:
CYAN: tput setaf 6
RED: tput setaf 1
YELLOW: tput setaf 3
GREEN: tput setaf 2
BLUE: tput setaf 1
PURPLE: tput setaf 5
BG_B: tput setab 0
BOLD: tput bold
RESET: tput sgr0
CLEAR: tput reset
PATH_ERROR: is not installed or correctly configured in PATH.
SVC_IPV4_CIDR: 10.43.0.0/16
SVC_IPV6_CIDR: 2001:cafe:42:1::/112
Expand Down Expand Up @@ -209,7 +199,7 @@ tasks:
"type": "k8s"
},
"kubernetes": {
"kubeconfig": "/etc/rancher/k3s/k3s.yaml"
"kubeconfig": "__KUBECONFIG_FILEPATH__"
},
"container_settings": {
"allow_ip_forwarding": true
Expand Down
10 changes: 0 additions & 10 deletions tasks/commit.yaml
Original file line number Diff line number Diff line change
@@ -1,15 +1,5 @@
version: '3'
vars:
CYAN: tput setaf 6
RED: tput setaf 1
YELLOW: tput setaf 3
GREEN: tput setaf 2
BLUE: tput setaf 1
PURPLE: tput setaf 5
BG_B: tput setab 0
BOLD: tput bold
RESET: tput sgr0
CLEAR: tput reset
PATH_ERROR: is not installed or correctly configured in PATH.
env:
VERSION: "1.3.1"
Expand Down
Loading

0 comments on commit d2a9f4c

Please sign in to comment.