longhorn/dev/scripts/lm-update.sh
Sheng Yang 3870716b8c dev scripts: update lm-update.sh and update-image-pull-policy.sh
To include a way to restart every Longhorn components automatically with
the latest image.

1. Now `lm-update.sh` will set `imagePullPolicy: Always` for the manager
and the driver.
2. Now update-image-pull-policy.sh will update the `imagePullPolicy` for
all the running deployments and daemonsets in the `longhorn-system`
namespace, including CSI components.

Signed-off-by: Sheng Yang <sheng.yang@rancher.com>
2020-10-20 12:28:26 -07:00

46 lines
1.2 KiB
Bash
Executable File

#!/bin/bash
#set -x
set -e
username=$1
if [ "$username" == "" ]
then
echo DockerHub username is required
exit 1
fi
update=$2
project="longhorn-manager"
base="${GOPATH}/src/github.com/longhorn/longhorn-manager"
yaml=${base}"/deploy/install/02-components/01-manager.yaml"
driver_yaml=${base}"/deploy/install/02-components/04-driver.yaml"
latest=`cat ${base}/bin/latest_image`
private=`sed "s/longhornio/${username}/g" ${base}/bin/latest_image`
echo Latest image ${latest}
echo Latest private image ${private}
docker tag ${latest} ${private}
docker push ${private}
escaped_private=${private//\//\\\/}
sed -i "s/image\:\ .*\/${project}:.*/image\:\ ${escaped_private}/g" $yaml
sed -i "s/-\ .*\/${project}:.*/-\ ${escaped_private}/g" $yaml
sed -i "s/imagePullPolicy\:\ .*/imagePullPolicy\:\ Always/g" $yaml
sed -i "s/image\:\ .*\/${project}:.*/image\:\ ${escaped_private}/g" $driver_yaml
sed -i "s/-\ .*\/${project}:.*/-\ ${escaped_private}/g" $driver_yaml
sed -i "s/imagePullPolicy\:\ .*/imagePullPolicy\:\ Always/g" $driver_yaml
set +e
if [ "$update" == "" ]
then
kubectl delete -f $yaml
kubectl create -f $yaml
kubectl delete -f $driver_yaml
kubectl create -f $driver_yaml
fi