Skip to content

Commit

Permalink
packages/test-peerpods: test IMDS functionality
Browse files Browse the repository at this point in the history
This adds a verification of IMDS functionality to the peer-pods smoke test.
  • Loading branch information
msanft committed Dec 3, 2024
1 parent 5f0f680 commit d39a0d0
Showing 1 changed file with 19 additions and 8 deletions.
27 changes: 19 additions & 8 deletions packages/test-peerpods.sh
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,17 @@ if [[ $found != true ]]; then
exit 1
fi

run_tests() {
pod="$(kubectl get pod -l app=alpine -o jsonpath='{.items[0].metadata.name}')"

# Check IMDS functionality.
# -f makes this fail on a 500 status code.
kubectl exec "$pod" -- curl -f -i -H "Metadata: true" http://169.254.169.254/metadata/THIM/amd/certification
}

cleanup() {
kubectl delete deploy nginx
kubectl wait --for=delete pod --selector=app=nginx --timeout=5m
kubectl delete deploy alpine
kubectl wait --for=delete pod --selector=app=alpine --timeout=5m
}

trap cleanup EXIT
Expand All @@ -52,26 +60,29 @@ kubectl apply -f - <<EOF
apiVersion: apps/v1
kind: Deployment
metadata:
name: nginx
name: alpine
spec:
selector:
matchLabels:
app: nginx
app: alpine
replicas: 1
template:
metadata:
labels:
app: nginx
app: alpine
spec:
runtimeClassName: kata-remote
containers:
- name: nginx
image: nginx
- name: alpine
image: alpine/curl
imagePullPolicy: Always
command: ["sleep", "3600"]
EOF

if ! kubectl wait --for=condition=available --timeout=5m deployment/nginx; then
if ! kubectl wait --for=condition=available --timeout=5m deployment/alpine; then
kubectl describe pods
kubectl logs -n confidential-containers-system -l app=cloud-api-adaptor --tail=-1 --all-containers
exit 1
fi

run_tests

0 comments on commit d39a0d0

Please sign in to comment.