Page MenuHomePhabricator

Use common k8s labels in tools-webservice
Closed, ResolvedPublic

Description

At T265780#6572850 we decided to use k8s common labels for the new buildpack k8s deployments.

While we will likely need to continue supporting the old tools.wmflabs.org/webservice labels (unless we redeploy all the current webservices to force them to migrate), but it would be good to have it start using the new labels just to be consistent.

app.kubernetes.io/component: web
app.kubernetes.io/managed-by: webservice

Event Timeline

Restricted Application added a subscriber: Aklapper. · View Herald Transcript

unless we redeploy all the current webservices to force them to migrate

According to https://kubernetes.io/docs/concepts/overview/working-with-objects/labels/ "Labels can be attached to objects at creation time and subsequently added and modified at any time" so we should be able to just relabel existing deployments, services, ingresses and pods.

Yeah, you can do the equivalent of (or an actual) kubectl patch on a live object. Some things resist patch changes, but I'm not surprised labels don't.

So I think running:

kubectl label --selector tools.wmflabs.org/webservice=true deployment app.kubernetes.io/component=web app.kubernetes.io/managed-by=webservice
kubectl label --selector tools.wmflabs.org/webservice=true ingress app.kubernetes.io/component=web app.kubernetes.io/managed-by=webservice
kubectl label --selector tools.wmflabs.org/webservice=true pod app.kubernetes.io/component=web app.kubernetes.io/managed-by=webservice
kubectl label --selector tools.wmflabs.org/webservice=true service app.kubernetes.io/component=web app.kubernetes.io/managed-by=webservice

as clusteradmin should do it. And then right afterward we'd push out a new webservice package (patch still to be written).

Change 637813 had a related patch set uploaded (by Legoktm; owner: Legoktm):
[operations/software/tools-webservice@master] Use common k8s labels

https://gerrit.wikimedia.org/r/637813

We should also label any interactive pods that might happen to be open.

And then right afterward we'd push out a new webservice package (patch still to be written).

And then we should probably re-run the kubectl label ... commands in case someone launched a new webservice in between that first command run and the upgrading of the webservice package.

Proposed a script on the patch that seems sensible enough. My test run of it (that doesn't run the label commands, only gets) takes a good while (since I'm only selecting objects that have the existing labels), but it finishes. I'll plan to run it whenever the patch is fully deployed to tools.

Change 637813 merged by jenkins-bot:

[operations/software/tools-webservice@master] Use common k8s labels

https://gerrit.wikimedia.org/r/637813