Skip to content

Automate bare-metal trusted compute deployment in K3 environment.#411

Open
jena-satyabrata wants to merge 2 commits intomainfrom
dev/sbjena/baremetal_automation
Open

Automate bare-metal trusted compute deployment in K3 environment.#411
jena-satyabrata wants to merge 2 commits intomainfrom
dev/sbjena/baremetal_automation

Conversation

@jena-satyabrata
Copy link
Copy Markdown
Contributor

Merge Checklist

All boxes should be checked before merging the PR

  • The changes in the PR have been built and tested
  • Ready to merge

Description

Fixes # (issue)

Any Newly Introduced Dependencies

How Has This Been Tested?

Signed-off-by: Jena, Satyabrata <satyabrata.jena@intel.com>
@shahmitu shahmitu requested a review from Copilot April 4, 2026 08:09
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Note

Copilot was unable to run its full agentic suite in this review.

Adds a bare-metal automation script to install (or rebuild) the Trusted Compute package in a k3s environment and validate the setup by deploying a sample trusted workload.

Changes:

  • Introduces a new run_trusted_compute_baremetal.sh script with --local-build and ORAS-based package retrieval.
  • Automates cleanup/uninstall of prior Trusted Compute artifacts, installs k3s if missing, and runs extension install.
  • Deploys and validates a sample nginx pod using the kata-qemu RuntimeClass, then cleans up.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +80 to +90
echo "[1/9] Building local installation package with make build"
cd "${SCRIPT_DIR}"
make build

if [[ ! -f "${SCRIPT_DIR}/${PACKAGE_TAR}" ]]; then
echo "Error: ${PACKAGE_TAR} was not created by make build"
exit 1
fi

echo "[2/9] Copying locally built package into temp directory: ${TEMP_DIR}"
cp "${SCRIPT_DIR}/${PACKAGE_TAR}" "${TEMP_DIR}/"
Copy link

Copilot AI Apr 4, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the --local-build flow the script remains in ${SCRIPT_DIR} after copying the tarball to ${TEMP_DIR}, but extraction runs tar -xvf \"${PACKAGE_TAR}\" from the current directory. This will fail (or extract the wrong file) because ${PACKAGE_TAR} is expected to be in ${TEMP_DIR}. Fix by extracting from ${TEMP_DIR} explicitly (e.g., cd \"${TEMP_DIR}\" before extraction or use tar -x... -C \"${TEMP_DIR}\" -f \"${TEMP_DIR}/${PACKAGE_TAR}\"). Also, since the file is .tgz, prefer using gzip-aware extraction flags/behavior to avoid portability issues.

Copilot uses AI. Check for mistakes.
fi

echo "[3/9] Extracting ${PACKAGE_TAR}"
tar -xvf "${PACKAGE_TAR}"
Copy link

Copilot AI Apr 4, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the --local-build flow the script remains in ${SCRIPT_DIR} after copying the tarball to ${TEMP_DIR}, but extraction runs tar -xvf \"${PACKAGE_TAR}\" from the current directory. This will fail (or extract the wrong file) because ${PACKAGE_TAR} is expected to be in ${TEMP_DIR}. Fix by extracting from ${TEMP_DIR} explicitly (e.g., cd \"${TEMP_DIR}\" before extraction or use tar -x... -C \"${TEMP_DIR}\" -f \"${TEMP_DIR}/${PACKAGE_TAR}\"). Also, since the file is .tgz, prefer using gzip-aware extraction flags/behavior to avoid portability issues.

Suggested change
tar -xvf "${PACKAGE_TAR}"
tar -xzvf "${TEMP_DIR}/${PACKAGE_TAR}" -C "${TEMP_DIR}"

Copilot uses AI. Check for mistakes.
sudo ./install.sh

echo "[8/9] Deploying sample nginx trusted workload"
sudo kubectl create namespace nginx-test
Copy link

Copilot AI Apr 4, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

kubectl create namespace nginx-test will fail on re-runs if the namespace already exists, and because set -e is enabled the script will exit. Consider making this idempotent (e.g., use kubectl apply for the namespace definition, or check existence before creation) so the script can be safely re-run.

Suggested change
sudo kubectl create namespace nginx-test
sudo kubectl apply -f - <<'EOF'
apiVersion: v1
kind: Namespace
metadata:
name: nginx-test
EOF

Copilot uses AI. Check for mistakes.
Comment on lines +143 to +147
echo "[9/9] Verifying workload and cleaning up"
sudo kubectl get pods -n nginx-test
sudo kubectl describe pod nginx-default -n nginx-test
sudo kubectl logs nginx-default -n nginx-test
sudo kubectl delete namespace nginx-test
Copy link

Copilot AI Apr 4, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verification is prone to flakiness: kubectl logs (and even describe/get output expectations) can fail or be misleading if the pod hasn't started yet, and with set -e the script will exit early. Add an explicit wait (e.g., wait for pod/nginx-default to be Ready with a timeout) before attempting to read logs, and consider ensuring cleanup runs even if verification fails.

Copilot uses AI. Check for mistakes.
runtimeClassName: kata-qemu
containers:
- name: nginx
image: nginx:latest
Copy link

Copilot AI Apr 4, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using nginx:latest makes the deployed workload non-reproducible and can unexpectedly change over time. Pin to a specific version tag or (preferably) an immutable image digest to ensure deterministic behavior and reduce supply-chain risk.

Suggested change
image: nginx:latest
image: nginx:1.27.0

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants