New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow K8S node labels to be propagated as Pod annotations #5054
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks really good. 👍 I did a few simple tests and it worked as advertised. I have only a few small comments nothing major. Naming suggestions are totally optional of course.
pkg/controller/elasticsearch/initcontainer/prepare_fs_script_test.go
Outdated
Show resolved
Hide resolved
(applies to anything:) how do we decide whether a feature is specified as an annotation or as a field in the spec? From a user pov, I'm wondering if i'd rather want to do something like this, much higher-level: spec:
allocationAwareness:
enable: true # defaults to false
attribute: "zone" # default
nodeLabel: "topology.kubernetes.io/zone" # default and have the operator automatically handle the Elasticsearch configuration part + the downward API + the environment variable propagation? |
I think one of the reason is that I have the feeling to implement something which might be part of K8S at some point. I'm still hoping for an "official" solution. It feels then easier to deprecate and remove an annotation than a field in the spec (assuming we don't want to maintain a feature which is natively available in K8S). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, I think this will be really useful 🚀
* Allow K8S node labels to be set as pod annotations * Reuse elasticsearch.k8s.elastic.co/config-hash
Fixes #3933
How to test (tested on GKE)
--exposed-node-labels="topology.kubernetes.io/.*,failure-domain.beta.kubernetes.io/.*"
k annotate --overwrite es/elasticsearch-sample eck.k8s.elastic.co/downward-node-labels="topology.kubernetes.io/zone,topology.kubernetes.io/region"
k get pod -l common.k8s.elastic.co/type=elasticsearch -o go-template='{{range .items}}{{.metadata.annotations}}{{printf "\n"}}{{end}}'
To get the logs of the init script you can run
k logs elasticsearch-sample-es-default-0 -c elastic-internal-init-filesystem -f
Misc
elastic-internal-init-filesystem
init container to wait for the annotations to be set.RUNNING
Pods. Theelastic-internal-init-filesystem
init-container should be left untouched as long as the feature is not used on an Elasticsearch resource.Spec.NodeName
has a non-empty value and the relevant conditionPodScheduled
is set toTrue
(see K8S binding code here)Nodes
are not watched.To be addressed in follow up PRs
docs/operating-eck/operating-eck.asciidoc