feat: add scripts

This commit is contained in:
Toboshii Nakama
2022-07-18 05:38:33 -05:00
parent 54392150ec
commit a9d80104c7
4 changed files with 66 additions and 0 deletions

View File

@@ -3,6 +3,31 @@ 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
- 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:

View File

@@ -1,6 +1,13 @@
---
version: "3"
vars:
PROJECT_DIR:
sh: "git rev-parse --show-toplevel"
CLUSTER_DIR: "{{.PROJECT_DIR}}/cluster"
ANSIBLE_DIR: "{{.PROJECT_DIR}}/provision/ansible"
TERRAFORM_DIR: "{{.PROJECT_DIR}}/provision/terraform"
includes:
ansible: .taskfiles/AnsibleTasks.yml
backup: .taskfiles/BackupTasks.yml

20
hack/deploy.sh Executable file
View File

@@ -0,0 +1,20 @@
#!/bin/bash
# Configure the control-plane nodes
talosctl apply-config -i -n k8s-control01 -f ../talos/clusterconfig/cluster01-k8s-control01.dfw.56k.sh.yaml
talosctl apply-config -i -n k8s-control02 -f ../talos/clusterconfig/cluster01-k8s-control02.dfw.56k.sh.yaml
talosctl apply-config -i -n k8s-control03 -f ../talos/clusterconfig/cluster01-k8s-control03.dfw.56k.sh.yaml
# Configure the worker nodes
talosctl apply-config -i -n k8s-worker01 -f ../talos/clusterconfig/cluster01-k8s-worker01.dfw.56k.sh.yaml
talosctl apply-config -i -n k8s-worker02 -f ../talos/clusterconfig/cluster01-k8s-worker02.dfw.56k.sh.yaml
talosctl apply-config -i -n k8s-worker03 -f ../talos/clusterconfig/cluster01-k8s-worker03.dfw.56k.sh.yaml
# talosctl --talosconfig=./talosconfig config endpoint k8s-control01 k8s-control02 k8s-control03
# talosctl config merge ./talosconfig
# It will take a few minutes for the nodes to spin up with the configuration. Once ready, execute
# talosctl --talosconfig=./talosconfig bootstrap -n k8s-control01
# It will then take a few more minutes for Kubernetes to get up and running on the nodes. Once ready, execute
# talosctl --talosconfig=./talosconfig kubeconfig -n k8s-control01

14
hack/reset.sh Executable file
View File

@@ -0,0 +1,14 @@
#!/bin/bash
# Reset the worker nodes first since the path to them is through the control plane nodes
talosctl reset --graceful=false --reboot -n k8s-control01 -e k8s-control01
talosctl reset --graceful=false --reboot -n k8s-control02 -e k8s-control02
talosctl reset --graceful=false --reboot -n k8s-control03 -e k8s-control03
echo "Waiting for workers to reset... ^C to stop here"
sleep 5
# Reset the control plane nodes
talosctl reset --graceful=false --reboot -n k8s-worker01 -e k8s-worker01
talosctl reset --graceful=false --reboot -n k8s-worker02 -e k8s-worker02
talosctl reset --graceful=false --reboot -n k8s-worker03 -e k8s-worker03