Skip to content
This repository has been archived by the owner on Apr 15, 2024. It is now read-only.

Commit

Permalink
example: fix image name and example script (#220)
Browse files Browse the repository at this point in the history
* add default prefix for example image
* increase script robustness

Signed-off-by: Ruoyu Ying <ruoyu.ying@intel.com>
  • Loading branch information
Ruoyu-y authored Dec 30, 2023
1 parent a655fc2 commit dbb55c0
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ spec:
mountPath: /run/ccnp-eventlog
containers:
- name: ccnp-node-measurement-example
image: ccnp-node-measurement-example:latest
image: "docker.io/library/ccnp-node-measurement-example:latest"
imagePullPolicy: IfNotPresent
resources:
limits:
Expand Down
34 changes: 28 additions & 6 deletions deployment/script/deploy-and-exec-ccnp-example.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,15 @@ set -e
DEFAULT_DOCKER_REPO=docker.io/library
DEFAULT_TAG=latest
TEMP_MANIFEST_FILE=/tmp/ccnp-node-measurement-example-deployment.yaml
DELETE_DEPLOYMENT=false

usage() { echo "Usage: $0 [-r <registry-prefix>] [-g <image-tag>] [-i <register-index-to-verify>]"; exit 1; }
while getopts ":r:g:i:h" option; do
usage() { echo "Usage: $0 [-r <registry-prefix>] [-g <image-tag>] [-d delete existing deployment] [-i <register-index-to-verify>]"; exit 1; }
while getopts ":r:g:i:dh" option; do
case "${option}" in
r) registry=${OPTARG};;
g) tag=${OPTARG};;
i) index=${OPTARG};;
d) DELETE_DEPLOYMENT=true;;
h) usage;;
*) echo "Invalid option: -${OPTARG}" >&2
usage
Expand All @@ -30,14 +32,34 @@ fi
if [[ -n "$tag" ]];then
sed -i "s#${DEFAULT_TAG}#${tag}#g" $TEMP_MANIFEST_FILE
fi

if [ $DELETE_DEPLOYMENT == true ]
then
echo "==> Cleaning up ccnp-node-measurement-example deployment"
kubectl delete -f $TEMP_MANIFEST_FILE
fi

echo "==> Creating ccnp-node-measurement-example deployment"
kubectl apply -f $TEMP_MANIFEST_FILE
sleep 3
for i in {1..5}
do
POD_NAME=$(kubectl get po | grep ccnp-node-measurement-example | grep Running | awk '{ print $1 }')
if [[ -z "$POD_NAME" ]]
then
sleep 3
echo "Retrying $i time ..."
else
break
fi
done

echo "Step 2: Execute node measurement fetching and verification"
POD_NAME=$(kubectl get po | grep ccnp-node-measurement-example | awk '{ print $1 }')
if [[ -z "$POD_NAME" ]]; then
echo "ccnp-node-measurement-example pod not found!"
echo "No ccnp-node-measurement-example pod with status running! Please check your deployment."
exit 1
fi
echo ""

echo "Step 2: Execute node measurement fetching and verification"
IFS=' ' read -r -a arr <<< "${index}"
if [[ ${#arr[@]} -eq 0 ]]
then
Expand Down

0 comments on commit dbb55c0

Please sign in to comment.