-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathupdate-kube-ovn
executable file
·60 lines (52 loc) · 1.95 KB
/
update-kube-ovn
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#!/usr/bin/env bash
set -euxo pipefail
# Update kube-ovn to the latest version. This script will:
# 1. Sync the kube-ovn container image to rocks.canonical.com
# 2. Update manifests in templates/kube-ovn
# 3. Update plugins/kubectl-ko
tag="${tag:-$(wget -O- https://api.github.com/repos/kubeovn/kube-ovn/releases/latest | jq .tag_name -r)}"
# Sync image
image="kubeovn/kube-ovn:$tag"
cat << EOF > regsync.yaml
sync:
- type: image
source: $image
target: upload.rocks.canonical.com:5000/cdk/$image
EOF
regsync once -c regsync.yaml
rm regsync.yaml
# Build manifests. Unfortunately, the upstream Kube-OVN project does not
# publish updated manifests with each release. To get "correct" manifests for a
# given release, we have to extract them from the install.sh script.
#
# Here, we attempt to do this by modifying install.sh such that it does not
# actually call out to kubectl. Then we run it. This is extremely brittle and
# likely to fail in a future Kube-OVN release.
(cd templates/kube-ovn
rm ./*
wget "https://raw.githubusercontent.com/kubeovn/kube-ovn/$tag/dist/images/install.sh"
sed -i install.sh \
-e "s/^VERSION=.*/VERSION='$tag'/" \
-e 's/^addresses=.*/addresses=ADDRESSES/' \
-e 's/^count=.*/count=1/'
# ensure the script does not call the real kubectl
mkdir bin
ln -s "$(which true)" bin/kubectl
(export PATH="bin:$PATH"
bash install.sh || true
)
rm -rf bin install.sh
# install.sh doesn't produce speaker.yaml, so we still need to obtain that
# from the yamls folder
wget "https://raw.githubusercontent.com/kubeovn/kube-ovn/$tag/yamls/speaker.yaml"
sed -i speaker.yaml \
-e "s/image:.*/image: kubeovn\/kube-ovn:$tag/"
# Add header
for f in *; do
echo "# DO NOT EDIT - Autogenerated by update-kube-ovn script for kube-ovn $tag" > "$f.tmp"
cat "$f" >> "$f.tmp"
mv "$f.tmp" "$f"
done
)
# Update kubectl-ko
wget "https://raw.githubusercontent.com/kubeovn/kube-ovn/$tag/dist/images/kubectl-ko" -O plugins/kubectl-ko