[ Cmii ] [ Octopus ] - Image Function fix bugs

This commit is contained in:
zeaslity
2024-04-07 15:59:53 +08:00
parent 8e1304aac0
commit a9f25712eb
14 changed files with 492 additions and 510 deletions

View File

@@ -0,0 +1,25 @@
#!/bin/bash
# Check if the correct number of arguments are provided
if [ "$#" -ne 3 ]; then
echo "Usage: $0 <name_space> <new_tag> <deployment_name>"
exit 1
fi
# Assign the arguments to variables
name_space=$1
new_tag=$2
deployment_name=$3
echo "Name Space: $name_space Deployment Name: $deployment_name New Tag: $new_tag"
echo ""
deployment_image=$(kubectl -n "${name_space}" get deployment "${deployment_name}" -o=jsonpath='{.spec.template.spec.containers[*].image}')
image_prefix=$(echo "${deployment_image}" | cut -d":" -f1)
old_tag=$(echo "${deployment_image}" | cut -d":" -f2)
echo "image prefix is => ${image_prefix}"
echo "old_tag is ${old_tag}"
kubectl -n "${name_space}" patch deployment "${deployment_name}" -p "{\"spec\":{\"template\":{\"spec\":{\"containers\":[{\"name\":\"${deployment_name}\",\"image\": \"${image_prefix}:${new_tag}\"}]}}}}"