commit 38c0b98fa8108f3e006e7405e1f95e16431b9428 Author: Sergio Talens-Oliag Date: Sun Apr 27 14:14:58 2025 +0200 Initial commit. diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..1269488 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +data diff --git a/README.md b/README.md new file mode 100644 index 0000000..4fffa49 --- /dev/null +++ b/README.md @@ -0,0 +1,6 @@ +# ArgoCD Autopilot + +This repository contains scripts and templates to test `argocd-autopilot` on a newly created `k3d` cluster. + +The documentation about how to use it is available on this +[post](https://blogops.mixinet.net/posts/gitops/argocd-autopilot/). diff --git a/bin/argocd-bootstrap.sh b/bin/argocd-bootstrap.sh new file mode 100755 index 0000000..94de14d --- /dev/null +++ b/bin/argocd-bootstrap.sh @@ -0,0 +1,33 @@ +#!/bin/sh + +set -e + +# VARIABLES +# Relative PATH to the workdir from the script directory +WORK_DIR_RELPATH=".." + +# Compute WORKDIR +SCRIPT="$(readlink -f "$0")" +SCRIPT_DIR="$(dirname "$SCRIPT")" +WORK_DIR="$(readlink -f "$SCRIPT_DIR/$WORK_DIR_RELPATH")" + +# Update the PATH to add the arkade bin directory +# Add the arkade binary directory to the path if missing +case ":${PATH}:" in + *:"${HOME}/.arkade/bin":*) ;; + *) export PATH="${PATH}:${HOME}/.arkade/bin" ;; +esac + +# Go to the working directory +cd "$WORK_DIR" || exit 1 + +# Set GIT variables +if [ -z "$GIT_REPO" ]; then + export GIT_REPO="https://forgejo.mixinet.net/blogops/argocd.git" +fi +if [ -z "$GIT_TOKEN" ]; then + GIT_TOKEN="$(pass mixinet.net/argocd@forgejo/repository-write)" + export GIT_TOKEN +fi + +argocd-autopilot repo bootstrap --provider gitea diff --git a/bin/arkade-install.sh b/bin/arkade-install.sh new file mode 100755 index 0000000..ef0f45a --- /dev/null +++ b/bin/arkade-install.sh @@ -0,0 +1,37 @@ +#!/bin/sh + +# TOOLS LIST +ARKADE_APPS="argocd argocd-autopilot k3d kubectl sops tofu" + +# Add the arkade binary directory to the path if missing +case ":${PATH}:" in + *:"${HOME}/.arkade/bin":*) ;; + *) export PATH="${PATH}:${HOME}/.arkade/bin" ;; +esac + +# Install or update arkade +if command -v arkade >/dev/null; then + echo "Trying to update the arkade application" + sudo arkade update +else + echo "Installing the arkade application" + curl -sLS https://get.arkade.dev | sudo sh +fi + +echo "" +echo "Installing tools with arkade" +echo "" +for app in $ARKADE_APPS; do + app_path="$(command -v $app)" || true + if [ "$app_path" ]; then + echo "The application '$app' already available on '$app_path'" + else + arkade get "$app" + fi +done + +cat <"$SECRETS_YAML" + sops encrypt -i "$SECRETS_YAML" +fi + +# Initialize terraform +tofu init + +# Apply the configuration +tofu apply diff --git a/bin/traefik-cert.sh b/bin/traefik-cert.sh new file mode 100755 index 0000000..599c53d --- /dev/null +++ b/bin/traefik-cert.sh @@ -0,0 +1,31 @@ +#!/bin/sh +# Script to update the +secret="localhost-mixinet-net-ingress-cert" +cert="${1:-localhost.mixinet.net.crt}" +key="${2:-localhost.mixinet.net.key}" +if [ -f "$cert" ] && [ -f "$key" ]; then + kubectl -n kube-system create secret tls $secret \ + --key=$key \ + --cert=$cert \ + --dry-run=client --save-config -o yaml | kubectl apply -f - + kubectl apply -f - << EOF +apiVersion: traefik.containo.us/v1alpha1 +kind: TLSStore +metadata: + name: default + namespace: kube-system + +spec: + defaultCertificate: + secretName: $secret +EOF +else + cat <