fix(e2e): use ConfigMap for tarball instead of inline base64
Embedding base64 data in the YAML spec broke parsing. Store the plugin tarball in a ConfigMap via --from-file and mount it in the deploy Job. This avoids both the stdin pipe issue and the YAML escaping issue. Co-Authored-By: Paperclip <noreply@paperclip.ing>
This commit is contained in:
@@ -55,19 +55,20 @@ else
|
|||||||
NODE_SELECTOR=""
|
NODE_SELECTOR=""
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Base64-encode the tarball so we can embed it in the pod command
|
# Clean up any previous deploy resources
|
||||||
# (avoids unreliable kubectl run --rm -i stdin piping)
|
|
||||||
TARBALL_B64=$(base64 -w0 "$TAR_FILE")
|
|
||||||
echo " Encoded size: $(echo -n "$TARBALL_B64" | wc -c) bytes"
|
|
||||||
|
|
||||||
# Clean up any previous deploy job/pod
|
|
||||||
kubectl delete job plugin-deploy -n "$HEADLAMP_NAMESPACE" --ignore-not-found 2>/dev/null || true
|
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
|
||||||
sleep 2
|
sleep 2
|
||||||
|
|
||||||
# Create a Job that decodes the tarball and extracts to the PVC
|
# Store the tarball in a ConfigMap (binary-safe via --from-file)
|
||||||
|
echo "Creating ConfigMap with plugin tarball..."
|
||||||
|
kubectl create configmap plugin-tarball \
|
||||||
|
-n "$HEADLAMP_NAMESPACE" \
|
||||||
|
--from-file=plugin.tar.gz="$TAR_FILE"
|
||||||
|
|
||||||
|
# Create a Job that extracts the tarball from the ConfigMap to the PVC
|
||||||
echo "Starting deploy job..."
|
echo "Starting deploy job..."
|
||||||
cat <<JOBEOF | kubectl apply -n "$HEADLAMP_NAMESPACE" -f -
|
kubectl apply -n "$HEADLAMP_NAMESPACE" -f - <<JOBEOF
|
||||||
apiVersion: batch/v1
|
apiVersion: batch/v1
|
||||||
kind: Job
|
kind: Job
|
||||||
metadata:
|
metadata:
|
||||||
@@ -82,24 +83,28 @@ spec:
|
|||||||
containers:
|
containers:
|
||||||
- name: deploy
|
- name: deploy
|
||||||
image: busybox:1.36
|
image: busybox:1.36
|
||||||
command:
|
command: ["sh", "-c"]
|
||||||
- sh
|
args:
|
||||||
- -c
|
|
||||||
- |
|
- |
|
||||||
echo "Decoding and extracting plugin..."
|
echo "Extracting plugin to shared volume..."
|
||||||
echo "${TARBALL_B64}" | base64 -d > /tmp/plugin.tar.gz
|
|
||||||
rm -rf /plugins/${PLUGIN_DIR_NAME}
|
rm -rf /plugins/${PLUGIN_DIR_NAME}
|
||||||
mkdir -p /plugins/${PLUGIN_DIR_NAME}
|
mkdir -p /plugins/${PLUGIN_DIR_NAME}
|
||||||
tar -xzf /tmp/plugin.tar.gz -C /plugins/${PLUGIN_DIR_NAME}
|
tar -xzf /tarball/plugin.tar.gz -C /plugins/${PLUGIN_DIR_NAME}
|
||||||
echo "Files deployed:"
|
echo "Files deployed:"
|
||||||
ls -la /plugins/${PLUGIN_DIR_NAME}/
|
ls -la /plugins/${PLUGIN_DIR_NAME}/
|
||||||
volumeMounts:
|
volumeMounts:
|
||||||
- name: plugins
|
- name: plugins
|
||||||
mountPath: /plugins
|
mountPath: /plugins
|
||||||
|
- name: tarball
|
||||||
|
mountPath: /tarball
|
||||||
|
readOnly: true
|
||||||
volumes:
|
volumes:
|
||||||
- name: plugins
|
- name: plugins
|
||||||
persistentVolumeClaim:
|
persistentVolumeClaim:
|
||||||
claimName: headlamp-plugins
|
claimName: headlamp-plugins
|
||||||
|
- name: tarball
|
||||||
|
configMap:
|
||||||
|
name: plugin-tarball
|
||||||
JOBEOF
|
JOBEOF
|
||||||
|
|
||||||
# Wait for the job to complete
|
# Wait for the job to complete
|
||||||
@@ -112,6 +117,7 @@ kubectl logs job/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 job 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
|
||||||
|
|
||||||
rm -f "$TAR_FILE"
|
rm -f "$TAR_FILE"
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user