For each branch I deploy a review app on Kubernetes, consisting of, let's say, a web server, a PHP server and a database. As far as I understand it is convention to use separate deployments for those services and it allows me to prepare the database in an init container of the PHP deployment.
However, I now have a number of seemingly unrelated deployments, only "grouped" by their similar name:
my-namespace
├── issue-foo-web
├── issue-foo-php
├── issue-foo-db
├── issue-bar-web
├── issue-bar-php
└── issue-bar-db
Is there a native/recommended way in Kubernetes to group deployments for one "app" or "installation" allowing for example to delete or health-check the whole group?
You should use Kubernetes labels to tag your resources. There are a number of recommended labels that you can use for this.
apiVersion: apps/v1
kind: Deployment
metadata:
labels:
app.kubernetes.io/name: mysql
app.kubernetes.io/instance: wordpress-abcxzy
app.kubernetes.io/version: "5.7.21"
app.kubernetes.io/component: database
app.kubernetes.io/part-of: wordpress
app.kubernetes.io/managed-by: helm