Skip to content

Commit 35f1892

Browse files
committed
ECK: Document annotations and labels propagation
1 parent 02d6b31 commit 35f1892

File tree

2 files changed

+68
-0
lines changed

2 files changed

+68
-0
lines changed
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
---
2+
mapped_pages:
3+
- https://www.elastic.co/guide/en/cloud-on-k8s/current/k8s-customize-pods.html
4+
applies_to:
5+
deployment:
6+
eck: all
7+
products:
8+
- id: cloud-kubernetes
9+
---
10+
11+
# Propagate Labels and Annotations [k8s-propagate-labels-annotations]
12+
13+
Starting with version `3.1.0`, Elastic Cloud on Kubernetes (ECK) supports propagating labels and annotations from the parent resource to the child resources it creates. This feature allows you to apply metadata consistently across all resources managed by ECK, such as Elasticsearch, Kibana, APM Server, Agent, and Beats.
14+
15+
The example below demonstrates how to set up an Elasticsearch cluster with custom labels and annotations that will be propagated to all child resources created by ECK. This can also be applied to Kibana, APM Server, Agent, and Beats resources.
16+
17+
```yaml
18+
# This sample sets up an Elasticsearch cluster with 3 nodes.
19+
apiVersion: elasticsearch.k8s.elastic.co/v1
20+
kind: Elasticsearch
21+
metadata:
22+
annotations:
23+
# Some custom annotations to be propagated to resources created by the operator.
24+
my-annotation1: "my-annotation1-value"
25+
my-annotation2: "my-annotation2-value"
26+
# Instructions for the operator to propagate these annotations and labels to resources it creates.
27+
eck.k8s.alpha.elastic.co/propagate-annotations: "my-annotation1, my-annotation2"
28+
eck.k8s.alpha.elastic.co/propagate-labels: "my-label1, my-label2"
29+
labels:
30+
# Some custom labels to be propagated to resources created by the operator.
31+
my-label1: "my-label1-value"
32+
my-label2: "my-label2-value"
33+
name: elasticsearch-sample
34+
spec:
35+
version: 9.0.0
36+
nodeSets:
37+
- name: default
38+
config:
39+
# this allows ES to run on nodes even if their vm.max_map_count has not been increased, at a performance cost
40+
node.store.allow_mmap: false
41+
count: 1
42+
```
43+
44+
The custom labels and annotations specified in the `metadata` section of the parent resource will be propagated to all child resources created by ECK, such as StatefulSets, Pods, Services, and Secrets. This ensures that all resources have consistent metadata, which can be useful for filtering, monitoring, and managing resources in Kubernetes:
45+
46+
```sh
47+
kubectl get sts,pods,svc -l my-label1=my-label1-value,my-label2=my-label2-value
48+
```
49+
50+
```sh
51+
NAME READY AGE
52+
statefulset.apps/elasticsearch-sample-es-default 1/1 4m10s
53+
54+
NAME READY STATUS RESTARTS AGE
55+
pod/elasticsearch-sample-es-default-0 1/1 Running 0 4m9s
56+
57+
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
58+
service/elasticsearch-sample-es-default ClusterIP None <none> 9200/TCP 4m12s
59+
service/elasticsearch-sample-es-http ClusterIP XX.XX.XX.XX <none> 9200/TCP 4m14s
60+
service/elasticsearch-sample-es-internal-http ClusterIP XX.XX.XX.XX <none> 9200/TCP 4m14s
61+
service/elasticsearch-sample-es-transport ClusterIP None <none> 9300/TCP 4m14s
62+
```
63+
64+
::::{note}
65+
Propagated labels and annotations are not automatically removed when the parent resource is deleted. If you want to remove them, you need to do so manually or use a cleanup script.
66+
::::
67+

deploy-manage/toc.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,7 @@ toc:
223223
- file: deploy/cloud-on-k8s/k8s-kibana-advanced-configuration.md
224224
- file: deploy/cloud-on-k8s/k8s-kibana-plugins.md
225225
- file: deploy/cloud-on-k8s/customize-pods.md
226+
- file: deploy/cloud-on-k8s/propagate-annotations-labels.md
226227
- file: deploy/cloud-on-k8s/manage-compute-resources.md
227228
- file: deploy/cloud-on-k8s/recipes.md
228229
- file: deploy/cloud-on-k8s/connect-to-external-elastic-resources.md

0 commit comments

Comments
 (0)