[ Cmii ] [ Octopus ] - Image Function fix bugs
This commit is contained in:
25
agent-go/shell/update-app-tag.sh
Normal file
25
agent-go/shell/update-app-tag.sh
Normal 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}\"}]}}}}"
|
||||
Reference in New Issue
Block a user