Skip to content

Instantly share code, notes, and snippets.

@eduardosilva
Created November 1, 2023 17:37
Show Gist options
  • Save eduardosilva/b30f552a9eb5e264b1cb626277d8395c to your computer and use it in GitHub Desktop.
Save eduardosilva/b30f552a9eb5e264b1cb626277d8395c to your computer and use it in GitHub Desktop.
Makefile Kind + ArgoCD + Crossplane
Makefile
# Vars
KIND_CLUSTER_NAME ?= my-kind-cluster
ARGOCD_VERSION ?= v2.0.5
ARGOCD_NAMESPACE ?= argocd
KIND_VERSION ?= v0.20.0
CROSSPLANE_NAMESPACE ?= crossplane-system
CROSSPLANE_VERSION ?= latest
## Install kind if not present
install-kind:
ifeq (, $(shell which kind))
# Linux
if [ "$(shell uname -s)" = "Linux" ]; then \
if [ "$(shell uname -m)" = "x86_64" ]; then \
curl -Lo ./kind https://kind.sigs.k8s.io/dl/$(KIND_VERSION)/kind-linux-amd64; \
elif [ "$(shell uname -m)" = "aarch64" ]; then \
curl -Lo ./kind https://kind.sigs.k8s.io/dl/$(KIND_VERSION)/kind-linux-arm64; \
fi; \
chmod +x ./kind; \
sudo mv ./kind /usr/local/bin/kind; \
fi
# macOS
if [ "$(shell uname -s)" = "Darwin" ]; then \
if [ "$(shell uname -m)" = "x86_64" ]; then \
curl -Lo ./kind https://kind.sigs.k8s.io/dl/$(KIND_VERSION)/kind-darwin-amd64; \
elif [ "$(shell uname -m)" = "arm64" ]; then \
curl -Lo ./kind https://kind.sigs.k8s.io/dl/$(KIND_VERSION)/kind-darwin-arm64; \
fi; \
chmod +x ./kind; \
mv ./kind /usr/local/bin/kind; \
fi
endif
## Start a kind cluster
kind-cluster: kind-cluster
kind create cluster --name $(KIND_CLUSTER_NAME)
## Install ArgoCD
install-argocd: kind-cluster
# Install ArgoCD
kubectl create namespace $(ARGOCD_NAMESPACE)
kubectl apply -n $(ARGOCD_NAMESPACE) -f https://raw.githubusercontent.com/argoproj/argo-cd/$(ARGOCD_VERSION)/manifests/install.yaml
# Wait for ArgoCD server to be ready
kubectl wait --for=condition=available --timeout=300s deployment/argocd-server -n $(ARGOCD_NAMESPACE)
## Install crossplane
install-crossplane: kind-cluster
# Add the Crossplane Helm repository
helm repo add crossplane-stable https://charts.crossplane.io/stable
helm repo update
# Install the Crossplane Helm chart
if [ "$(CROSSPLANE_VERSION)" = "latest" ]; then \
helm install crossplane \
--namespace $(CROSSPLANE_NAMESPACE) \
--create-namespace crossplane-stable/crossplane \
--set provider.packages='{xpkg.upbound.io/upbound/provider-aws:v0.40.0,xpkg.upbound.io/upbound/provider-gcp:v0.36.0,xpkg.upbound.io/crossplane-contrib/provider-openstack:v0.1.7}'; \
else \
helm install crossplane \
--namespace $(CROSSPLANE_NAMESPACE) \
--create-namespace crossplane-stable/crossplane \
--version $(CROSSPLANE_VERSION) \
--set provider.packages='{xpkg.upbound.io/upbound/provider-aws:v0.40.0,xpkg.upbound.io/upbound/provider-gcp:v0.36.0,xpkg.upbound.io/crossplane-contrib/provider-openstack:v0.1.7}'; \
fi
kubectl get providers
## All-in-one target
all: kind-cluster install-argocd install-crossplane
.PHONY: install-kind kind-cluster install-argocd install-crossplane all
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment