Hi All,
I have deployed Cassandra operator and trying to add custom labels in CassandraDatacenter yaml, where statefulset/Cassandra cluster should use those labels
can you help me in adding custom labels in example-cassdc-full.yaml .
Bringing together the Apache Cassandra experts from the community and DataStax.
Want to learn? Have a question? Want to share your expertise? You are in the right place!
Not sure where to begin? Getting Started
Hi All,
I have deployed Cassandra operator and trying to add custom labels in CassandraDatacenter yaml, where statefulset/Cassandra cluster should use those labels
can you help me in adding custom labels in example-cassdc-full.yaml .
Hi @phaniharsha It is possible to do what you want using the .spec.podTemplateSpec
property. Here is an example:
apiVersion: cassandra.datastax.com/v1beta1 kind: CassandraDatacenter metadata: name: dc1 spec: clusterName: custom-labels-example serverType: cassandra serverVersion: "3.11.10" dockerImageRunsAsCassandra: true serverImage: datastax/cassandra-mgmtapi-3_11_10:v0.1.23 managementApiAuth: insecure: {} size: 1 storageConfig: cassandraDataVolumeClaimSpec: storageClassName: persistent-storage accessModes: - ReadWriteOnce resources: requests: storage: 5Gi podTemplateSpec: metadata: labels: foo: bar
This will result in the label foo=bar
being added to the pods in the StatefulSet.
The podTemplateSpec
property is really powerful and flexible. It is powerful in that it allows you to override or custom define quite a bit.
It is flexible because it has merge behavior. In other words, you can add something for the cassandra container and cass-operator will merge that into the StatefulSet as opposed to just overwriting it.
I hope that helps :)
Cheers
John
Thanks for the response
I have tried adding labels under podTemplateSpec in CassandraDatacenter but no luck, labels are not being added to the pods in statefulset. am i missing something? can you please help me.
storageConfig: cassandraDataVolumeClaimSpec: storageClassName: { { .Values.cr.storageConfig.storageClassName }} accessModes: - { { .Values.cr.storageConfig.accessMode }} resources: requests: storage: { { .Values.cr.storageConfig.storage }} podTemplateSpec: metadata: labels: foo: bar
By describing pod result as follow:
By describing sts result as follow:
Thanks,
Phani
Hi @phaniharsha
Is the code that you shared from a Helm chart template (or something similar)? Maybe it is not generating the CassandraDatacenter spec as expected. Let's see what it looks like. Can you please share the output of `kubectl get cassandradatacenter dc1 -o yaml`.
Yes, you can add custom labels.
For example:
metadata: name: dc1 labels: label_1: value_1 label_2: value_2
Is this what you're after? If not, please let us know what outcome you're after or what problem you're trying to solve so we can provide a better answer. Cheers!
Hi Eric, Thanks for the response.
I am trying to add some extra labels/custom labels in statefulset through Cassandradatacenter
I tried adding labels under metadata object in cassandradatacenter but same custom labels are not being taken by statefulset instead i am only seeing pre-defined labels or pods, my goal is, statefulset or pods should also take custom labels along with predefined labels.
Cassandradatacenter:
dc1:
Statefulset:
6 People are following this question.
Custom labels do not propagate to pods in statefulset
DSE includes a version of Jackson-databind package identified as vulnerable to RCE in CVE-2020-8840
When is the Kubernetes operator available for DSE Graph, Analytics and Search?
Does cass-operator generate certificates by default?
Is it possible to scale down a cluster with cass-operator on Kubernetes?
DataStax Enterprise is powered by the best distribution of Apache Cassandra ™
© 2021 DataStax, Titan, and TitanDB are registered trademarks of DataStax, Inc. and its subsidiaries in the United States and/or other countries.
Apache, Apache Cassandra, Cassandra, Apache Tomcat, Tomcat, Apache Lucene, Lucene, Apache Solr, Apache Hadoop, Hadoop, Apache Spark, Spark, Apache TinkerPop, TinkerPop, Apache Kafka and Kafka are either registered trademarks or trademarks of the Apache Software Foundation or its subsidiaries in Canada, the United States and/or other countries.
Privacy Policy Terms of Use