Skip to content
This repository has been archived by the owner on Jun 29, 2022. It is now read-only.

Find updates of the components that make Lokomotive #375

Merged
merged 2 commits into from
Jun 24, 2020

Conversation

surajssd
Copy link
Member

@surajssd surajssd commented Apr 28, 2020

I used this script to identify the updates that are needed to the components we incorporate into Lokomotive.

@surajssd
Copy link
Member Author

The output looks like this:

$ ./scripts/find-updates.sh 
Component               Current Version     Latest Version
---------               ---------------     --------------
kubernetes                     v1.18.2"            v1.18.2
calico                         v3.13.3"            v3.13.3
etcd                            v3.4.7"             v3.4.7
cert-manager                    v0.14.2            v0.14.2
contour                          v1.3.0             v1.4.0
Dex                             v2.23.0            v2.23.0
external-dns                     2.21.2             2.22.0
gangway                          v3.2.0             v3.2.0
metallb              v0.8.3-2-gf653773b             v0.9.3
metrics-server                   2.11.1             2.11.1
openebs                           1.9.0              1.9.1

@surajssd
Copy link
Member Author

surajssd commented Apr 28, 2020

All inputs on how to make it configurable, non-repeatable code, etc. are welcome.

Copy link
Member

@invidian invidian left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work @surajssd, I put some comments for possible improvements. If we would clean up the version to get exact matches, we could even have this script running on the CI from time to time and reporting updates on Slack.

scripts/find-updates.sh Outdated Show resolved Hide resolved
scripts/find-updates.sh Outdated Show resolved Hide resolved
scripts/find-updates.sh Outdated Show resolved Hide resolved
scripts/find-updates.sh Show resolved Hide resolved
scripts/find-updates.sh Show resolved Hide resolved
@surajssd surajssd force-pushed the surajssd/find-updates branch from dcb7278 to 32502cc Compare April 29, 2020 08:46
@surajssd surajssd requested a review from invidian April 29, 2020 08:48
@surajssd
Copy link
Member Author

surajssd commented May 4, 2020

@invidian added changes PTAL.

Copy link
Member

@invidian invidian left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure if we should spend more time on this script, current output produces reasonable result, so we could merge it.

I pointed some nits I found, which could be quickly fixed though. They include fix for having exact value for versions, which I think could be even taken further, so the script only prints the components, which should be installed, instead of all of them.

I also think this script might be rather fragile, if we move things around in the repository. Perhaps having some "manifest" file which we discussed during when working on versioning and pull the versions from there into the check and the code.

I also did some test to use column binary instead of printf to have more flexible/dynamic output. This ensures nice formatting regardless of the value length and also in my opinion makes the script a bit simpler.

Here is the patch if you want to take a look, including both fixed nits and column output. I added Progress: . output line to provide user some feedback, as now output is delayed until all versions are pulled. I think this is optional and could be removed if you don't like it.

diff --git a/scripts/find-updates.sh b/scripts/find-updates.sh
index 1d12346f..09a866c0 100755
--- a/scripts/find-updates.sh
+++ b/scripts/find-updates.sh
@@ -6,6 +6,13 @@ function get_latest_release() {
   version=$(curl --silent "https://api.github.com/repos/$1/releases/latest" | jq -r '.tag_name')
 }

+OUTPUT="---------------,---------------,---------------\n"
+
+function progress() {
+  OUTPUT+="${1}\n"
+  echo -n .
+}
+
 # Make sure we keep track of the Lokomotive code repository.
 workdir=$(pwd)

@@ -15,39 +22,39 @@ export XDG_CACHE_HOME="${tmphelm}"
 export XDG_CONFIG_HOME="${tmphelm}"
 export XDG_DATA_HOME="${tmphelm}"

-# Make sure that we have a format for priting values.
-format="%-20s %18s %18s\n"
+OUTPUT="---------------,---------------,---------------\n"

-# Print the column names.
-printf "${format}" "Component" "Current Version" "Latest Version"
-printf "${format}" "---------" "---------------" "--------------"
+echo -n "Progress: ."

 ###########################
 # k8s
-current_version=$(grep 'k8s.gcr.io/kube-apiserver' assets/lokomotive-kubernetes/bootkube/variables.tf | cut -d":" -f2)
+current_version=$(grep 'k8s.gcr.io/kube-apiserver' assets/lokomotive-kubernetes/bootkube/variables.tf | cut -d":" -f2 | sed 's/"//g')

 get_latest_release kubernetes/kubernetes
-printf "${format}" "kubernetes" "${current_version}" "${version}"
+
+progress "kubernetes,${current_version},${version}"

 ###########################
 # calico
-current_version=$(grep 'calico/node' assets/lokomotive-kubernetes/bootkube/variables.tf | cut -d":" -f2)
+current_version=$(grep 'calico/node' assets/lokomotive-kubernetes/bootkube/variables.tf | cut -d":" -f2 | sed 's/"//g')

 get_latest_release projectcalico/calico
-printf "${format}" "calico" "${current_version}" "${version}"
+
+progress "calico,${current_version},${version}"

 ###########################
 # etcd
-current_version=$(grep 'ETCD_IMAGE_TAG=' assets/lokomotive-kubernetes/aws/flatcar-linux/kubernetes/cl/controller.yaml.tmpl | cut -d"=" -f3)
+current_version=$(grep 'ETCD_IMAGE_TAG=' assets/lokomotive-kubernetes/aws/flatcar-linux/kubernetes/cl/controller.yaml.tmpl | cut -d"=" -f3 | sed 's/"//g')

 get_latest_release etcd-io/etcd
-printf "${format}" "etcd" "${current_version}" "${version}"
+
+progress "etcd,${current_version},${version}"

 ###########################
 # cert-manager

 cd "${workdir}"
-current_version=$(grep appVersion assets/components/cert-manager/manifests/Chart.yaml | cut -d":" -f2)
+current_version=$(grep appVersion assets/components/cert-manager/manifests/Chart.yaml | cut -d":" -f2 | sed 's/ //g' | sed 's/ //g')

 # Download the latest chart in temp dir and find out the version in it.
 tmpdir=$(mktemp -d)
@@ -55,9 +62,9 @@ cd "${tmpdir}"
 helm repo add jetstack https://charts.jetstack.io >/dev/null 2>&1
 helm repo update >/dev/null 2>&1
 helm fetch --untar --untardir ./ jetstack/cert-manager
-version=$(grep appVersion "${tmpdir}/cert-manager/Chart.yaml" | cut -d":" -f2)
+version=$(grep appVersion "${tmpdir}/cert-manager/Chart.yaml" | cut -d":" -f2 | sed 's/ //g')

-printf "${format}" "cert-manager" "${current_version}" "${version}"
+progress "cert-manager,${current_version},${version}"

 ###########################
 # contour
@@ -66,7 +73,8 @@ cd "${workdir}"
 current_version=$(grep "image: docker.io/projectcontour/contour" assets/components/contour/contour/03-contour.yaml | cut -d":" -f3)

 get_latest_release projectcontour/contour
-printf "${format}" "contour" "${current_version}" "${version}"
+
+progress "contour,${current_version},${version}"

 ###########################
 # Dex
@@ -74,22 +82,23 @@ cd "${workdir}"
 current_version=$(grep "image: quay.io/dexidp/dex" pkg/components/dex/component.go | cut -d":" -f3)

 get_latest_release dexidp/dex
-printf "${format}" "Dex" "${current_version}" "${version}"
+
+progress "dex,${current_version},${version}"


 ###########################
 # external dns
 cd "${workdir}"
-current_version=$(grep version assets/components/external-dns/manifests/Chart.yaml | cut -d":" -f2)
+current_version=$(grep version assets/components/external-dns/manifests/Chart.yaml | cut -d":" -f2 | sed 's/ //g')

 tmpdir=$(mktemp -d)
 cd "${tmpdir}"
 helm repo add bitnami https://charts.bitnami.com/bitnami >/dev/null 2>&1
 helm repo update >/dev/null 2>&1
 helm fetch --untar --untardir ./ bitnami/external-dns
-version=$(grep version "${tmpdir}/external-dns/Chart.yaml" | cut -d":" -f2)
+version=$(grep version "${tmpdir}/external-dns/Chart.yaml" | cut -d":" -f2 | sed 's/ //g')

-printf "${format}" "external-dns" "${current_version}" "${version}"
+progress "external-dns,${current_version},${version}"

 ###########################
 # gangway
@@ -98,7 +107,7 @@ cd "${workdir}"
 current_version=$(grep "image: gcr.io/heptio-images/gangway" pkg/components/gangway/component.go | cut -d":" -f3)

 get_latest_release heptiolabs/gangway
-printf "${format}" "gangway" "${current_version}" "${version}"
+progress "gangway,${current_version},${version}"

 ###########################
 # metallb
@@ -107,12 +116,12 @@ cd "${workdir}"
 current_version=$(grep "image: quay.io/kinvolk/metallb-controller" pkg/components/metallb/manifests.go | cut -d":" -f3)

 get_latest_release metallb/metallb
-printf "${format}" "metallb" "${current_version}" "${version}"
+progress "metallb,${current_version},${version}"

 ###########################
 # metrics-server
 cd "${workdir}"
-current_version=$(grep version assets/components/metrics-server/Chart.yaml | cut -d":" -f2)
+current_version=$(grep version assets/components/metrics-server/Chart.yaml | cut -d":" -f2 | sed 's/ //g')

 tmpdir=$(mktemp -d)
 cd "${tmpdir}"
@@ -120,19 +129,24 @@ cd "${tmpdir}"
 helm repo add stable https://kubernetes-charts.storage.googleapis.com >/dev/null 2>&1
 helm repo update >/dev/null 2>&1
 helm fetch --untar --untardir ./ stable/metrics-server
-version=$(grep version "${tmpdir}/metrics-server/Chart.yaml" | cut -d":" -f2)
+version=$(grep version "${tmpdir}/metrics-server/Chart.yaml" | cut -d":" -f2 | sed 's/ //g')

-printf "${format}" "metrics-server" "${current_version}" "${version}"
+progress "metrics-server,${current_version},${version}"

 ###########################
 # openebs
 cd "${workdir}"
-current_version=$(grep version assets/components/openebs/Chart.yaml | cut -d":" -f2)
+current_version=$(grep version assets/components/openebs/Chart.yaml | cut -d":" -f2 | sed 's/ //g')

 tmpdir=$(mktemp -d)
 cd "${tmpdir}"

 helm fetch --untar --untardir ./ stable/openebs
-version=$(grep version "${tmpdir}/openebs/Chart.yaml" | cut -d":" -f2)
+version=$(grep version "${tmpdir}/openebs/Chart.yaml" | cut -d":" -f2 | sed 's/ //g')
+
+progress "openebs,${current_version},${version}"
+
+# Finish progress line and add one more to separate progress from result.
+echo -e "\n"

-printf "${format}" "openebs" "${current_version}" "${version}"
+echo -e $OUTPUT | column -s, -t -N "Component,Current Version,Latest Version"

scripts/find-updates.sh Outdated Show resolved Hide resolved
scripts/find-updates.sh Outdated Show resolved Hide resolved
scripts/find-updates.sh Outdated Show resolved Hide resolved
scripts/find-updates.sh Outdated Show resolved Hide resolved
scripts/find-updates.sh Outdated Show resolved Hide resolved
scripts/find-updates.sh Show resolved Hide resolved
@iaguis
Copy link
Contributor

iaguis commented May 5, 2020

Can we get this moving, it seems very close to being ready :)

rata
rata previously approved these changes May 6, 2020
Copy link
Member

@rata rata left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. We can make some trivial changes later :)

@invidian thanks a lot for the patch, too! However, I don't think is worth it and I think taking so much time for this script is pointless. We can improve it if we need to, it's just a script we will run from time to time AFAIK.

In fact, @invidian patch does not work in my laptop (column: invalid option -- 'N' and doing column [opts] <string> is not supported either), so IMHO, it's not worth trying to make it work on all computers. I think we should keep using printf that is simple and works (and we don't really care about columns in this script, at least in the fist iterations)

docs/updating-components.md Outdated Show resolved Hide resolved
docs/updating-components.md Outdated Show resolved Hide resolved
docs/updating-components.md Outdated Show resolved Hide resolved
docs/updating-components.md Outdated Show resolved Hide resolved
docs/updating-components.md Outdated Show resolved Hide resolved
docs/updating-components.md Outdated Show resolved Hide resolved
docs/updating-components.md Outdated Show resolved Hide resolved
docs/updating-components.md Outdated Show resolved Hide resolved
scripts/find-updates.sh Outdated Show resolved Hide resolved
scripts/find-updates.sh Outdated Show resolved Hide resolved
@surajssd surajssd force-pushed the surajssd/find-updates branch from 7b4ca9d to 52103b5 Compare June 1, 2020 13:13
@surajssd surajssd requested review from invidian, johananl and rata June 1, 2020 13:14
@surajssd surajssd force-pushed the surajssd/find-updates branch 3 times, most recently from 60fb999 to f2f6a1b Compare June 1, 2020 15:37
docs/updating-components.md Outdated Show resolved Hide resolved
docs/updating-components.md Outdated Show resolved Hide resolved

To update Calico update the image tags in following files:

- `assets/lokomotive-kubernetes/bootkube/resources/charts/calico/values.yaml`
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't like hardcoding all the paths in this document, but I guess it just describes the reality. Can we add some kind of "at time of writing" note on the top, that those path may change in the future?

@ipochi
Copy link
Member

ipochi commented Jun 2, 2020

I'd like to suggest one exercise before updating a component to a new version. We check the github repository or the concerned component and check if there are any issues reported by the community in the new version before updating in Lokomotive.

@surajssd surajssd force-pushed the surajssd/find-updates branch 2 times, most recently from 2aea51b to 21a010a Compare June 2, 2020 10:43
@surajssd surajssd requested a review from invidian June 2, 2020 12:36
README.md Outdated Show resolved Hide resolved
@surajssd surajssd force-pushed the surajssd/find-updates branch from 21a010a to b904092 Compare June 4, 2020 12:51
@surajssd surajssd requested a review from invidian June 4, 2020 12:51
Copy link
Member

@invidian invidian left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think run-conformance-tests.md should stay in docs directory. Regular user may want to run conformance tests, to make sure their cluster is conformant.

docs/development/updating-components.md Outdated Show resolved Hide resolved
@invidian
Copy link
Member

Ping @surajssd

@surajssd surajssd force-pushed the surajssd/find-updates branch 2 times, most recently from cf6b8a4 to 624449a Compare June 17, 2020 09:58
@surajssd surajssd requested a review from invidian June 22, 2020 09:53
Copy link
Member

@invidian invidian left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems there is one empty commit in this PR. Either last commit should be split and part of it should be added to this commit or it should be removed.

There is also one nit-pick regarding the selected value, which I believe is valuable for the future enhancements of this script.

scripts/find-updates.sh Outdated Show resolved Hide resolved
@surajssd surajssd force-pushed the surajssd/find-updates branch from 624449a to 9dd9923 Compare June 24, 2020 07:37
surajssd added 2 commits June 24, 2020 13:29
This commit adds a script that helps Lokomotive devs to figure out if a
component has a new update.

After figuring out the dev can then manually update those components.

Signed-off-by: Suraj Deshmukh <suraj@kinvolk.io>
Signed-off-by: Suraj Deshmukh <suraj@kinvolk.io>
@surajssd surajssd force-pushed the surajssd/find-updates branch from 9dd9923 to 223e84a Compare June 24, 2020 07:59
Copy link
Member

@invidian invidian left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@surajssd surajssd merged commit e2499b4 into master Jun 24, 2020
@surajssd surajssd deleted the surajssd/find-updates branch June 24, 2020 08:13
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants