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

ci: Drop makefiles

parent 70c764f7
No related branches found
No related tags found
No related merge requests found
.DEFAULT_GOAL := help
REGISTRY_HOST := quay.io
include utils/*.mk
.PHONY: check-machine
check-machine: ## Check your local machine setup to be prepared for the installation
command -v kubectl >/dev/null
command -v ansible >/dev/null
command -v flux >/dev/null
command -v sops >/dev/null
command -v terraform >/dev/null
.PHONY: cli
cli: ## Install koolbox CLI (Contains all tools used in this project)
cd ./images/koolbox && make install REGISTRY_HOST=$(REGISTRY_HOST) USERNAME=shivering-isles
.PHONY: cli-config
cli-config: ## Configure koolbox CLI (To setup terraform values as well was tokens)
cd ./images/koolbox && make config
.PHONY: docs
docs: cli ## Build and render docs locally
cd ./docs && make serve
.PHONY: validate
validate:
./scripts/validate.sh
.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: commit
commit: ## Commit changes to git, push them to the remote and inform flux about it
git commit -v
git push
make flux-update-git
merge:
git fetch
git merge --no-ff origin/$(BRANCH) --no-edit
git push
git push origin --delete $(BRANCH)
.PHONY: help
help: ## Show this help
@egrep -h '\s##\s' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-20s\033[0m %s\n", $$1, $$2}'
IMG_DIRS := $(wildcard images/*)
.PHONY: $(IMG_DIRS)
$(IMG_DIRS):
$(MAKE) -C $@ snapshot REGISTRY_HOST=$(REGISTRY_HOST) USERNAME=$(USERNAME)
.PHONY: images
images: $(IMG_DIRS) ## Build all local images
.PHONY: ssh-init-hosts
ssh-init-hosts:
ssh -o StrictHostKeyChecking=no cp01.$(TF_VAR_dns_domain) echo "Hello World"
ssh -o StrictHostKeyChecking=no cp02.$(TF_VAR_dns_domain) echo "Hello World"
ssh -o StrictHostKeyChecking=no cp03.$(TF_VAR_dns_domain) echo "Hello World"
.PHONY: kubeadm-init
kubeadm-init:
ssh cp01.$(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 cp01.$(TF_VAR_dns_domain) systemctl enable kubelet.service
.PHONY: kubeadm-copy-config
kubeadm-copy-config: ## Copy Kubernetes admin config from cp01 to the local machine
scp cp01.$(TF_VAR_dns_domain):/etc/kubernetes/admin.conf /root/.kube/config
.PHONY: kubeadm-join-masters
kubeadm-join-masters:
ssh cp02.$(TF_VAR_dns_domain) $$(ssh cp01.$(TF_VAR_dns_domain) kubeadm token create --ttl 1h --print-join-command --certificate-key "$$(ssh cp01.$(TF_VAR_dns_domain) kubeadm init phase upload-certs --upload-certs | tail -1)" | tail -1)
ssh cp02.$(TF_VAR_dns_domain) systemctl enable kubelet.service
ssh cp03.$(TF_VAR_dns_domain) $$(ssh cp01.$(TF_VAR_dns_domain) kubeadm token create --ttl 1h --print-join-command --certificate-key "$$(ssh cp01.$(TF_VAR_dns_domain) kubeadm init phase upload-certs --upload-certs | tail -1)" | tail -1)
ssh cp03.$(TF_VAR_dns_domain) systemctl enable kubelet.service
.PHONY: kubectl-remove-first-master-taints
kubectl-remove-first-master-taints:
kubectl taint nodes cp01.$(TF_VAR_dns_domain) node-role.kubernetes.io/master-
.PHONY: kubectl-remove-all-master-taints
kubectl-remove-all-master-taints:
kubectl taint nodes --all node-role.kubernetes.io/master- || true
.PHONY: kubectl-delete-wrong-subnet
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
.PHONY: kubectl-prepare-hcloud-csi
kubectl-prepare-hcloud-csi:
kubectl -n kube-system create secret generic --from-literal token=$CLOUD_TOKEN --dry-run=client -o yaml hcloud-csi | kubectl apply -f -
.PHONY: kubernetes-install
kubernetes-install: ssh-init-hosts kubeadm-init kubeadm-copy-config kubectl-remove-first-master-taints kubectl-prepare-hcloud-csi 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