deploy: private package pull via External Secrets; pull over public HTTPS (no k3s restart)
All checks were successful
CI / ci (push) Successful in 1m55s
All checks were successful
CI / ci (push) Successful in 1m55s
- k3s pulls git.7tl-homelab.com/... over valid TLS (no registries.yaml/node config) - CI still pushes internally to 10.66.15.22:3000 (fast, insecure-trusted) - ExternalSecret materializes gitea-registry dockerconfigjson from OpenBao - deployment uses imagePullSecrets: gitea-registry - .env added to .dockerignore
This commit is contained in:
parent
466a01f217
commit
b9f2c72bd4
@ -8,3 +8,5 @@ README.md
|
|||||||
docs
|
docs
|
||||||
k8s
|
k8s
|
||||||
.DS_Store
|
.DS_Store
|
||||||
|
.env
|
||||||
|
.env.*
|
||||||
|
|||||||
@ -27,7 +27,11 @@ on:
|
|||||||
- '**/*.md'
|
- '**/*.md'
|
||||||
|
|
||||||
env:
|
env:
|
||||||
IMAGE: 10.66.15.22:3000/bmr_bluecap/bcs-website
|
# Push over the internal HTTP endpoint (fast, no edge; host dockerd trusts it as insecure).
|
||||||
|
PUSH_IMAGE: 10.66.15.22:3000/bmr_bluecap/bcs-website
|
||||||
|
# k3s pulls over the public HTTPS endpoint (valid TLS -> no registries.yaml / node config / restart).
|
||||||
|
# Same Gitea package as PUSH_IMAGE, just a different access path.
|
||||||
|
DEPLOY_IMAGE: git.7tl-homelab.com/bmr_bluecap/bcs-website
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
ci:
|
ci:
|
||||||
@ -70,7 +74,7 @@ jobs:
|
|||||||
- name: Build & push image to Gitea Packages
|
- name: Build & push image to Gitea Packages
|
||||||
run: |
|
run: |
|
||||||
echo "${{ secrets.CI_TOKEN }}" | docker login 10.66.15.22:3000 -u "${{ github.repository_owner }}" --password-stdin
|
echo "${{ secrets.CI_TOKEN }}" | docker login 10.66.15.22:3000 -u "${{ github.repository_owner }}" --password-stdin
|
||||||
docker build -t "$IMAGE:${{ steps.tag.outputs.sha }}" -t "$IMAGE:latest" .
|
docker build -t "$PUSH_IMAGE:${{ steps.tag.outputs.sha }}" -t "$PUSH_IMAGE:latest" .
|
||||||
# Registry pushes can time out on a slow blob; docker push is resumable, so retry.
|
# Registry pushes can time out on a slow blob; docker push is resumable, so retry.
|
||||||
push_retry() {
|
push_retry() {
|
||||||
for i in 1 2 3 4 5; do
|
for i in 1 2 3 4 5; do
|
||||||
@ -80,14 +84,15 @@ jobs:
|
|||||||
done
|
done
|
||||||
return 1
|
return 1
|
||||||
}
|
}
|
||||||
push_retry "$IMAGE:${{ steps.tag.outputs.sha }}"
|
push_retry "$PUSH_IMAGE:${{ steps.tag.outputs.sha }}"
|
||||||
push_retry "$IMAGE:latest"
|
push_retry "$PUSH_IMAGE:latest"
|
||||||
|
|
||||||
- name: Bump k8s image tag and commit back
|
- name: Bump k8s image tag and commit back
|
||||||
run: |
|
run: |
|
||||||
git config user.name "gitea-actions[bot]"
|
git config user.name "gitea-actions[bot]"
|
||||||
git config user.email "gitea-actions@bmr_bluecap"
|
git config user.email "gitea-actions@bmr_bluecap"
|
||||||
(cd k8s && kustomize edit set image "$IMAGE=$IMAGE:${{ steps.tag.outputs.sha }}")
|
# Deployment references the public HTTPS image (what k3s pulls); bump its tag.
|
||||||
|
(cd k8s && kustomize edit set image "$DEPLOY_IMAGE=$DEPLOY_IMAGE:${{ steps.tag.outputs.sha }}")
|
||||||
git add k8s/kustomization.yaml
|
git add k8s/kustomization.yaml
|
||||||
git diff --cached --quiet && { echo "no image change"; exit 0; }
|
git diff --cached --quiet && { echo "no image change"; exit 0; }
|
||||||
git commit -m "ci: deploy ${{ steps.tag.outputs.sha }} [skip ci]"
|
git commit -m "ci: deploy ${{ steps.tag.outputs.sha }} [skip ci]"
|
||||||
|
|||||||
@ -13,14 +13,15 @@ spec:
|
|||||||
labels:
|
labels:
|
||||||
app: bluecap-website
|
app: bluecap-website
|
||||||
spec:
|
spec:
|
||||||
# If the Gitea package is PRIVATE, create a docker-registry secret (ideally via
|
# Private Gitea package -> pull auth from the External-Secrets-managed dockerconfigjson
|
||||||
# External Secrets) named `gitea-registry` in this namespace and uncomment:
|
# (see k8s/externalsecret-registry.yaml).
|
||||||
# imagePullSecrets:
|
imagePullSecrets:
|
||||||
# - name: gitea-registry
|
- name: gitea-registry
|
||||||
containers:
|
containers:
|
||||||
- name: website
|
- name: website
|
||||||
# Tag is managed by CI via kustomize (see k8s/kustomization.yaml `images`).
|
# Pulled over public HTTPS (valid cert -> no node registry config). Tag managed by CI
|
||||||
image: 10.66.15.22:3000/bmr_bluecap/bcs-website:latest
|
# via kustomize (see k8s/kustomization.yaml `images`).
|
||||||
|
image: git.7tl-homelab.com/bmr_bluecap/bcs-website:latest
|
||||||
imagePullPolicy: IfNotPresent
|
imagePullPolicy: IfNotPresent
|
||||||
ports:
|
ports:
|
||||||
- name: http
|
- name: http
|
||||||
|
|||||||
26
k8s/externalsecret-registry.yaml
Normal file
26
k8s/externalsecret-registry.yaml
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
# Materializes a docker-registry pull secret (gitea-registry) from OpenBao via the existing
|
||||||
|
# ClusterSecretStore, so the private Gitea package can be pulled by k3s without a static secret
|
||||||
|
# in Git. Store a read:package Gitea PAT in OpenBao at `cluster/bluecap-registry` with fields
|
||||||
|
# `username` (e.g. bmr_bluecap) and `password` (the token).
|
||||||
|
apiVersion: external-secrets.io/v1
|
||||||
|
kind: ExternalSecret
|
||||||
|
metadata:
|
||||||
|
name: gitea-registry
|
||||||
|
namespace: bluecap-strategies
|
||||||
|
spec:
|
||||||
|
refreshInterval: 1h
|
||||||
|
secretStoreRef:
|
||||||
|
name: openbao-cluster
|
||||||
|
kind: ClusterSecretStore
|
||||||
|
target:
|
||||||
|
name: gitea-registry
|
||||||
|
template:
|
||||||
|
type: kubernetes.io/dockerconfigjson
|
||||||
|
data:
|
||||||
|
.dockerconfigjson: |
|
||||||
|
{"auths":{"git.7tl-homelab.com":{"username":"{{ .username }}","password":"{{ .password }}","auth":"{{ printf "%s:%s" .username .password | b64enc }}"}}}
|
||||||
|
data:
|
||||||
|
- secretKey: username
|
||||||
|
remoteRef: { key: bluecap-registry, property: username }
|
||||||
|
- secretKey: password
|
||||||
|
remoteRef: { key: bluecap-registry, property: password }
|
||||||
@ -1,14 +1,15 @@
|
|||||||
apiVersion: kustomize.config.k8s.io/v1beta1
|
apiVersion: kustomize.config.k8s.io/v1beta1
|
||||||
kind: Kustomization
|
kind: Kustomization
|
||||||
resources:
|
resources:
|
||||||
- namespace.yaml
|
- namespace.yaml
|
||||||
- configmap.yaml
|
- configmap.yaml
|
||||||
- deployment.yaml
|
- externalsecret-registry.yaml
|
||||||
- service.yaml
|
- deployment.yaml
|
||||||
- ingress.yaml
|
- service.yaml
|
||||||
|
- ingress.yaml
|
||||||
|
|
||||||
# CI updates newTag to the immutable git-sha via `kustomize edit set image` (see .gitea/workflows/ci.yml).
|
# CI updates newTag to the immutable git-sha via `kustomize edit set image` (see .gitea/workflows/ci.yml).
|
||||||
|
# Name is the public HTTPS pull endpoint that k3s uses.
|
||||||
images:
|
images:
|
||||||
- name: 10.66.15.22:3000/bmr_bluecap/bcs-website
|
- name: git.7tl-homelab.com/bmr_bluecap/bcs-website
|
||||||
newName: 10.66.15.22:3000/bmr_bluecap/bcs-website
|
newTag: latest
|
||||||
newTag: 79f2e8a78b9f
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user