Browse your Git repositories
#!/bin/bash
# Script to build ARM64 image directly on a Kubernetes node
echo "This script will build the ARM64 image on a Kubernetes worker node"
echo ""
# Get the first worker node IP
WORKER_IP=$(kubectl get nodes -l '!node-role.kubernetes.io/control-plane' -o jsonpath='{.items[0].status.addresses[?(@.type=="InternalIP")].address}')
echo "Building on worker: $WORKER_IP"
echo ""
# Create a build pod
cat <<EOF | kubectl apply -f -
apiVersion: v1
kind: Pod
metadata:
name: notes-builder
namespace: default
spec:
restartPolicy: Never
nodeSelector:
kubernetes.io/arch: arm64
containers:
- name: kaniko
image: martizih/kaniko:v1.26.4
args:
- "--dockerfile=/workspace/Dockerfile"
- "--context=git://github.com/YOUR_REPO/notes-app.git" # Update this
- "--destination=harbor.kratov.luiv.dev/luna_priv/notes:latest"
- "--cache=true"
volumeMounts:
- name: docker-config
mountPath: /kaniko/.docker/
volumes:
- name: docker-config
secret:
secretName: harbor-registry-secret
items:
- key: .dockerconfigjson
path: config.json
EOF
echo "Build pod created. Check status with: kubectl logs -f notes-builder"