Skip to content

Commit

Permalink
config: add app.kubernetes.io/component label (#794)
Browse files Browse the repository at this point in the history
* config: add `app.kubernetes.io/component` label

following the best practices when it comes to labelling objects (see
[1]), by making use of the recommended `app.kubernetes.io/component`,
we're able to clearly identify those objects that are part of
cartographer (useful for any tool that might want to do some form of
matching against anything cartographer-related, e.g., getting rid of all
of them based on matching on such label).

the approach I took here is to make use of ytt overlays in order to add
the label to all components _except_ the Namespace.

[1]: https://kubernetes.io/docs/concepts/overview/working-with-objects/common-labels/

Co-authored-by: Scott Andrews <andrewssc@vmware.com>
Co-authored-by: Emily Johnson <51918476+emmjohnson@users.noreply.github.com>
  • Loading branch information
3 people committed Apr 6, 2022
1 parent e2d47bd commit b059780
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
23 changes: 23 additions & 0 deletions hack/overlays/component-labels.yaml
@@ -0,0 +1,23 @@
# Copyright 2021 VMware
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

#@ load("@ytt:overlay", "overlay")

#@overlay/match by=overlay.not_op(overlay.subset({"kind":"Namespace"})),expects="1+"
---
metadata:
#@overlay/match missing_ok=True
labels:
#@overlay/match missing_ok=True
app.kubernetes.io/component: cartographer
1 change: 1 addition & 0 deletions hack/release.sh
Expand Up @@ -74,6 +74,7 @@ generate_release() {
mkdir -p ./release
ytt --ignore-unknown-comments -f ./config \
-f ./hack/overlays/webhook-configuration.yaml \
-f ./hack/overlays/component-labels.yaml \
--data-value version=$RELEASE_VERSION |
KO_DOCKER_REPO=$REGISTRY ko resolve -B -f- > \
./release/cartographer.yaml
Expand Down

0 comments on commit b059780

Please sign in to comment.