diff --git a/deployment/headlamp-e2e-values.yaml b/deployment/headlamp-e2e-values.yaml new file mode 100644 index 0000000..36ab498 --- /dev/null +++ b/deployment/headlamp-e2e-values.yaml @@ -0,0 +1,22 @@ +--- +# Headlamp Helm values for E2E testing with shared volume plugin deployment. +# +# The CI runner and Headlamp pod share a PVC so that the runner can copy +# built plugin artifacts directly into Headlamp's plugins directory. +# This is a CI-only mechanism — production plugin distribution uses ArtifactHub. + +# Point Headlamp at the shared plugins mount +config: + pluginsDir: /headlamp/plugins + +# PVC-backed volume shared with the CI runner +volumes: + - name: plugins + persistentVolumeClaim: + claimName: headlamp-plugins + +# Mount into the Headlamp container +volumeMounts: + - name: plugins + mountPath: /headlamp/plugins + readOnly: true diff --git a/deployment/headlamp-plugins-pvc.yaml b/deployment/headlamp-plugins-pvc.yaml new file mode 100644 index 0000000..f103a21 --- /dev/null +++ b/deployment/headlamp-plugins-pvc.yaml @@ -0,0 +1,14 @@ +--- +# PVC for sharing built plugin artifacts between the CI runner and Headlamp. +# Used only in E2E test environments — not for production. +apiVersion: v1 +kind: PersistentVolumeClaim +metadata: + name: headlamp-plugins + namespace: kube-system +spec: + accessModes: + - ReadWriteOnce + resources: + requests: + storage: 128Mi diff --git a/deployment/headlamp-static-plugin-values.yaml b/deployment/headlamp-static-plugin-values.yaml deleted file mode 100644 index 59618f3..0000000 --- a/deployment/headlamp-static-plugin-values.yaml +++ /dev/null @@ -1,83 +0,0 @@ ---- -# Custom Headlamp values for static plugin installation -# This disables the plugin manager and uses an init container instead - -# Disable the plugin manager sidecar -pluginsManager: - enabled: false - -# Use an init container to install plugins to /headlamp/static-plugins -initContainers: - - name: install-plugins - image: node:lts-alpine - command: - - /bin/sh - - -c - - | - set -e - echo "Installing plugins to /headlamp/static-plugins..." - - # Create plugins directory - mkdir -p /headlamp/static-plugins - - # Set up npm cache - export NPM_CONFIG_CACHE=/tmp/npm-cache - export NPM_CONFIG_USERCONFIG=/tmp/npm-userconfig - mkdir -p /tmp/npm-cache /tmp/npm-userconfig - - # Install polaris plugin - echo "Installing polaris plugin..." - cd /headlamp/static-plugins - npm pack headlamp-polaris-plugin@0.3.0 - tar -xzf headlamp-polaris-plugin-0.3.0.tgz - mv package headlamp-polaris-plugin - rm headlamp-polaris-plugin-0.3.0.tgz - - # Install other plugins - npx --yes @headlamp-k8s/plugin@latest install \ - --source https://artifacthub.io/packages/headlamp/headlamp-plugins/headlamp_flux \ - --folderName /headlamp/static-plugins - - npx --yes @headlamp-k8s/plugin@latest install \ - --source https://artifacthub.io/packages/headlamp/headlamp-trivy/headlamp_trivy \ - --folderName /headlamp/static-plugins - - npx --yes @headlamp-k8s/plugin@latest install \ - --source https://artifacthub.io/packages/headlamp/headlamp-plugins/headlamp_cert-manager \ - --folderName /headlamp/static-plugins - - npx --yes @headlamp-k8s/plugin@latest install \ - --source https://artifacthub.io/packages/headlamp/headlamp-plugins/headlamp_ai_assistant \ - --folderName /headlamp/static-plugins - - echo "All plugins installed successfully" - ls -la /headlamp/static-plugins - securityContext: - runAsUser: 100 - runAsGroup: 101 - runAsNonRoot: true - privileged: false - resources: - requests: - cpu: 100m - memory: 256Mi - limits: - memory: 512Mi - volumeMounts: - - name: static-plugins - mountPath: /headlamp/static-plugins - -# Configure headlamp to use static plugins -config: - pluginsDir: /headlamp/static-plugins - -# Add volume for static plugins -volumes: - - name: static-plugins - emptyDir: {} - -# Add volume mount to main container -volumeMounts: - - name: static-plugins - mountPath: /headlamp/static-plugins - readOnly: true diff --git a/scripts/deploy-plugin-via-volume.sh b/scripts/deploy-plugin-via-volume.sh new file mode 100755 index 0000000..c89c719 --- /dev/null +++ b/scripts/deploy-plugin-via-volume.sh @@ -0,0 +1,49 @@ +#!/usr/bin/env bash +# deploy-plugin-via-volume.sh +# +# Copies the built plugin into the shared PVC so Headlamp picks it up. +# The PVC must already be mounted on the CI runner at PLUGIN_VOLUME_PATH. +# +# Usage: +# scripts/deploy-plugin-via-volume.sh [plugin-volume-path] +# +# Environment: +# PLUGIN_VOLUME_PATH — mount point of the shared PVC (default: /mnt/headlamp-plugins) +# HEADLAMP_NAMESPACE — namespace where Headlamp runs (default: kube-system) +# HEADLAMP_DEPLOY — Headlamp deployment name (default: headlamp) +set -euo pipefail + +REPO_ROOT="$(cd "$(dirname "$0")/.." && pwd)" +PLUGIN_VOLUME_PATH="${1:-${PLUGIN_VOLUME_PATH:-/mnt/headlamp-plugins}}" +HEADLAMP_NAMESPACE="${HEADLAMP_NAMESPACE:-kube-system}" +HEADLAMP_DEPLOY="${HEADLAMP_DEPLOY:-headlamp}" + +# The deployed directory name must match the plugin's registered name. +# PR #56 aligns registerPluginSettings to "polaris"; the directory must match. +PLUGIN_DIR_NAME="polaris" +DIST_DIR="$REPO_ROOT/dist" + +if [ ! -d "$DIST_DIR" ]; then + echo "ERROR: dist/ not found. Run 'npm run build' first." >&2 + exit 1 +fi + +echo "Deploying plugin to shared volume..." +echo " Source: $DIST_DIR" +echo " Destination: $PLUGIN_VOLUME_PATH/$PLUGIN_DIR_NAME" + +# Clean any previous version and copy fresh build +rm -rf "${PLUGIN_VOLUME_PATH:?}/${PLUGIN_DIR_NAME}" +mkdir -p "$PLUGIN_VOLUME_PATH/$PLUGIN_DIR_NAME" +cp -a "$DIST_DIR"/. "$PLUGIN_VOLUME_PATH/$PLUGIN_DIR_NAME/" +cp "$REPO_ROOT/package.json" "$PLUGIN_VOLUME_PATH/$PLUGIN_DIR_NAME/" + +echo "Plugin files deployed:" +ls -la "$PLUGIN_VOLUME_PATH/$PLUGIN_DIR_NAME/" + +# Restart Headlamp to pick up the new plugin +echo "Restarting Headlamp deployment to load plugin..." +kubectl rollout restart "deployment/$HEADLAMP_DEPLOY" -n "$HEADLAMP_NAMESPACE" +kubectl rollout status "deployment/$HEADLAMP_DEPLOY" -n "$HEADLAMP_NAMESPACE" --timeout=120s + +echo "Plugin deployed successfully."