generated from hadenlabs/base-template
-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(tasks): implement task to keybase and multipass (#3)
- Loading branch information
Showing
3 changed files
with
181 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
version: "3" | ||
|
||
tasks: | ||
check: | ||
desc: Exist sops and dependences | ||
run: once | ||
deps: | ||
- task: check:sops | ||
- task: check:gpg | ||
- task: check:vars | ||
|
||
check:sops: | ||
desc: Exist sops | ||
run: once | ||
preconditions: | ||
- sh: command -v sops | ||
msg: "Please Install sops" | ||
|
||
check:gpg: | ||
desc: Exist sops | ||
run: once | ||
preconditions: | ||
- sh: command -v gpg | ||
msg: "Please Install gpg" | ||
|
||
check:vars: | ||
desc: Exist vars for sops | ||
run: once | ||
preconditions: | ||
- sh: test -v GPG_KEY | ||
msg: "Please add var environment GPG_KEY" | ||
- sh: test -v KEYBASE_PROJECT_PATH | ||
msg: "Please add var environment KEYBASE_PROJECT_PATH" | ||
|
||
make: | ||
desc: Make sops gen key. | ||
run: once | ||
deps: | ||
- task: check | ||
cmds: | ||
- >- | ||
gpg --batch --gen-key {{.GPG_FILE_CONF}} | ||
import: | ||
desc: Import gpg key. | ||
run: once | ||
deps: | ||
- task: check | ||
cmds: | ||
- >- | ||
gpg --import {{.KEYBASE_PROJECT_PATH}}/gpg/key.asc | ||
export: | ||
desc: export gpg key. | ||
run: once | ||
deps: | ||
- task: check:sops | ||
- task: environment | ||
cmds: | ||
- >- | ||
gpg --armor --export-secret-keys {{.GPG_KEY}} > {{.KEYBASE_PROJECT_PATH}}/gpg/key.asc | ||
environment: | ||
desc: setup environment sops. | ||
run: once | ||
deps: | ||
- task: check:sops | ||
cmds: | ||
- cmd: mkdir -p {{.KEYBASE_PROJECT_PATH}}/gpg | ||
- cmd: mkdir -p {{.KEYBASE_TEAM_PATH}}/k8s |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,107 @@ | ||
version: "3" | ||
|
||
tasks: | ||
check: | ||
desc: Exist multipass and dependences | ||
run: once | ||
deps: | ||
- task: check:multipass | ||
|
||
check:multipass: | ||
desc: Exist multipass | ||
run: once | ||
preconditions: | ||
- sh: command -v multipass | ||
msg: "Please Install multipass" | ||
|
||
make:path: | ||
desc: make paths | ||
run: once | ||
cmds: | ||
- task: make:path:build | ||
|
||
make:path:build: | ||
desc: make path build | ||
run: once | ||
cmds: | ||
- cmd: mkdir -p {{.BUILD_PATH}} | ||
|
||
launch: | ||
desc: launch multipass. | ||
run: once | ||
deps: | ||
- task: check:multipass | ||
cmds: | ||
- task: make:path | ||
- >- | ||
multipass launch --verbose --name {{.MULTIPASS_LAUNCH_NAME}} --cloud-init {{.MULTIPASS_CLOUD_INIT_FILE}} {{.MULTIPASS_ARGS}} {{.CLI_ARGS}} | ||
launch:k8s:master: | ||
desc: launch k8s master. | ||
run: once | ||
cmds: | ||
- task: launch | ||
vars: | ||
MULTIPASS_LAUNCH_NAME: k8s-master | ||
MULTIPASS_CLOUD_INIT_FILE: provision/multipass/kubernetes/master.yaml | ||
MULTIPASS_ARGS: -c 2 -m 2G --disk 20G | ||
- cmd: multipass exec {{.MULTIPASS_LAUNCH_NAME}} -- bash -c 'sudo cat /etc/kubernetes/admin.conf' > {{.KUBECONFIG}} | ||
vars: | ||
MULTIPASS_LAUNCH_NAME: k8s-master | ||
- cmd: echo "wait ...." | ||
- cmd: sleep 50 | ||
- cmd: echo "now deploying calico ...." | ||
- cmd: KUBECONFIG={{.KUBECONFIG}} kubectl apply -f https://docs.projectcalico.org/manifests/tigera-operator.yaml | ||
- cmd: KUBECONFIG={{.KUBECONFIG}} kubectl apply -f provision/k8s/manifests/overlays/core/calico/crd.yaml | ||
- cmd: KUBECONFIG={{.KUBECONFIG}} kubectl get pods -n calico-system | ||
- cmd: KUBECONFIG={{.KUBECONFIG}} kubectl taint nodes --all node-role.kubernetes.io/master- | ||
- cmd: KUBECONFIG={{.KUBECONFIG}} kubectl get nodes -o wide | ||
- cmd: multipass exec {{.MULTIPASS_LAUNCH_NAME}} -- bash -c 'sudo kubeadm token create --print-join-command' > {{.BUILD_PATH}}/kubeadm_join.sh | ||
vars: | ||
MULTIPASS_LAUNCH_NAME: k8s-master | ||
- cmd: echo "Now deploying the worker nodes" | ||
- cmd: multipass mount {{.MOUNT_PATH_K8S_LOCAL}} {{.MULTIPASS_LAUNCH_NAME}}:/data | ||
vars: | ||
MULTIPASS_LAUNCH_NAME: k8s-master | ||
|
||
launch:k8s:node: | ||
desc: launch k8s nodes. | ||
run: once | ||
cmds: | ||
- task: launch | ||
vars: | ||
MULTIPASS_LAUNCH_NAME: k8s-node | ||
MULTIPASS_CLOUD_INIT_FILE: provision/multipass/kubernetes/node.yaml | ||
MULTIPASS_ARGS: -c 2 -m 2G --disk 20G | ||
- cmd: multipass transfer {{.BUILD_PATH}}/kubeadm_join.sh {{.MULTIPASS_LAUNCH_NAME}}:kubeadm_join.sh | ||
- cmd: multipass exec {{.MULTIPASS_LAUNCH_NAME}} -- bash -c 'sudo chmod +x kubeadm_join.sh' | ||
- cmd: multipass exec {{.MULTIPASS_LAUNCH_NAME}} -- bash -c 'sudo sh ./kubeadm_join.sh' | ||
- cmd: KUBECONFIG={{.KUBECONFIG}} kubectl label node {{.MULTIPASS_LAUNCH_NAME}} node-role.kubernetes.io/node= | ||
- cmd: KUBECONFIG={{.KUBECONFIG}} kubectl get nodes | ||
- cmd: multipass mount {{.MOUNT_PATH_K8S_LOCAL}} {{.MULTIPASS_LAUNCH_NAME}}:/data | ||
vars: | ||
MULTIPASS_LAUNCH_NAME: k8s-node | ||
|
||
make:certificates: | ||
desc: make certificates and export. | ||
run: once | ||
deps: | ||
- task: check | ||
cmds: | ||
- cmd: mkcert '*.k8s.local' | ||
- cmd: mkdir -p {{.KEYBASE_PROJECT_PATH}}/keys/ | ||
- cmd: mv _wildcard.k8s.local.pem {{.KEYBASE_PROJECT_PATH}}/keys/ | ||
- cmd: mv _wildcard.k8s.local-key.pem {{.KEYBASE_PROJECT_PATH}}/keys/ | ||
status: | ||
- test -f {{.KEYBASE_PROJECT_PATH}}/keys/_wildcard.k8s.local.pem | ||
- test -f {{.KEYBASE_PROJECT_PATH}}/keys/_wildcard.k8s.local-key.pem | ||
|
||
launch:traefik: | ||
desc: make traefik. | ||
run: once | ||
deps: | ||
- task: check | ||
cmds: | ||
- task: make:certificates | ||
# - cmd: KUBECONFIG={{.KUBECONFIG}} kubectl create secret tls traefik-tls-cert --key={{.KEYBASE_PROJECT_PATH}}/keys/_wildcard.k8s.local-key.pem --cert={{.KEYBASE_PROJECT_PATH}}/keys/_wildcard.k8s.local.pem -n core | ||
- cmd: KUBECONFIG={{.KUBECONFIG}} kubectl apply -f provision/k8s/manifests/overlays/core/traefik/crd.yaml |