From 177b15920fa02d1901f730e22686e996d0d53fc1 Mon Sep 17 00:00:00 2001 From: Falkan Date: Thu, 19 Mar 2026 01:00:54 -0400 Subject: [PATCH] chore: in-cluster registry manifest, build-push.sh script --- build-push.sh | 30 ++++++++++++++++++ k8s/deployment.yaml | 3 +- k8s/registry.yaml | 77 +++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 109 insertions(+), 1 deletion(-) create mode 100755 build-push.sh create mode 100644 k8s/registry.yaml diff --git a/build-push.sh b/build-push.sh new file mode 100755 index 0000000..7d54504 --- /dev/null +++ b/build-push.sh @@ -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 diff --git a/k8s/deployment.yaml b/k8s/deployment.yaml index c384448..ac287f4 100644 --- a/k8s/deployment.yaml +++ b/k8s/deployment.yaml @@ -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: diff --git a/k8s/registry.yaml b/k8s/registry.yaml new file mode 100644 index 0000000..f78fef0 --- /dev/null +++ b/k8s/registry.yaml @@ -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