Skip to content

Commit

Permalink
add helper script to upgrade k8s
Browse files Browse the repository at this point in the history
- added helper script
  from kubernetes/kubernetes#79384 (comment)
  to scripts/upgrade-k8s.sh

- removed bashisms from the script

Signed-off-by: Ed Bartosh <[email protected]>
  • Loading branch information
bart0sh committed Sep 1, 2022
1 parent 210252d commit f814591
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions scripts/upgrade-k8s.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/bin/sh -eu

# based on the work discussed in
# https://github.com/kubernetes/kubernetes/issues/79384#issuecomment-521493597

if [ $# != 1 ] || [ "$1" = "?" ] || [ "$1" = "--help" ]; then
echo "Usage: $0 <k8s version>" >&2
exit 1
fi

VERSION="$1"

for MOD in $(
curl -sS https://raw.githubusercontent.com/kubernetes/kubernetes/v${VERSION}/go.mod |
sed -n 's|.*k8s.io/\(.*\) => ./staging/src/k8s.io/.*|k8s.io/\1|p'
); do
echo "$MOD"
V=$(
go mod download -json "${MOD}@kubernetes-${VERSION}" |
sed -n 's|.*"Version": "\(.*\)".*|\1|p'
)
go mod edit "-replace=${MOD}=${MOD}@${V}"
done
go get "k8s.io/kubernetes@v${VERSION}"

0 comments on commit f814591

Please sign in to comment.