Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

♻️ Refactoring the init from sh to make #274

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .mk-lib/common.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
MK_DIR := $(ROOT_DIR)/.mk-lib
-include $(MK_DIR)/variables.mk

.DEFAULT_GOAL := help

help: ##@other Show this help.
@perl -e '$(HELP_FUN)' $(MAKEFILE_LIST)
23 changes: 23 additions & 0 deletions .mk-lib/variables.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#COLORS
GREEN := $(shell tput -Txterm setaf 2)
WHITE := $(shell tput -Txterm setaf 7)
YELLOW := $(shell tput -Txterm setaf 3)
RED := $(shell tput -Txterm setaf 1)
RESET := $(shell tput -Txterm sgr0)

# Add the following 'help' target to your Makefile
# And add help text after each target name starting with '\#\#'
# A category can be added with @category
HELP_FUN = \
%help; \
while(<>) { push @{$$help{$$2 // 'options'}}, [$$1, $$3] if /^([a-zA-Z\-]+)\s*:.*\#\#(?:@([a-zA-Z\-]+))?\s(.*)$$/ }; \
print "usage: make [target]\n\n"; \
for (sort keys %help) { \
print "${WHITE}$$_:${RESET}\n"; \
for (@{$$help{$$_}}) { \
$$sep = " " x (32 - length $$_->[0]); \
print " ${YELLOW}$$_->[0]${RESET}$$sep${GREEN}$$_->[1]${RESET}\n"; \
}; \
print "\n"; }

kget := kubectl get all -A
15 changes: 15 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# REQUIRED SECTION
ROOT_DIR:=$(shell dirname $(realpath $(lastword $(MAKEFILE_LIST))))
include $(ROOT_DIR)/.mk-lib/common.mk

init:
@kubectl apply --server-side --kustomize ./cluster/bootstrap/flux
@export SOPS_AGE_KEY_FILE=~/AGE/sops-key.txt
@sops --decrypt cluster/flux/vars/cluster-secrets.sops.yaml | kubectl apply -f -
@kubectl apply -f cluster/flux/vars/cluster-settings.yaml
@kubectl apply --server-side --kustomize ./cluster/flux/config
nodes:
@kubectl get nodes

kget:
@$(kget)
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,7 @@ And after less than 2 minutes you should end up with working cluster with Cilium
❯ ~ k0sctl kubeconfig > ~/.kube/config

[☸ lab:default]
❯ ~ kubectl get nodes
❯ ~ make nodes
NAME STATUS ROLES AGE VERSION
node1 Ready <none> 2m10s v1.29.1+k0s
node2 Ready <none> 2m16s v1.29.1+k0s
Expand Down Expand Up @@ -473,7 +473,7 @@ All of the above in one shot using init.sh:

```sh
[☸ lab:default] [ main]
❯ ~/homelab ./init.sh
❯ ~/homelab make init
namespace/flux-system serverside-applied
resourcequota/critical-pods serverside-applied
customresourcedefinition.apiextensions.k8s.io/alerts.notification.toolkit.fluxcd.io serverside-applied
Expand Down
5 changes: 0 additions & 5 deletions init.sh

This file was deleted.