Project: MongoDB: support setting pod and statefulset labels

Created on 6 Jun 2019  路  7Comments  路  Source: kubedb/project

Based on both the documentation and some experimentation it seems that you cannot currently set the labels for either the stateful set or pods created by KubeDB. Pod labeling is very important to us so this is a major pain point.

feature_request

Most helpful comment

Issue-Label Bot is automatically applying the label feature_request to this issue, with a confidence of 0.66. Please mark this comment with :thumbsup: or :thumbsdown: to give our bot feedback!

Links: app homepage, dashboard and code for this bot.

All 7 comments

Issue-Label Bot is automatically applying the label feature_request to this issue, with a confidence of 0.66. Please mark this comment with :thumbsup: or :thumbsdown: to give our bot feedback!

Links: app homepage, dashboard and code for this bot.

statefulset labels can be set like this.

apiVersion: kubedb.com/v1alpha1
kind: MongoDB
metadata:
  name: mongo-sh
  namespace: demo
  labels:
    mongodb: mg
spec:
  version: 3.6-v4
  shardTopology:
    configServer:
      replicas: 3
      storage:
        resources:
          requests:
            storage: 1Gi
        storageClassName: standard
    mongos:
      replicas: 2
      strategy:
        type: RollingUpdate
    shard:
      replicas: 3
      shards: 3
      storage:
        resources:
          requests:
            storage: 1Gi
        storageClassName: standard
  updateStrategy:
    type: RollingUpdate
  storageType: Durable
  terminationPolicy: WipeOut

Here, label mongodb: mg is forwarded to statefulsets.

Interesting... is that documented somewhere?

I guess I assumed you had to put them in the spec.podTemplate.controller section since that's where the annotations go (and spec.podTemplate.metadata for pods). But any labels placed there are ignored.

Is there a way to set pod labels?

Also searching a way to label pods via crd (Istio needs app&version labels). @the-redback is it possible?

@BufferUnderflower, a bit new to k8s, istio (and even newer to kubedb). Why does Istio need app and version label? After seeing your comment I reviewed the docs and this was recommended https://istio.io/docs/setup/additional-setup/requirements/. Is there something else this is used for?

I am currently having issues (with Postgres) and I am wondering if it's related to labelling

Envoy proxy is NOT ready: 2 errors occurred:
...
envoy missing listener for inbound application port: 5432

Hi The labels are important for metrics and monitor, tool like kiali will visualize you mesh and grouped the kubedb clusters as an app, In addition it will help to add "-" before the port name in the clusters services (istio pod and services)

This is also required for Postgres, the same issue exists there. Annotations are taken over, but pod labels are explicitly set to calculated values.
I suggest, that all podTemplate.metadata.labels are included that do not violate the kubed namespace and are not already in OffshootSelector() (from postgres operator, may vary for mongodb)

Was this page helpful?
0 / 5 - 0 ratings