fix(e2e): use Pod instead of Job for plugin deploy

The CI runner SA has permission to create Pods but not Jobs in
kube-system. Switch from a Job to a plain Pod with restartPolicy:Never.
Use ConfigMap mount for tarball data (no stdin piping needed).

Co-Authored-By: Paperclip <noreply@paperclip.ing>
This commit is contained in:
2026-03-17 17:20:37 +00:00
parent 8aaa82663c
commit f4fac60d40
+40 -44
View File
@@ -52,7 +52,7 @@ if [ -n "$HEADLAMP_NODE" ]; then
fi fi
# Clean up any previous deploy resources # Clean up any previous deploy resources
kubectl delete job plugin-deploy -n "$HEADLAMP_NAMESPACE" --ignore-not-found 2>/dev/null || true kubectl delete pod plugin-deploy -n "$HEADLAMP_NAMESPACE" --ignore-not-found --wait=true 2>/dev/null || true
kubectl delete configmap plugin-tarball -n "$HEADLAMP_NAMESPACE" --ignore-not-found 2>/dev/null || true kubectl delete configmap plugin-tarball -n "$HEADLAMP_NAMESPACE" --ignore-not-found 2>/dev/null || true
sleep 2 sleep 2
@@ -62,69 +62,65 @@ kubectl create configmap plugin-tarball \
-n "$HEADLAMP_NAMESPACE" \ -n "$HEADLAMP_NAMESPACE" \
--from-file=plugin.tar.gz="$TAR_FILE" --from-file=plugin.tar.gz="$TAR_FILE"
# Build the Job manifest as a temp file to avoid heredoc YAML escaping issues # Build the Pod manifest as a temp file to avoid heredoc YAML escaping issues
JOB_FILE=$(mktemp /tmp/plugin-deploy-job-XXXXXX.yaml) POD_FILE=$(mktemp /tmp/plugin-deploy-pod-XXXXXX.yaml)
cat > "$JOB_FILE" <<'YAMLDOC' cat > "$POD_FILE" <<'YAMLDOC'
apiVersion: batch/v1 apiVersion: v1
kind: Job kind: Pod
metadata: metadata:
name: plugin-deploy name: plugin-deploy
spec: spec:
backoffLimit: 0 restartPolicy: Never
ttlSecondsAfterFinished: 60 containers:
template: - name: deploy
spec: image: busybox:1.36
restartPolicy: Never command: ["sh", "-c"]
containers: args:
- name: deploy - |
image: busybox:1.36 echo "Extracting plugin to shared volume..."
command: ["sh", "-c"] rm -rf /plugins/PLUGIN_DIR_PLACEHOLDER
args: mkdir -p /plugins/PLUGIN_DIR_PLACEHOLDER
- | tar -xzf /tarball/plugin.tar.gz -C /plugins/PLUGIN_DIR_PLACEHOLDER
echo "Extracting plugin to shared volume..." echo "Files deployed:"
rm -rf /plugins/PLUGIN_DIR_PLACEHOLDER ls -la /plugins/PLUGIN_DIR_PLACEHOLDER/
mkdir -p /plugins/PLUGIN_DIR_PLACEHOLDER volumeMounts:
tar -xzf /tarball/plugin.tar.gz -C /plugins/PLUGIN_DIR_PLACEHOLDER
echo "Files deployed:"
ls -la /plugins/PLUGIN_DIR_PLACEHOLDER/
volumeMounts:
- name: plugins
mountPath: /plugins
- name: tarball
mountPath: /tarball
readOnly: true
volumes:
- name: plugins - name: plugins
persistentVolumeClaim: mountPath: /plugins
claimName: headlamp-plugins
- name: tarball - name: tarball
configMap: mountPath: /tarball
name: plugin-tarball readOnly: true
volumes:
- name: plugins
persistentVolumeClaim:
claimName: headlamp-plugins
- name: tarball
configMap:
name: plugin-tarball
YAMLDOC YAMLDOC
# Substitute plugin dir name # Substitute plugin dir name
sed -i "s/PLUGIN_DIR_PLACEHOLDER/${PLUGIN_DIR_NAME}/g" "$JOB_FILE" sed -i "s/PLUGIN_DIR_PLACEHOLDER/${PLUGIN_DIR_NAME}/g" "$POD_FILE"
# Add nodeName if we know which node Headlamp is on # Add nodeName if we know which node Headlamp is on
if [ -n "$HEADLAMP_NODE" ]; then if [ -n "$HEADLAMP_NODE" ]; then
sed -i "/restartPolicy: Never/i\\ nodeName: ${HEADLAMP_NODE}" "$JOB_FILE" sed -i "/restartPolicy: Never/i\\ nodeName: ${HEADLAMP_NODE}" "$POD_FILE"
fi fi
echo "Starting deploy job..." echo "Starting deploy pod..."
kubectl apply -n "$HEADLAMP_NAMESPACE" -f "$JOB_FILE" kubectl apply -n "$HEADLAMP_NAMESPACE" -f "$POD_FILE"
rm -f "$JOB_FILE" rm -f "$POD_FILE"
# Wait for the job to complete # Wait for the pod to complete (Succeeded phase)
echo "Waiting for deploy job to complete..." echo "Waiting for deploy pod to complete..."
kubectl wait --for=condition=complete job/plugin-deploy \ kubectl wait --for=jsonpath='{.status.phase}'=Succeeded pod/plugin-deploy \
-n "$HEADLAMP_NAMESPACE" --timeout=120s -n "$HEADLAMP_NAMESPACE" --timeout=120s
# Show logs # Show logs
kubectl logs job/plugin-deploy -n "$HEADLAMP_NAMESPACE" 2>/dev/null || true kubectl logs plugin-deploy -n "$HEADLAMP_NAMESPACE" 2>/dev/null || true
# Clean up # Clean up
kubectl delete job plugin-deploy -n "$HEADLAMP_NAMESPACE" --ignore-not-found 2>/dev/null || true kubectl delete pod plugin-deploy -n "$HEADLAMP_NAMESPACE" --ignore-not-found 2>/dev/null || true
kubectl delete configmap plugin-tarball -n "$HEADLAMP_NAMESPACE" --ignore-not-found 2>/dev/null || true kubectl delete configmap plugin-tarball -n "$HEADLAMP_NAMESPACE" --ignore-not-found 2>/dev/null || true
rm -f "$TAR_FILE" rm -f "$TAR_FILE"