Skip to content
Snippets Groups Projects
Verified Commit 6242ec3a authored by Sheogorath's avatar Sheogorath :european_castle:
Browse files

Makefile: Add all commands to deploy the kubernetes controlplane

This patch adds a few util functions to deploy the entire kubernetes
cluster using `make deploy`. Currently it's still very iterative and not
ideal, but it works.
parent 753fe453
No related branches found
No related tags found
Loading
......@@ -21,6 +21,9 @@ cli-config: ## Configure koolbox CLI (To setup terraform values as well was toke
.PHONY: deploy
deploy: check-machine ## Deploy infrastructure on Hetzner Cloud
cd ./terraform && make apply
date
sleep 600
make kubernetes-install
.PHONY: destroy
destroy: check-machine ## Destroy infrastructure on Hetzner Cloud
......
.PHONY: flux-preflight
flux-preflight:
# Checking for required variables
env | grep -Pe '^GITLAB_TOKEN' > /dev/null
.PHONY: flux-watch
flux-watch: ## flux: Show currently deployed resources an their status in all namespaces
koolbox flux get all --all-namespaces
.PHONY: flux-update-git
flux-update-git: ## flux: Reload flux-system repository
koolbox flux reconcile source git flux-system
.PHONY: flux-bootstrap
flux-bootstrap: flux-preflight
flux bootstrap gitlab \
--hostname=git.shivering-isles.com \
--ssh-hostname=git.shivering-isles.com:2222 \
--ssh-key-algorithm ed25519 \
--owner=shivering-isles \
--repository=infrastructure-gitops \
--path=clusters/k8s01
.PHONY: kubeadm-init
kubeadm-init:
ssh node01.$(TF_VAR_dns_domain) kubeadm init --control-plane-endpoint "api.$(TF_VAR_dns_domain):6443" --upload-certs --pod-network-cidr "192.168.0.0/16"
ssh node01.$(TF_VAR_dns_domain) systemctl enable kubelet.service
kubeadm-copy-config: ## Copy Kubernetes admin config from node01 to the local machine
scp node01.$(TF_VAR_dns_domain):/etc/kubernetes/admin.conf /root/.kube/config
kubeadm-join-masters:
ssh node02.$(TF_VAR_dns_domain) $$(ssh node01.$(TF_VAR_dns_domain) kubeadm token create --ttl 1h --print-join-command --certificate-key "$$(ssh node01.$(TF_VAR_dns_domain) kubeadm init phase upload-certs --upload-certs | tail -1)" | tail -1)
ssh node02.$(TF_VAR_dns_domain) systemctl enable kubelet.service
ssh node03.$(TF_VAR_dns_domain) $$(ssh node01.$(TF_VAR_dns_domain) kubeadm token create --ttl 1h --print-join-command --certificate-key "$$(ssh node01.$(TF_VAR_dns_domain) kubeadm init phase upload-certs --upload-certs | tail -1)" | tail -1)
ssh node03.$(TF_VAR_dns_domain) systemctl enable kubelet.service
kubectl-remove-first-master-taints:
kubectl taint nodes node01.$(TF_VAR_dns_domain) node-role.kubernetes.io/master-
kubectl-remove-all-master-taints:
kubectl taint nodes --all node-role.kubernetes.io/master- || true
kubectl-delete-wrong-subnet:
kubectl get pods --all-namespaces -o wide | grep 10.85. | awk '{print "-n " $$1 " " $$2}' | xargs -L 1 kubectl delete pod
kubernetes-install: kubeadm-init kubeadm-copy-config kubectl-remove-first-master-taints flux-bootstrap kubeadm-join-masters kubectl-remove-all-master-taints kubectl-delete-wrong-subnet
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment