Refactor Makefiles #83

This commit is contained in:
Marian Koreniuk
2024-04-17 22:24:59 +03:00
parent 8a2ad90882
commit fcebfdff24
29 changed files with 122 additions and 257 deletions

41
hack/package-system.mk Normal file
View File

@@ -0,0 +1,41 @@
.DEFAULT_GOAL=help
.PHONY=help show diff apply delete update image
help: ## Show this help.
@awk 'BEGIN {FS = ":.*?## "} /^[a-zA-Z_-]+:.*?## / {sub("\\\\n",sprintf("\n%22c"," "), $$2);printf "\033[36m%-20s\033[0m %s\n", $$1, $$2}' $(MAKEFILE_LIST)
show: ## Show output of rendered templates
case "$(NAME)" in
cilium|kubeovn)
kubectl get hr -n $(NAMESPACE) $(NAME) -o jsonpath='{.spec.values}' | helm template --dry-run=server -n $(NAMESPACE) $(NAME) . -f -
;;
*)
helm template --dry-run=server -n $(NAMESPACE) $(NAME) .
;;
esac
apply: suspend ## Apply Helm release to a Kubernetes cluster
case "$(NAME)" in
cilium|kubeovn)
kubectl get hr -n $(NAMESPACE) $(NAME) -o jsonpath='{.spec.values}' | helm upgrade -i -n $(NAMESPACE) $(NAME) . -f -
;;
*)
helm upgrade -i -n $(NAMESPACE) $(NAME) .
;;
esac
diff: ## Diff Helm release against objects in a Kubernetes cluster
case "$(NAME)" in
cilium|kubeovn)
kubectl get hr -n $(NAMESPACE) $(NAME) -o jsonpath='{.spec.values}' | helm diff upgrade --allow-unreleased --normalize-manifests -n $(NAMESPACE) $(NAME) . -f -
;;
*)
helm diff upgrade --allow-unreleased --normalize-manifests -n $(NAMESPACE) $(NAME) .
;;
esac
suspend: ## Suspend reconciliation for an existing Helm release
flux suspend hr -n $(NAMESPACE) $(NAME)
resume: ## Resume reconciliation for an existing Helm release
flux resume hr -n $(NAMESPACE) $(NAME)

View File

@@ -1,5 +1,5 @@
NAMESPACE=cozy-fluxcd
NAME=fluxcd
NAMESPACE=cozy-$(NAME)
API_VERSIONS_FLAGS=$(addprefix -a ,$(shell kubectl api-versions))

View File

@@ -1,5 +1,5 @@
NAMESPACE=cozy-system
NAME=installer
NAMESPACE=cozy-system
PUSH := 1
LOAD := 0
REGISTRY := ghcr.io/aenix-io/cozystack

View File

@@ -1,5 +1,5 @@
NAMESPACE=cozy-system
NAME=platform
NAMESPACE=cozy-system
API_VERSIONS_FLAGS=$(addprefix -a ,$(shell kubectl api-versions))

View File

@@ -1,14 +1,7 @@
NAME=capi-operator
NAMESPACE=cozy-cluster-api
show:
helm template --dry-run=server -n $(NAMESPACE) $(NAME) .
apply:
helm upgrade -i -n $(NAMESPACE) $(NAME) .
diff:
helm diff upgrade --allow-unreleased --normalize-manifests -n $(NAMESPACE) $(NAME) .
include ../../hack/package-system.mk
update:
rm -rf charts

View File

@@ -1,11 +1,4 @@
NAME=capi-providers
NAMESPACE=cozy-cluster-api
show:
helm template --dry-run=server -n $(NAMESPACE) $(NAME) .
apply:
helm upgrade -i -n $(NAMESPACE) $(NAME) .
diff:
helm diff upgrade --allow-unreleased --normalize-manifests -n $(NAMESPACE) $(NAME) .
include ../../hack/package-system.mk

View File

@@ -1,11 +1,4 @@
NAME=cert-manager-issuers
NAMESPACE=cozy-cert-manager
show:
helm template --dry-run=server -n $(NAMESPACE) $(NAME) .
apply:
helm upgrade -i -n $(NAMESPACE) $(NAME) .
diff:
helm diff upgrade --allow-unreleased --normalize-manifests -n $(NAMESPACE) $(NAME) .
include ../../hack/package-system.mk

View File

@@ -1,17 +1,10 @@
NAME=cert-manager
NAMESPACE=cozy-cert-manager
NAMESPACE=cozy-$(NAME)
show:
helm template --dry-run=server -n $(NAMESPACE) $(NAME) .
apply:
helm upgrade -i -n $(NAMESPACE) $(NAME) .
diff:
helm diff upgrade --allow-unreleased --normalize-manifests -n $(NAMESPACE) $(NAME) .
include ../../hack/package-system.mk
update:
rm -rf charts
helm repo add jetstack https://charts.jetstack.io
helm repo update jetstack
helm pull jetstack/cert-manager --untar --untardir charts
helm pull jetstack/$(NAME) --untar --untardir charts

View File

@@ -1,19 +1,12 @@
NAMESPACE=cozy-cilium
NAME=cilium
NAMESPACE=cozy-$(NAME)
show:
kubectl get hr -n cozy-cilium cilium -o jsonpath='{.spec.values}' | helm template --dry-run=server -n $(NAMESPACE) $(NAME) . -f -
apply:
kubectl get hr -n cozy-cilium cilium -o jsonpath='{.spec.values}' | helm upgrade -i -n $(NAMESPACE) $(NAME) . -f -
diff:
kubectl get hr -n cozy-cilium cilium -o jsonpath='{.spec.values}' | helm diff upgrade --allow-unreleased --normalize-manifests -n $(NAMESPACE) $(NAME) . -f -
include ../../hack/package-system.mk
update:
rm -rf charts
helm repo add cilium https://helm.cilium.io/
helm repo update cilium
helm pull cilium/cilium --untar --untardir charts --version 1.14
sed -i -e '/Used in iptables/d' -e '/SYS_MODULE/d' charts/cilium/values.yaml
helm repo add $(NAME) https://helm.cilium.io/
helm repo update $(NAME)
helm pull $(NAME)/$(NAME) --untar --untardir charts --version 1.14
sed -i -e '/Used in iptables/d' -e '/SYS_MODULE/d' charts/$(NAME)/values.yaml
patch -p3 --no-backup-if-mismatch < patches/fix-cgroups.patch

View File

@@ -1,14 +1,7 @@
NAME=clickhouse-operator
NAMESPACE=cozy-clickhouse-operator
show:
helm template --dry-run=server -n $(NAMESPACE) $(NAME) .
apply:
helm upgrade -i -n $(NAMESPACE) $(NAME) .
diff:
helm diff upgrade --allow-unreleased --normalize-manifests -n $(NAMESPACE) $(NAME) .
include ../../hack/package-system.mk
update:
rm -rf charts

View File

@@ -1,21 +1,14 @@
NAME=dashboard
NAMESPACE=cozy-dashboard
NAMESPACE=cozy-$(NAME)
PUSH := 1
LOAD := 0
REPOSITORY := ghcr.io/aenix-io/cozystack
TAG := v0.2.0
show:
helm template --dry-run=server -n $(NAMESPACE) $(NAME) .
apply:
helm upgrade -i -n $(NAMESPACE) $(NAME) .
diff:
helm diff upgrade --allow-unreleased --normalize-manifests -n $(NAMESPACE) $(NAME) .
include ../../hack/package-system.mk
update: update-chart update-dockerfiles
image: image-dashboard image-kubeapps-apis
image: image-$(NAME) image-kubeapps-apis
update-chart:
rm -rf charts
@@ -29,21 +22,21 @@ update-dockerfiles:
tag=$$(git ls-remote --tags --sort="v:refname" https://github.com/vmware-tanzu/kubeapps | awk -F'[/^]' 'END{print $$3}') && \
wget https://github.com/vmware-tanzu/kubeapps/raw/$${tag}/cmd/kubeapps-apis/Dockerfile -O images/kubeapps-apis/Dockerfile && \
patch images/kubeapps-apis/Dockerfile < images/kubeapps-apis/dockerfile.diff && \
node_image=$$(wget -O- https://github.com/vmware-tanzu/kubeapps/raw/main/dashboard/Dockerfile | awk '/FROM bitnami\/node/ {print $$2}') && \
sed -i "s|FROM .* AS build|FROM $${node_image} AS build|" images/dashboard/Dockerfile && \
node_image=$$(wget -O- https://github.com/vmware-tanzu/kubeapps/raw/main/$(NAME)/Dockerfile | awk '/FROM bitnami\/node/ {print $$2}') && \
sed -i "s|FROM .* AS build|FROM $${node_image} AS build|" images/$(NAME)/Dockerfile && \
version=$$(echo "$$tag" | sed 's/^v//') && \
sed -i "s/ARG VERSION=.*/ARG VERSION=$${version}/" images/dashboard/Dockerfile
sed -i "s/ARG VERSION=.*/ARG VERSION=$${version}/" images/$(NAME)/Dockerfile
image-dashboard:
docker buildx build images/dashboard \
docker buildx build images/$(NAME) \
--provenance false \
--tag $(REPOSITORY)/dashboard:$(TAG) \
--cache-from type=registry,ref=$(REPOSITORY)/dashboard:$(TAG) \
--tag $(REPOSITORY)/$(NAME):$(TAG) \
--cache-from type=registry,ref=$(REPOSITORY)/$(NAME):$(TAG) \
--cache-to type=inline \
--metadata-file images/dashboard.json \
--metadata-file images/$(NAME).json \
--push=$(PUSH) \
--load=$(LOAD)
echo "$(REPOSITORY)/dashboard:$(TAG)" > images/dashboard.tag
echo "$(REPOSITORY)/$(NAME):$(TAG)" > images/$(NAME).tag
image-kubeapps-apis:
docker buildx build images/kubeapps-apis \

View File

@@ -1,14 +1,7 @@
NAME=grafana-operator
NAMESPACE=cozy-grafana-operator
show:
helm template --dry-run=server -n $(NAMESPACE) $(NAME) .
apply:
helm upgrade -i -n $(NAMESPACE) $(NAME) .
diff:
helm diff upgrade --allow-unreleased --normalize-manifests -n $(NAMESPACE) $(NAME) .
include ../../hack/package-system.mk
update:
rm -rf charts

View File

@@ -1,21 +1,14 @@
NAME=ingress-nginx
NAMESPACE=cozy-ingress-nginx
NAMESPACE=cozy-$(NAME)
show:
helm template --dry-run=server -n $(NAMESPACE) $(NAME) .
apply:
helm upgrade -i -n $(NAMESPACE) $(NAME) .
diff:
helm diff upgrade --allow-unreleased --normalize-manifests -n $(NAMESPACE) $(NAME) .
include ../../hack/package-system.mk
update:
rm -rf charts
helm repo add ingress-nginx https://kubernetes.github.io/ingress-nginx
helm repo update ingress-nginx
helm pull ingress-nginx/ingress-nginx --untar --untardir charts
helm repo add $(NAME) https://kubernetes.github.io/$(NAME)
helm repo update $(NAME)
helm pull $(NAME)/$(NAME) --untar --untardir charts
patch -p 3 < patches/add-metrics2.patch
rm -f charts/ingress-nginx/templates/controller-deployment.yaml.orig
rm -rf charts/ingress-nginx/changelog/
#sed -i '/ type:/a \ allocateLoadBalancerNodePorts: false' charts/ingress-nginx/templates/controller-service.yaml
rm -f charts/$(NAME)/templates/controller-deployment.yaml.orig
rm -rf charts/$(NAME)/changelog/
#sed -i '/ type:/a \ allocateLoadBalancerNodePorts: false' charts/$(NAME)/templates/controller-service.yaml

View File

@@ -1,14 +1,7 @@
NAME=kafka-operator
NAMESPACE=cozy-kafka-operator
NAMESPACE=cozy-$(NAME)
show:
helm template --dry-run=server -n $(NAMESPACE) $(NAME) .
apply:
helm upgrade -i -n $(NAMESPACE) $(NAME) .
diff:
helm diff upgrade --allow-unreleased --normalize-manifests -n $(NAMESPACE) $(NAME) .
include ../../hack/package-system.mk
update:
rm -rf charts

View File

@@ -1,18 +1,10 @@
NAME=kamaji
NAMESPACE=cozy-kamaji
NAMESPACE=cozy-$(NAME)
show:
helm template --dry-run=server -n $(NAMESPACE) $(NAME) .
apply:
flux suspend hr kamaji -n cozy-kamaji || true
helm upgrade -i -n $(NAMESPACE) $(NAME) .
diff:
helm diff upgrade --allow-unreleased --normalize-manifests -n $(NAMESPACE) $(NAME) .
include ../../hack/package-system.mk
update:
rm -rf charts
helm repo add clastix https://clastix.github.io/charts
helm repo update clastix
helm pull clastix/kamaji --untar --untardir charts
helm pull clastix/$(NAME) --untar --untardir charts

View File

@@ -1,14 +1,7 @@
NAMESPACE=cozy-kubeovn
NAME=kubeovn
NAMESPACE=cozy-$(NAME)
show:
kubectl get hr -n $(NAMESPACE) $(NAME) -o jsonpath='{.spec.values}' | helm template --dry-run=server -n $(NAMESPACE) $(NAME) . -f -
apply:
kubectl get hr -n $(NAMESPACE) $(NAME) -o jsonpath='{.spec.values}' | helm upgrade -i -n $(NAMESPACE) $(NAME) . -f -
diff:
kubectl get hr -n $(NAMESPACE) $(NAME) -o jsonpath='{.spec.values}' | helm diff upgrade --allow-unreleased --normalize-manifests -n $(NAMESPACE) $(NAME) . -f -
include ../../hack/package-system.mk
update:
rm -rf charts && mkdir -p charts/kube-ovn

View File

@@ -1,14 +1,7 @@
NAME=kubevirt-cdi-operator
NAMESPACE=cozy-kubevirt-cdi
show:
helm template --dry-run=server -n $(NAMESPACE) $(NAME) .
apply:
helm upgrade -i -n $(NAMESPACE) $(NAME) .
diff:
helm diff upgrade --allow-unreleased --normalize-manifests -n $(NAMESPACE) $(NAME) .
include ../../hack/package-system.mk
update:
rm -rf templates

View File

@@ -1,14 +1,7 @@
NAME=kubevirt-cdi
NAMESPACE=cozy-kubevirt-cdi
NAMESPACE=cozy-$(NAME)
show:
helm template --dry-run=server -n $(NAMESPACE) $(NAME) .
apply:
helm upgrade -i -n $(NAMESPACE) $(NAME) .
diff:
helm diff upgrade --allow-unreleased --normalize-manifests -n $(NAMESPACE) $(NAME) .
include ../../hack/package-system.mk
update:
rm -rf templates

View File

@@ -1,19 +1,12 @@
NAME=kubevirt-operator
NAMESPACE=cozy-kubevirt
show:
helm template --dry-run=server -n $(NAMESPACE) $(NAME) .
apply:
helm upgrade -i -n $(NAMESPACE) $(NAME) .
diff:
helm diff upgrade --allow-unreleased --normalize-manifests -n $(NAMESPACE) $(NAME) .
include ../../hack/package-system.mk
update:
rm -rf templates
mkdir templates
export RELEASE=$$(curl https://storage.googleapis.com/kubevirt-prow/release/kubevirt/kubevirt/stable.txt) && \
wget https://github.com/kubevirt/kubevirt/releases/download/$${RELEASE}/kubevirt-operator.yaml -O templates/kubevirt-operator.yaml && \
sed -i 's/namespace: kubevirt/namespace: cozy-kubevirt/g' templates/kubevirt-operator.yaml
awk -i inplace -v RS="---" '!/kind: Namespace/{printf "%s", $$0 RS}' templates/kubevirt-operator.yaml
wget https://github.com/kubevirt/kubevirt/releases/download/$${RELEASE}/$(NAME).yaml -O templates/$(NAME).yaml && \
sed -i 's/namespace: kubevirt/namespace: $(NAMESPACE)/g' templates/$(NAME).yaml
awk -i inplace -v RS="---" '!/kind: Namespace/{printf "%s", $$0 RS}' templates/$(NAME).yaml

View File

@@ -1,14 +1,7 @@
NAME=kubevirt
NAMESPACE=cozy-kubevirt
NAMESPACE=cozy-$(NAME)
show:
helm template --dry-run=server -n $(NAMESPACE) $(NAME) .
apply:
helm upgrade -i -n $(NAMESPACE) $(NAME) .
diff:
helm diff upgrade --allow-unreleased --normalize-manifests -n $(NAMESPACE) $(NAME) .
include ../../hack/package-system.mk
update:
rm -rf templates

View File

@@ -1,11 +1,4 @@
NAME=linstor
NAMESPACE=cozy-linstor
NAMESPACE=cozy-$(NAME)
show:
helm template --dry-run=server -n $(NAMESPACE) $(NAME) .
apply:
helm upgrade -i -n $(NAMESPACE) $(NAME) .
diff:
helm diff upgrade --allow-unreleased --normalize-manifests -n $(NAMESPACE) $(NAME) .
include ../../hack/package-system.mk

View File

@@ -1,17 +1,10 @@
NAME=mariadb-operator
NAMESPACE=cozy-mariadb-operator
NAMESPACE=cozy-$(NAME)
show:
helm template --dry-run=server -n $(NAMESPACE) $(NAME) .
apply:
helm upgrade -i -n $(NAMESPACE) $(NAME) .
diff:
helm diff upgrade --allow-unreleased --normalize-manifests -n $(NAMESPACE) $(NAME) .
include ../../hack/package-system.mk
update:
rm -rf charts
helm repo add mariadb-operator https://mariadb-operator.github.io/mariadb-operator
helm repo update mariadb-operator
helm pull mariadb-operator/mariadb-operator --untar --untardir charts
helm repo add $(NAME) https://$(NAME).github.io/$(NAME)
helm repo update $(NAME)
helm pull $(NAME)/$(NAME) --untar --untardir charts

View File

@@ -1,17 +1,10 @@
NAME=metallb
NAMESPACE=cozy-metallb
NAMESPACE=cozy-$(NAME)
show:
helm template --dry-run=server -n $(NAMESPACE) $(NAME) .
apply:
helm upgrade -i -n $(NAMESPACE) $(NAME) .
diff:
helm diff upgrade --allow-unreleased --normalize-manifests -n $(NAMESPACE) $(NAME) .
include ../../hack/package-system.mk
update:
rm -rf charts
helm repo add metallb https://metallb.github.io/metallb
helm repo update metallb
helm pull metallb/metallb --untar --untardir charts
helm repo add $(NAME) https://$(NAME).github.io/$(NAME)
helm repo update $(NAME)
helm pull $(NAME)/$(NAME) --untar --untardir charts

View File

@@ -1,14 +1,7 @@
NAME=monitoring
NAMESPACE=cozy-monitoring
NAMESPACE=cozy-$(NAME)
show:
helm template --dry-run=server -n $(NAMESPACE) $(NAME) .
apply:
helm upgrade -i -n $(NAMESPACE) $(NAME) .
diff:
helm diff upgrade --allow-unreleased --normalize-manifests -n $(NAMESPACE) $(NAME) .
include ../../hack/package-system.mk
update:
rm -rf charts

View File

@@ -1,14 +1,7 @@
NAME=postgres-operator
NAMESPACE=cozy-postgres-operator
NAMESPACE=cozy-$(NAME)
show:
helm template --dry-run=server -n $(NAMESPACE) $(NAME) .
apply:
helm upgrade -i -n $(NAMESPACE) $(NAME) .
diff:
helm diff upgrade --allow-unreleased --normalize-manifests -n $(NAMESPACE) $(NAME) .
include ../../hack/package-system.mk
update:
rm -rf charts

View File

@@ -1,17 +1,10 @@
NAME=rabbitmq-operator
NAMESPACE=cozy-rabbitmq-operator
NAMESPACE=cozy-$(NAME)
show:
helm template --dry-run=server -n $(NAMESPACE) $(NAME) .
apply:
helm upgrade -i -n $(NAMESPACE) $(NAME) .
diff:
helm diff upgrade --allow-unreleased --normalize-manifests -n $(NAMESPACE) $(NAME) .
include ../../hack/package-system.mk
update:
rm -rf templates/cluster-operator.yml
wget -O templates/cluster-operator.yml https://github.com/rabbitmq/cluster-operator/releases/latest/download/cluster-operator.yml
yq -i 'del(select(.kind=="Namespace"))' templates/cluster-operator.yml
sed -i 's/rabbitmq-system/cozy-rabbitmq-operator/g' templates/cluster-operator.yml
sed -i 's/rabbitmq-system/$(NAMESPACE)/g' templates/cluster-operator.yml

View File

@@ -1,18 +1,11 @@
NAME=redis-operator
NAMESPACE=cozy-redis-operator
NAMESPACE=cozy-$(NAME)
show:
helm template --dry-run=server -n $(NAMESPACE) $(NAME) .
apply:
helm upgrade -i -n $(NAMESPACE) $(NAME) .
diff:
helm diff upgrade --allow-unreleased --normalize-manifests -n $(NAMESPACE) $(NAME) .
include ../../hack/package-system.mk
update:
rm -rf charts
helm repo add redis-operator https://spotahome.github.io/redis-operator
helm repo update redis-operator
helm pull redis-operator/redis-operator --untar --untardir charts
sed -i '/{{/d' charts/redis-operator/crds/databases.spotahome.com_redisfailovers.yaml
helm repo add $(NAME) https://spotahome.github.io/$(NAME)
helm repo update $(NAME)
helm pull $(NAME)/$(NAME) --untar --untardir charts
sed -i '/{{/d' charts/$(NAME)/crds/databases.spotahome.com_redisfailovers.yaml

View File

@@ -1,14 +1,7 @@
NAME=traffic-manager
NAMESPACE=cozy-telepresence
show:
helm template --dry-run=server -n $(NAMESPACE) $(NAME) .
apply:
helm upgrade -i -n $(NAMESPACE) $(NAME) .
diff:
helm diff upgrade --allow-unreleased --normalize-manifests -n $(NAMESPACE) $(NAME) .
include ../../hack/package-system.mk
update:
rm -rf charts

View File

@@ -1,21 +1,14 @@
NAME=victoria-metrics-operator
NAMESPACE=cozy-victoria-metrics-operator
NAMESPACE=cozy-$(NAME)
show:
helm template --dry-run=server -n $(NAMESPACE) $(NAME) .
apply:
helm upgrade -i -n $(NAMESPACE) $(NAME) .
diff:
helm diff upgrade --allow-unreleased --normalize-manifests -n $(NAMESPACE) $(NAME) .
include ../../hack/package-system.mk
update:
rm -rf charts
# VictoriaMetrics operator
helm repo add vm https://victoriametrics.github.io/helm-charts/
helm repo update vm
helm pull vm/victoria-metrics-operator --untar --untardir charts
helm pull vm/$(NAME) --untar --untardir charts
# Prometheus CRDs
helm repo add prometheus-community https://prometheus-community.github.io/helm-charts
helm repo update prometheus-community