Files
foundation/Makefile
Morten Olsen 3c1c9d7dc0 init
2025-11-25 18:14:03 +01:00

78 lines
2.9 KiB
Makefile

.PHONY: help create deploy check validate lint format install-tools clean ci
# Default target
help:
@echo "Available targets:"
@echo " make create - Create K3s cluster and install Argo CD"
@echo " make deploy - Deploy all foundation services"
@echo " make check - Run all validation checks (lint + validate)"
@echo " make validate - Validate Kubernetes manifests"
@echo " make lint - Lint YAML files"
@echo " make format - Format YAML files (where possible)"
@echo " make install-tools - Install required tools (kubeconform, yamllint)"
@echo " make ci - Run CI validation (non-interactive)"
@echo " make clean - Clean temporary files"
# Cluster setup
create:
colima delete -f -d
colima start --kubernetes -m 8 --k3s-arg="--disable helm-controller,traefik"
kubectl create namespace argocd
kubectl apply -n argocd -f https://raw.githubusercontent.com/argoproj/argo-cd/stable/manifests/install.yaml
# Deployment
deploy:
kubectl apply -k apps/
# Validation and linting
check: lint validate
@echo "✓ All checks passed"
validate:
@if [ -f scripts/validate.sh ]; then \
./scripts/validate.sh; \
else \
echo "Validating Kubernetes manifests..."; \
which kubeconform > /dev/null || (echo "kubeconform not found. Run 'make install-tools'" && exit 1); \
for file in apps/*.yaml storage/*.yaml; do \
if [ -f "$$file" ] && [[ ! "$$file" == *"kustomization.yaml" ]]; then \
kubeconform -strict -skip Certificate,Issuer,CertificateRequest,ClusterIssuer "$$file" || exit 1; \
fi; \
done; \
echo "Validating Kustomize configurations..."; \
kustomize build apps/ > /dev/null; \
kustomize build storage/ > /dev/null; \
echo "✓ Validation passed"; \
fi
lint:
@echo "Linting YAML files..."
@which yamllint > /dev/null || (echo "yamllint not found. Run 'make install-tools'" && exit 1)
@yamllint -c .yamllint apps/ storage/
@echo "✓ Linting passed"
format:
@echo "Formatting YAML files..."
@which yq > /dev/null || (echo "yq not found. Install with: brew install yq" && exit 1)
@find apps storage -name "*.yaml" -type f -exec yq eval -i . {} \;
@echo "✓ Formatting complete"
# Tool installation
install-tools:
@echo "Installing kubeconform..."
@which kubeconform > /dev/null || (brew install kubeconform || echo "Failed to install kubeconform. Install manually: https://github.com/yannh/kubeconform")
@echo "Installing yamllint..."
@which yamllint > /dev/null || (pip3 install yamllint || echo "Failed to install yamllint. Install manually: pip install yamllint")
@echo "Installing kustomize..."
@which kustomize > /dev/null || (brew install kustomize || echo "Failed to install kustomize. Install manually: https://kustomize.io")
@echo "✓ Tools installation complete"
# CI target (non-interactive, exits on error)
ci: check
@echo "✓ CI validation passed"
# Cleanup
clean:
@find . -type f -name "*.tmp" -delete
@echo "✓ Cleanup complete"