fix: use OCI archive workflow instead of registry — scp + ctr import on each node
This commit is contained in:
@@ -1,13 +1,14 @@
|
|||||||
#!/usr/bin/env bash
|
#!/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]
|
# Usage: ./build-push.sh [tag]
|
||||||
# Requires: buildah, kubectl
|
# Requires: buildah, ssh access to nodes, ctr on nodes
|
||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
|
|
||||||
TAG="${1:-latest}"
|
TAG="${1:-latest}"
|
||||||
# Use a node IP:NodePort — resolvable from both dev machine and cluster nodes
|
IMAGE="humor-units:$TAG"
|
||||||
REGISTRY="${REGISTRY:-<NODE_IP>:30500}"
|
ARCHIVE="/tmp/humor-units.tar"
|
||||||
IMAGE="$REGISTRY/humor-units:$TAG"
|
# Space-separated list of node SSH targets
|
||||||
|
NODES="${NODES:-node1 node2}"
|
||||||
|
|
||||||
echo "==> Building $IMAGE..."
|
echo "==> Building $IMAGE..."
|
||||||
buildah build \
|
buildah build \
|
||||||
@@ -15,8 +16,16 @@ buildah build \
|
|||||||
--tag "$IMAGE" \
|
--tag "$IMAGE" \
|
||||||
"$(dirname "$0")"
|
"$(dirname "$0")"
|
||||||
|
|
||||||
echo "==> Pushing $IMAGE..."
|
echo "==> Exporting to OCI archive $ARCHIVE..."
|
||||||
buildah push --tls-verify=false "$IMAGE"
|
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..."
|
echo "==> Restarting humor-units deployment..."
|
||||||
kubectl rollout restart deployment/humor-units -n default
|
kubectl rollout restart deployment/humor-units -n default
|
||||||
|
|||||||
@@ -16,8 +16,8 @@ spec:
|
|||||||
spec:
|
spec:
|
||||||
containers:
|
containers:
|
||||||
- name: humor-units
|
- name: humor-units
|
||||||
image: <NODE_IP>:30500/humor-units:latest
|
image: humor-units:latest
|
||||||
imagePullPolicy: Always
|
imagePullPolicy: Never
|
||||||
ports:
|
ports:
|
||||||
- containerPort: 3000
|
- containerPort: 3000
|
||||||
env:
|
env:
|
||||||
|
|||||||
@@ -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
|
|
||||||
Reference in New Issue
Block a user