Skip to content

Commit

Permalink
Protected harbor with sealed secrets. (#44)
Browse files Browse the repository at this point in the history
  • Loading branch information
pantierra authored Dec 2, 2024
1 parent b5e2753 commit d3d5804
Show file tree
Hide file tree
Showing 7 changed files with 70 additions and 3 deletions.
11 changes: 11 additions & 0 deletions argocd/infra/harbor/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Harbor `Application`

The deployment of `harbor` relies mostly upon the harbor helm chart.

## Admin Credentials Sealed Secret

The harbor admin credentials are provided via a `Secret` that is maintained securely in git as a `SealedSecret`.

This `SealedSecret` is defined as an element with the `parts/`, and is generated via the script `ss-harbor-auth.sh` via the `sealed-secrets-controller` that is running in the live cluster.

The `<rootUser>` and `<rootPassword>` are supplied as positional cmdline arguments (with built-in defaults).
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,11 @@ spec:

externalURL: https://harbor.develop.eoepca.org
# initial password for logging in with user "admin"
harborAdminPassword: "changeme"
harborAdminPassword:
valueFrom:
secretKeyRef:
name: harbor-auth
key: rootPassword

chartmuseum:
enabled: false
Expand Down
3 changes: 3 additions & 0 deletions argocd/infra/harbor/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@

resources:
- app-harbor.yaml
3 changes: 3 additions & 0 deletions argocd/infra/harbor/parts/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@

resources:
- ss-harbor-auth.yaml
16 changes: 16 additions & 0 deletions argocd/infra/harbor/parts/ss-harbor-auth.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
---
apiVersion: bitnami.com/v1alpha1
kind: SealedSecret
metadata:
creationTimestamp: null
name: harbor-auth
namespace: infra
spec:
encryptedData:
rootPassword: AgCJVuPPZAv0GlCEw0DI5jqc3qdSdNdxRUjtbAs/SThFCfDgOxB68cMNFUjxkQMV4twZpN9lZyVf30SZvvmQ4Fyw9Wnq/D2PR2GtsE9bkLshcZ8CpEr2CL2qocM7r4u7LQodAEzwS7i6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6x/Y6Y9Y5DJz8PEyz2EwAxmOwNmnQjmJnv1kD35JHftexdahQ0hwD0rGroQ9F3cLCxoZzwGMX+ba4PvzJ+50qYqMdQjB5TqKgFtzq/9uvDikr1XEDzdfGxb+hxFOCrU6fQhd7vdYeNf2ITCZLROyIEujCFS6Z5qdJohfuYMr56Ikh74UKDJkqL2GkjBrXLUQhEZ+KKwylqlrqLQ9hRCckXyhBavg==
template:
metadata:
creationTimestamp: null
name: harbor-auth
namespace: infra
30 changes: 30 additions & 0 deletions argocd/infra/harbor/ss-harbor-auth.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#!/usr/bin/env bash

ORIG_DIR="$(pwd)"
cd "$(dirname "$0")"
BIN_DIR="$(pwd)"

onExit() {
cd "${ORIG_DIR}"
}
trap onExit EXIT

# Optional local .env file for secret values as env vars
source .env 2>/dev/null

SECRET_NAME="harbor-auth"
NAMESPACE="infra"

ROOT_USER="${1:-${ROOT_USER:-admin}}"
ROOT_PASSWORD="${2:-${ROOT_PASSWORD:-changeme}}"

secretYaml() {
kubectl -n "${NAMESPACE}" create secret generic "${SECRET_NAME}" \
--from-literal="rootUser=${ROOT_USER}" \
--from-literal="rootPassword=${ROOT_PASSWORD}" \
--dry-run=client -o yaml
}

# Create Secret and then pipe to kubeseal to create the SealedSecret
secretYaml \
| kubeseal -o yaml --controller-name sealed-secrets --controller-namespace infra > parts/ss-${SECRET_NAME}.yaml
4 changes: 2 additions & 2 deletions argocd/infra/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@

resources:
- app-sealed-secrets.yaml
- minio
- app-harbor.yaml
- cert-manager
- harbor
- minio

0 comments on commit d3d5804

Please sign in to comment.