keycloak/keycloak-operator

Implement Kubernetes recommended labels

hbjydev opened this issue · 3 comments

Description

Given the following Keycloak resource:

apiVersion: keycloak.org/v1alpha1
kind: Keycloak
metadata:
  name: keycloak-primary
  labels:
    app: keycloak-primary
spec:
  instances: 1
  externalAccess:
    enabled: true

The only label keycloak-primary will get is app=keycloak-primary. This is fine, it's a user-configured label. However, like awx-operator, I feel this operator should also add the standard app.kubernetes.io labels. These cannot entirely be done by the user as far as I am aware, because certain labels (such as app.kubernetes.io/component and app.kubernetes.io/name) would be different depending on which resource is being labelled.

Discussion

No response

Motivation

This ensures that all of the resources generated by keycloak-operator have a standard set of labels that can be used in some external tooling (like a custom dev platform, for example) to manage all of these without needing to try and manually investigate each resource the operator deploys.

Details

For example, the postgres container this creates should be created with the following labels:

app.kubernetes.io/name: postgres
app.kubernetes.io/instance: keycloak-primary-postgres
app.kubernetes.io/version: <version of the postgres db deployed>
app.kubernetes.io/component: database
app.kubernetes.io/part-of: keycloak-primary
app.kubernetes.io/managed-by: keycloak-operator
app.kubernetes.io/created-by: keycloak-operator
app.kubernetes.io/operator-version: 17.0.0

See awx-operator for example

Hi @hbjydev ,
thanks for your interest and sorry for the late reply.
Currently, you are free to add any label you prefer to the resources created by the operator, and, as long as you don't modify the defaults everything will be preserved.

Does this work for you?
Is it just a matter of "good practices" or do you have a specific use case?

Would you be up to submit a PR for this enanchement? (I cannot guarantee it will be merged as this operator is going EOL)

I got a same problem here. I can not add any custom labels except the default: "app".

Thanks (again) for reporting this issue. Keycloak 19 was the last version that included this legacy Operator, and with the release of Keycloak 20 the Operator reached EOL and this repository will be archived, please see our blog post on this topic. If this issue is still valid for the Realm Operator, please re-open it there. Thanks for your understanding. And be sure to check out our new Operator!