From fae0826400c5eda9795075d985164c8b46a02a47 Mon Sep 17 00:00:00 2001 From: Danijel Simeunovic Date: Mon, 16 Mar 2026 11:54:32 +0100 Subject: [PATCH] ssh access --- docs/OPERATIONS-RUNBOOK.md | 341 +++++++++++++++++++++++++++++++++++++ 1 file changed, 341 insertions(+) diff --git a/docs/OPERATIONS-RUNBOOK.md b/docs/OPERATIONS-RUNBOOK.md index 6b931af..0425b0b 100644 --- a/docs/OPERATIONS-RUNBOOK.md +++ b/docs/OPERATIONS-RUNBOOK.md @@ -3,6 +3,8 @@ ## Table of Contents - [Overview](#overview) - [Cluster Bootstrap](#cluster-bootstrap) + - [Initial Cluster Setup](#initial-cluster-setup) + - [ArgoCD Repository Access Setup](#argocd-repository-access-setup) - [Day-to-Day Operations](#day-to-day-operations) - [Application Management](#application-management) - [Secret Management](#secret-management) @@ -103,6 +105,345 @@ kubectl get applications -n argocd 5. **Test Slack notifications** by triggering a sync +### ArgoCD Repository Access Setup + +ArgoCD needs SSH access to private Git repositories to pull manifests and Helm values. This section covers setting up deploy keys for GitHub repositories. + +#### Why Deploy Keys? + +- **Read-only access**: Deploy keys provide secure, read-only access to repositories +- **No user credentials**: No need to share personal SSH keys or tokens +- **Repository-specific**: Each repository gets its own key for better security +- **Revocable**: Easy to revoke access without affecting other repositories + +#### Prerequisites + +- kubectl access to the cluster +- Write access to the GitHub repository +- ArgoCD installed and running + +#### Setup Procedure + +**Step 1: Generate SSH Key Pair** + +Generate a dedicated SSH key for ArgoCD without a passphrase (required for automated access): + +```bash +# Generate ED25519 key (recommended - smaller and more secure) +ssh-keygen -t ed25519 -C "argocd-deploy-key-sturdy-adventure" -f argocd-deploy-key -N "" + +# Or RSA key if ED25519 is not supported +ssh-keygen -t rsa -b 4096 -C "argocd-deploy-key-sturdy-adventure" -f argocd-deploy-key -N "" +``` + +This creates two files: +- `argocd-deploy-key` - Private key (keep secret) +- `argocd-deploy-key.pub` - Public key (add to GitHub) + +**Step 2: Add Public Key to GitHub** + +1. Copy the public key: + ```bash + cat argocd-deploy-key.pub + ``` + +2. Go to GitHub repository settings: + - Navigate to: `https://github.com/fortedigital/sturdy-adventure/settings/keys` + - Or: Repository → Settings → Deploy keys + +3. Click **"Add deploy key"** + - Title: `ArgoCD Production Cluster` + - Key: Paste the public key content + - ☐ Allow write access (leave unchecked - read-only is sufficient) + - Click **"Add key"** + +4. Repeat for the `helm-values` repository if it's private: + ```bash + # Generate separate key for helm-values repo + ssh-keygen -t ed25519 -C "argocd-deploy-key-helm-values" -f argocd-helm-values-key -N "" + + # Add to: https://github.com/fortedigital/helm-values/settings/keys + ``` + +**Step 3: Create Kubernetes Secret** + +Add the private key to ArgoCD as a repository secret: + +```bash +# Create secret for sturdy-adventure repository +kubectl create secret generic repo-sturdy-adventure \ + --from-file=sshPrivateKey=argocd-deploy-key \ + --namespace=argocd \ + --dry-run=client -o yaml | kubectl apply -f - + +# Label it for ArgoCD to recognize +kubectl label secret repo-sturdy-adventure \ + -n argocd \ + argocd.argoproj.io/secret-type=repository + +# Add repository annotations +kubectl annotate secret repo-sturdy-adventure \ + -n argocd \ + managed-by=argocd.argoproj.io +``` + +Alternatively, create a complete repository secret with all metadata: + +```bash +kubectl apply -f - < /tmp/test-repo-access.yaml <> ~/.ssh/known_hosts + +# Or disable strict host key checking (less secure) +kubectl patch secret repo-sturdy-adventure -n argocd \ + --type merge \ + -p '{"stringData":{"insecure":"true"}}' +``` + +**Issue: Repository shows as "Unknown" status** + +```bash +# Check repository server logs +kubectl logs -n argocd deployment/argocd-repo-server + +# Refresh repository connection +kubectl delete secret repo-sturdy-adventure -n argocd +# Recreate secret (see Step 3 above) + +# Restart ArgoCD components +kubectl rollout restart deployment argocd-repo-server -n argocd +kubectl rollout restart deployment argocd-application-controller -n argocd +``` + +#### Multiple Repository Setup + +For the three-repository pattern (sturdy-adventure, forte-helm, helm-values): + +```bash +# 1. sturdy-adventure (main config repo) +ssh-keygen -t ed25519 -C "argocd-sturdy-adventure" -f key-sturdy -N "" +# Add key-sturdy.pub to: https://github.com/fortedigital/sturdy-adventure/settings/keys + +# 2. helm-values (private values repo) +ssh-keygen -t ed25519 -C "argocd-helm-values" -f key-helm-values -N "" +# Add key-helm-values.pub to: https://github.com/fortedigital/helm-values/settings/keys + +# 3. forte-helm is public - no key needed (use HTTPS) + +# Create secrets +kubectl create secret generic repo-sturdy-adventure \ + --from-file=sshPrivateKey=key-sturdy \ + --namespace=argocd --dry-run=client -o yaml | \ + kubectl label --local -f - argocd.argoproj.io/secret-type=repository --dry-run=client -o yaml | \ + kubectl apply -f - + +kubectl create secret generic repo-helm-values \ + --from-file=sshPrivateKey=key-helm-values \ + --namespace=argocd --dry-run=client -o yaml | \ + kubectl label --local -f - argocd.argoproj.io/secret-type=repository --dry-run=client -o yaml | \ + kubectl apply -f - + +# Clean up keys +shred -u key-sturdy key-helm-values +``` + +#### Converting HTTPS to SSH + +If you're currently using HTTPS and want to switch to SSH: + +```bash +# 1. Generate and add deploy key (see steps above) + +# 2. Update all Application manifests +# Change from: +# repoURL: https://github.com/fortedigital/sturdy-adventure.git +# To: +# repoURL: git@github.com:fortedigital/sturdy-adventure.git + +# 3. Update and commit +find . -name "*.yaml" -type f -exec sed -i 's|https://github.com/fortedigital/|git@github.com:fortedigital/|g' {} + + +git add . +git commit -m "Switch from HTTPS to SSH for repository access" +git push + +# 4. ArgoCD will automatically re-sync with new SSH URLs +``` + --- ## Day-to-Day Operations