Skip to content

Commit

Permalink
Protected harbor with sealed secrets.
Browse files Browse the repository at this point in the history
  • Loading branch information
pantierra committed Nov 18, 2024
1 parent d1a4b5f commit e205958
Show file tree
Hide file tree
Showing 7 changed files with 64 additions and 2 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).
File renamed without changes.
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
15 changes: 15 additions & 0 deletions argocd/infra/harbor/parts/ss-harbor-auth.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
apiVersion: bitnami.com/v1alpha1
kind: SealedSecret
metadata:
creationTimestamp: null
name: harbor-auth
namespace: infra
spec:
encryptedData:
rootPassword: AgCtSw9RdovqoEc2tYSSG7gKNu9w/kdqp0RnAdTp5I0iPI+/wGIX7ILcKKQ4qXjHUJSEXHasS4YXnVIC6EnQI/xllm8L4bwtStt0hx7K4ufP1UoUpOGoY5YMCz5ytMxdbW1D8jp82N5PCFtp3Th4tl1bQhgK/df29IABJWHAMlYknI0w8VLdJ2B72sw0G1qWomi3WxAEJiaoD79YHGUSu+/r494ir9tjqBq8U2yowt/75Jrl1Bzcsf8aYoGMHPzxpOa8y/L5QziDav5UVTSdDtqLtno6T8WIFfWcJlP2EXOfzxOnF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umPtvnS028HPJoN/r1DtuvZnvhfuqvuI/EvV1vTFNZwxbeoT3fpewE3k4FuzloM=
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 e205958

Please sign in to comment.