fab-city-software-kit/Makefile

93 lines
3 KiB
Makefile

##@ General
# The help target prints out all targets with their descriptions organized
# beneath their categories. The categories are represented by '##@' and the
# target descriptions by '##'. The awk commands is responsible for reading the
# entire set of makefiles included in this invocation, looking for lines of the
# file as xyz: ## something, and then pretty-format the target and help. Then,
# if there's a line with ##@ something, that gets pretty-printed as a category.
# More info on the usage of ANSI control characters for terminal formatting:
# https://en.wikipedia.org/wiki/ANSI_escape_code#SGR_parameters
# More info on the awk command:
# http://linuxcommand.org/lc3_adv_awk.php
help: ## Display this help.
@awk 'BEGIN {FS = ":.*##"; printf "\nUsage:\n make \033[36m<target>\033[0m\n"} /^[a-zA-Z_0-9-]+:.*?##/ { printf " \033[36m%-15s\033[0m %s\n", $$1, $$2 } /^##@/ { printf "\n\033[1m%s\033[0m\n", substr($$0, 5) } ' $(MAKEFILE_LIST)
##@ Setup
up: ## Create a local K3D development cluster.
@k3d cluster create interfacer-swkit --config k3s-dev.yaml
down: ## Delete the local K3D development cluster
@k3d cluster delete interfacer-swkit
##@ Lint
lint: yaml-lint markdown-lint ## Lint all input files.
yaml-lint: ## Lint all YAML files.
@yamllint -f auto .
markdown-lint: ## Lint all Markdown files.
@mdl .
manifest-lint: ## Lint the Kubenetes manifest.
@kubectl kustomize overlays/dev --enable-helm | kubeconform -ignore-missing-schemas -strict
##@ Build
doc: ## Build the documentation using mkdocs.
mkdocs build
manifest: ## Build Kubernetes manifest using Kustomize and Helm.
@kubectl kustomize overlays/dev --enable-helm
deploy: deploy-dev ## Apply the manifest to the local Kubernetes development cluster.
deploy-dev: ## Apply the manifest to the local Kubernetes development cluster.
@kubectl kustomize overlays/dev/ --enable-helm | kubectl apply --server-side=true -f -
deploy-prod: ## Apply the manifest to the Kubernetes production cluster.
@kubectl kustomize overlays/prod/ --enable-helm | kubectl apply --server-side=true -f -
remove: ## Remove the namespaces from the Kubernetes cluster.
@kubectl delete namespaces \
cert-manager \
gitea \
interfacer-core \
interfacer-webpresence
clean: down up ## Clean the local Kubernetes development cluster.
##@ Show
get: ## Get specific Kubernetes resources from all namespaces.
@kubectl get --all-namespaces $(filter-out $@, $(MAKECMDGOALS))
get-all: ## Get the state of all Kubernetes resources.
@kubectl get all --all-namespaces
get-ns: ## Get all Kubernetes namespaces.
@kubectl get namespaces
get-api: ## Get all Kubernetes api resources.
@kubectl api-resources
get-crd: ## Get all Kubernetes api resources.
@kubectl get crd
get-node: ## Get all Kubernetes nodes.
@kubectl get nodes -o wide
watch-all: ## Watch the state of all Kubernetes resources.
@watch -n 1 kubectl get all --all-namespaces
##@ Log
events: ## Show all Kubernetes cluster events.
@kubectl get events --watch --all-namespaces
%:
@true