chore: in-cluster registry manifest, build-push.sh script

This commit is contained in:
Falkan
2026-03-19 01:00:54 -04:00
parent e6a023e14a
commit 177b15920f
3 changed files with 109 additions and 1 deletions

30
build-push.sh Executable file
View File

@@ -0,0 +1,30 @@
#!/usr/bin/env bash
# build-push.sh — build and push humor-units image to the in-cluster registry
# Usage: ./build-push.sh [tag]
# Requires: buildah, kubectl
set -euo pipefail
TAG="${1:-latest}"
REGISTRY="localhost:5000" # via kubectl port-forward
IMAGE="$REGISTRY/humor-units:$TAG"
echo "==> Port-forwarding registry..."
kubectl port-forward -n registry svc/registry 5000:5000 &
PF_PID=$!
trap "kill $PF_PID 2>/dev/null" EXIT
sleep 2
echo "==> Building $IMAGE..."
buildah build \
--format docker \
--tag "$IMAGE" \
"$(dirname "$0")"
echo "==> Pushing $IMAGE..."
buildah push --tls-verify=false "$IMAGE"
echo "==> Restarting humor-units deployment..."
kubectl rollout restart deployment/humor-units -n default
echo "==> Done. Waiting for rollout..."
kubectl rollout status deployment/humor-units -n default

View File

@@ -16,7 +16,8 @@ spec:
spec:
containers:
- name: humor-units
image: ghcr.io/YOUR_ORG/humor-units:latest # replace with your registry
image: registry.registry.svc.cluster.local:5000/humor-units:latest
imagePullPolicy: Always
ports:
- containerPort: 3000
env:

77
k8s/registry.yaml Normal file
View File

@@ -0,0 +1,77 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: registry
namespace: registry
labels:
app: registry
spec:
replicas: 1
selector:
matchLabels:
app: registry
template:
metadata:
labels:
app: registry
spec:
containers:
- name: registry
image: registry:2
ports:
- containerPort: 5000
env:
- name: REGISTRY_STORAGE_FILESYSTEM_ROOTDIRECTORY
value: /var/lib/registry
volumeMounts:
- name: data
mountPath: /var/lib/registry
resources:
requests:
cpu: 50m
memory: 64Mi
limits:
cpu: 200m
memory: 128Mi
readinessProbe:
httpGet:
path: /v2/
port: 5000
initialDelaySeconds: 5
periodSeconds: 10
volumes:
- name: data
persistentVolumeClaim:
claimName: registry-data
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: registry-data
namespace: registry
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 10Gi
---
apiVersion: v1
kind: Service
metadata:
name: registry
namespace: registry
spec:
selector:
app: registry
ports:
- port: 5000
targetPort: 5000
# ClusterIP is fine if you port-forward from dev machine to push.
# Change to NodePort or add an Ingress if you want external push access.
type: ClusterIP
---
apiVersion: v1
kind: Namespace
metadata:
name: registry