From cffaaea26dc809717f8e92de6cdde608198aa561 Mon Sep 17 00:00:00 2001 From: Falkan Date: Thu, 19 Mar 2026 01:33:47 -0400 Subject: [PATCH] =?UTF-8?q?fix:=20use=20OCI=20archive=20workflow=20instead?= =?UTF-8?q?=20of=20registry=20=E2=80=94=20scp=20+=20ctr=20import=20on=20ea?= =?UTF-8?q?ch=20node?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- build-push.sh | 23 +++++++++----- k8s/deployment.yaml | 4 +-- k8s/registry.yaml | 76 --------------------------------------------- 3 files changed, 18 insertions(+), 85 deletions(-) delete mode 100644 k8s/registry.yaml diff --git a/build-push.sh b/build-push.sh index 21a7e4c..cf976e4 100755 --- a/build-push.sh +++ b/build-push.sh @@ -1,13 +1,14 @@ #!/usr/bin/env bash -# build-push.sh — build and push humor-units image to the in-cluster registry +# build-push.sh — build humor-units image and import it into containerd on each node # Usage: ./build-push.sh [tag] -# Requires: buildah, kubectl +# Requires: buildah, ssh access to nodes, ctr on nodes set -euo pipefail TAG="${1:-latest}" -# Use a node IP:NodePort — resolvable from both dev machine and cluster nodes -REGISTRY="${REGISTRY:-:30500}" -IMAGE="$REGISTRY/humor-units:$TAG" +IMAGE="humor-units:$TAG" +ARCHIVE="/tmp/humor-units.tar" +# Space-separated list of node SSH targets +NODES="${NODES:-node1 node2}" echo "==> Building $IMAGE..." buildah build \ @@ -15,8 +16,16 @@ buildah build \ --tag "$IMAGE" \ "$(dirname "$0")" -echo "==> Pushing $IMAGE..." -buildah push --tls-verify=false "$IMAGE" +echo "==> Exporting to OCI archive $ARCHIVE..." +buildah push "$IMAGE" "oci-archive:${ARCHIVE}:${IMAGE}" + +for NODE in $NODES; do + echo "==> Copying to $NODE..." + scp "$ARCHIVE" "$NODE:/tmp/humor-units.tar" + + echo "==> Importing on $NODE..." + ssh "$NODE" "ctr -n k8s.io images import /tmp/humor-units.tar && rm /tmp/humor-units.tar" +done echo "==> Restarting humor-units deployment..." kubectl rollout restart deployment/humor-units -n default diff --git a/k8s/deployment.yaml b/k8s/deployment.yaml index ac3487a..24e61b1 100644 --- a/k8s/deployment.yaml +++ b/k8s/deployment.yaml @@ -16,8 +16,8 @@ spec: spec: containers: - name: humor-units - image: :30500/humor-units:latest - imagePullPolicy: Always + image: humor-units:latest + imagePullPolicy: Never ports: - containerPort: 3000 env: diff --git a/k8s/registry.yaml b/k8s/registry.yaml deleted file mode 100644 index 587e7ac..0000000 --- a/k8s/registry.yaml +++ /dev/null @@ -1,76 +0,0 @@ -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 - nodePort: 30500 - type: NodePort ---- -apiVersion: v1 -kind: Namespace -metadata: - name: registry