Skip to content

Commit

Permalink
Install argocd and kuadrant
Browse files Browse the repository at this point in the history
Signed-off-by: Roi Vazquez <[email protected]>
  • Loading branch information
roivaz committed Oct 24, 2024
1 parent 3832aa2 commit 717fe67
Show file tree
Hide file tree
Showing 26 changed files with 480 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
bin
tmp
kubeconfig
95 changes: 95 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
# Setting SHELL to bash allows bash commands to be executed by recipes.
# Options are set to exit when a recipe line exits non-zero or a piped command fails.
SHELL = /usr/bin/env bash -o pipefail
.SHELLFLAGS = -ec

MKFILE_PATH := $(abspath $(lastword $(MAKEFILE_LIST)))
PROJECT_PATH := $(patsubst %/,%,$(dir $(MKFILE_PATH)))

OS = $(shell uname -s | tr '[:upper:]' '[:lower:]')
ARCH := $(shell uname -m | tr '[:upper:]' '[:lower:]')
# Container Engine to be used for building image and with kind
CONTAINER_ENGINE ?= docker

## Location to install dependencies to
LOCALBIN ?= $(PROJECT_PATH)/bin
$(LOCALBIN):
mkdir -p $(LOCALBIN)

## Temp folder
tmp:
umask 0000 && mkdir -p $@

##@ Kind

## Targets to use kind for deployment https://kind.sigs.k8s.io
export KUBECONFIG = $(PWD)/kubeconfig

KIND_CLUSTER_NAME ?= kuadrant-local
KIND_K8S_VERSION ?= v1.31.0@sha256:53df588e04085fd41ae12de0c3fe4c72f7013bba32a20e7325357a1ac94ba865
.PHONY: kind-create-cluster
kind-create-cluster-%: kind start-cloud-provider-kind ## Create the "kuadrant-local" kind cluster.
KIND_EXPERIMENTAL_PROVIDER=$(CONTAINER_ENGINE) $(KIND) create cluster --wait 5m \
--image kindest/node:$(KIND_K8S_VERSION) \
--name $(KIND_CLUSTER_NAME)-$* \
--config util/kind-cluster.yaml

.PHONY: kind-delete-cluster
kind-delete-cluster-%: kind stop-cloud-provider-kind ## Delete the "kuadrant-local" kind cluster.
- KIND_EXPERIMENTAL_PROVIDER=$(CONTAINER_ENGINE) $(KIND) delete cluster --name $(KIND_CLUSTER_NAME)-$*

kind-apply-argocd: kustomize
$(KUSTOMIZE) build manifests/argocd-install | yq 'select(.kind == "CustomResourceDefinition")' | kubectl apply -f -
sleep 2
kubectl wait --for condition=established --timeout=60s crd --all
$(KUSTOMIZE) build manifests/argocd-install | yq 'select(.kind != "CustomResourceDefinition")' | kubectl apply -f -

##@ Kind cloud provider
CPK_PID_FILE = tmp/cloud-provider-kind.pid

start-cloud-provider-kind: tmp
hack/run-background-process.sh $(KIND_CLOUD_PROVIDER) $(CPK_PID_FILE) tmp/cloud-provider-kind.log
stop-cloud-provider-kind:
- kill -TERM $(shell cat $(CPK_PID_FILE)) && rm $(CPK_PID_FILE)

##@ ArgoCD management targets
ARGOCD_PASSWD = $(shell kubectl -n argocd get secret argocd-initial-admin-secret -o jsonpath="{.data.password}" | base64 -d)
ARGOCD_IP = $(shell kubectl -n argocd get svc argocd-server -o jsonpath="{.status.loadBalancer.ingress[0].ip}")
argocd-url:
@echo -e "\tURL: \thttps://$(ARGOCD_IP)"
@echo -e "\tuser: \tadmin"
@echo -e "\tpass: \t$(ARGOCD_PASSWD)"


##@ Tooling

KUSTOMIZE = $(PROJECT_PATH)/bin/kustomize
KUSTOMIZE_VERSION = [email protected]
.PHONY: kustomize
kustomize: $(KUSTOMIZE) ## Download kustomize locally if necessary.
$(KUSTOMIZE):
test -s $(KUSTOMIZE) || GOBIN=$(LOCALBIN) go install sigs.k8s.io/kustomize/kustomize/$(KUSTOMIZE_VERSION)


KIND = $(PROJECT_PATH)/bin/kind
KIND_VERSION ?= v0.24.0
.PHONY: kind
kind: $(KIND) ## Download kind locally if necessary
$(KIND): $(LOCALBIN)
test -s $(KIND) || GOBIN=$(LOCALBIN) go install sigs.k8s.io/kind@$(KIND_VERSION)

KIND_CLOUD_PROVIDER = $(PROJECT_PATH)/bin/cloud-provider-kind
KIND_CLOUD_PROVIDER_VERSION ?= latest
.PHONY: kind-cloud-provider
kind-cloud-provider: $(KIND_CLOUD_PROVIDER) ## Download kind locally if necessary
$(KIND_CLOUD_PROVIDER): $(LOCALBIN)
test -s $(KIND_CLOUD_PROVIDER) ||GOBIN=$(LOCALBIN) go install sigs.k8s.io/cloud-provider-kind@$(KIND_CLOUD_PROVIDER_VERSION)

##@ Install argocd
ARGOCD ?= $(LOCALBIN)/argocd
ARGOCD_VERSION ?= v2.4.12
ARGOCD_DOWNLOAD_URL ?= https://github.com/argoproj/argo-cd/releases/download/v2.4.13/argocd-$(OS)-$(ARCH)
argocd: $(ARGOCD) ## Download argocd CLI locally if necessary
$(ARGOCD):
curl -sL $(ARGOCD_DOWNLOAD_URL) -o $(ARGOCD)
chmod +x $(ARGOCD)
19 changes: 19 additions & 0 deletions hack/run-background-process.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/bin/bash

BINARY=$1
PID_FILE=$2
LOG_FILE=$3

set -e

if [[ -f ${PID_FILE} ]]; then
PID=$(cat ${PID_FILE})
if [[ $(ps -p ${PID} -o command --no-headers) != "" ]]; then
echo "${BINARY} already running"
exit 0
fi
fi

# start the process
nohup ${BINARY} > ${LOG_FILE} 2>&1 &
echo $! > ${PID_FILE}
19 changes: 19 additions & 0 deletions manifests/argocd-applications/argocd-install-application.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
name: argocd-install
namespace: argocd
spec:
destination:
namespace: argocd
name: in-cluster
project: default
source:
path: manifests/argocd-install
# repoURL: https://github.com/kuadrant/deployment
# targetRevision: HEAD
repoURL: https://github.com/roivaz/kuadrant-deployment
targetRevision: argocd-setup
syncPolicy:
automated:
selfHeal: true
36 changes: 36 additions & 0 deletions manifests/argocd-applications/kuadrant-applicationset.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
apiVersion: argoproj.io/v1alpha1
kind: ApplicationSet
metadata:
name: kuadrant-install
namespace: argocd
spec:
ignoreApplicationDifferences:
- jsonPointers:
- /spec/syncPolicy
- /spec/source/targetRevision
goTemplate: true
generators:
- git:
# repoURL: https://github.com/kuadrant/deployment
# revision: HEAD
repoURL: https://github.com/roivaz/kuadrant-deployment
revision: argocd-setup
files:
- path: manifests/kuadrant/**/argocd-config.yaml
template:
metadata:
name: "{{.path.basename}}"
spec:
project: default
source:
# repoURL: https://github.com/kuadrant/deployment
# targetRevision: main
repoURL: https://github.com/roivaz/kuadrant-deployment
targetRevision: argocd-setup
path: "{{.path.path}}"
destination:
name: in-cluster
syncPolicy:
automated:
prune: true
selfHeal: true
7 changes: 7 additions & 0 deletions manifests/argocd-applications/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
namespace: argocd
resources:
- argocd-install-application.yaml
- operator-lifecycle-manager-application.yaml
- kuadrant-applicationset.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
name: operator-lifecycle-manager
namespace: argocd
spec:
destination:
namespace: olm
name: in-cluster
project: default
source:
path: manifests/operator-lifecycle-manager
# repoURL: https://github.com/kuadrant/deployment
# targetRevision: HEAD
repoURL: https://github.com/roivaz/kuadrant-deployment
targetRevision: argocd-setup
syncPolicy:
automated:
selfHeal: true
syncOptions:
- ServerSideApply=true
22 changes: 22 additions & 0 deletions manifests/argocd-install/app-of-apps-application.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# App of Apps keeps ArgoCD Applications in sync
apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
name: app-of-apps
namespace: argocd
spec:
destination:
namespace: argocd
name: in-cluster
project: default
source:
path: manifests/argocd-applications
# repoURL: https://github.com/kuadrant/deployment
# targetRevision: HEAD
repoURL: https://github.com/roivaz/kuadrant-deployment
targetRevision: argocd-setup
syncPolicy:
automated:
selfHeal: true


15 changes: 15 additions & 0 deletions manifests/argocd-install/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
namespace: argocd
resources:
- namespace.yaml
- https://raw.githubusercontent.com/argoproj/argo-cd/refs/tags/v2.12.6/manifests/install.yaml
- app-of-apps-application.yaml
patches:
- target:
kind: Service
name: argocd-server
patch: |-
- op: add
path: /spec/type
value: LoadBalancer
4 changes: 4 additions & 0 deletions manifests/argocd-install/namespace.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
apiVersion: v1
kind: Namespace
metadata:
name: argocd
1 change: 1 addition & 0 deletions manifests/kuadrant/gateway-api/argocd-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# Use this file to configure some parameters of the generated Application
4 changes: 4 additions & 0 deletions manifests/kuadrant/gateway-api/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
- https://github.com/kubernetes-sigs/gateway-api/releases/download/v1.1.0/standard-install.yaml
1 change: 1 addition & 0 deletions manifests/kuadrant/istio/argocd-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# Use this file to configure some parameters of the generated Application
28 changes: 28 additions & 0 deletions manifests/kuadrant/istio/istio.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
apiVersion: sailoperator.io/v1alpha1
kind: Istio
metadata:
name: default
namespace: istio-system
annotations:
argocd.argoproj.io/sync-options: SkipDryRunOnMissingResource=true
spec:
version: v1.23.0
namespace: istio-system
# Disable autoscaling to reduce dev resources
values:
pilot:
autoscaleEnabled: false

---
# Configure envoy access logging.
apiVersion: telemetry.istio.io/v1alpha1
kind: Telemetry
metadata:
name: mesh-default
namespace: istio-system
annotations:
argocd.argoproj.io/sync-options: SkipDryRunOnMissingResource=true
spec:
accessLogging:
- providers:
- name: envoy
7 changes: 7 additions & 0 deletions manifests/kuadrant/istio/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
- namespace.yaml
- operator.yaml
- istio.yaml
- monitoring.yaml
15 changes: 15 additions & 0 deletions manifests/kuadrant/istio/monitoring.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# TODO: no monitoring stack configured yet
# apiVersion: monitoring.coreos.com/v1
# kind: ServiceMonitor
# metadata:
# name: istiod-monitor
# namespace: istio-system
# spec:
# targetLabels:
# - app
# selector:
# matchLabels:
# istio: pilot
# endpoints:
# - port: http-monitoring
# interval: 30s
6 changes: 6 additions & 0 deletions manifests/kuadrant/istio/namespace.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
apiVersion: v1
kind: Namespace
metadata:
name: istio-system
annotations:
argocd.argoproj.io/sync-wave: "-2"
23 changes: 23 additions & 0 deletions manifests/kuadrant/istio/operator.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
kind: OperatorGroup
apiVersion: operators.coreos.com/v1
metadata:
name: sail
namespace: istio-system
annotations:
argocd.argoproj.io/sync-wave: "-1"
spec: {}

---
apiVersion: operators.coreos.com/v1alpha1
kind: Subscription
metadata:
name: sailoperator
namespace: istio-system
annotations:
argocd.argoproj.io/sync-wave: "-1"
spec:
channel: candidates
installPlanApproval: Automatic
name: sailoperator
source: operatorhubio-catalog
sourceNamespace: olm
1 change: 1 addition & 0 deletions manifests/kuadrant/kuadrant-operator/argocd-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# Use this file to configure some parameters of the generated Application
7 changes: 7 additions & 0 deletions manifests/kuadrant/kuadrant-operator/kuadrant.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
apiVersion: kuadrant.io/v1beta1
kind: Kuadrant
metadata:
name: kuadrant
annotations:
argocd.argoproj.io/sync-options: SkipDryRunOnMissingResource=true
spec: {}
8 changes: 8 additions & 0 deletions manifests/kuadrant/kuadrant-operator/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
namespace: kuadrant-system
resources:
- namespace.yaml
- operator.yaml
- redis.yaml
- kuadrant.yaml
6 changes: 6 additions & 0 deletions manifests/kuadrant/kuadrant-operator/namespace.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
apiVersion: v1
kind: Namespace
metadata:
name: kuadrant-system
annotations:
argocd.argoproj.io/sync-wave: "-2"
Loading

0 comments on commit 717fe67

Please sign in to comment.