# Set custom password on Elasticsearch resource

**URL:** <https://discuss.elastic.co/t/set-custom-password-on-elasticsearch-resource/276147>\
**Category:** Elastic Cloud on Kubernetes (ECK)\
**Tags:** elastic-stack-security\
**Created:** [June 16, 2021, 1:17pm UTC](https://discuss.elastic.co/t/set-custom-password-on-elasticsearch-resource/276147 "2021-06-16T13:17:05Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![pkaramol](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/pkaramol/32/22610_2.png) [@pkaramol](https://discuss.elastic.co/u/pkaramol)\
**Post date:** [June 16, 2021, 1:17pm UTC](https://discuss.elastic.co/t/set-custom-password-on-elasticsearch-resource/276147/1 "2021-06-16T13:17:05Z")

</div>

When spinning up a new `Elasticsearch` resource, a new password is created than can be retrieved as follows:

```auto
PASSWORD=$(k get secret clusterName-es-elastic-user -o json | jq -r .data.elastic | base64 -D

```

Is there a way to pre/define hard-code the password so:

a) it does not change upon cluster destruction / recreation

b) it can be rotated on demand?

---

<div class="post-metadata">

**Author:** ![pkaramol](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/pkaramol/32/22610_2.png) [@pkaramol](https://discuss.elastic.co/u/pkaramol)\
**Post date:** [June 16, 2021, 1:46pm UTC](https://discuss.elastic.co/t/set-custom-password-on-elasticsearch-resource/276147/2 "2021-06-16T13:46:34Z")

</div>

Found out the relevant [documentation](https://www.elastic.co/guide/en/cloud-on-k8s/current/k8s-users-and-roles.html#k8s_file_realm).

My question is whether usage of `stringData` in the `k8s` secret is mandatory.

---

<div class="post-metadata">

**Author:** ![michael.morello](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/michael.morello/32/47448_2.png) [@michael.morello](https://discuss.elastic.co/u/michael.morello)\
**Post date:** [June 17, 2021, 8:39am UTC](https://discuss.elastic.co/t/set-custom-password-on-elasticsearch-resource/276147/3 "2021-06-17T08:39:35Z")

</div>

> [@pkaramol](#):
>
> My question is whether usage of `stringData` in the `k8s` secret is mandatory

`stringData` is a K8S trick to avoid base64 encoding when creating a [Secret](https://kubernetes.io/docs/concepts/configuration/secret/#overview-of-secrets):

> If the conversion to base64 string is not desirable, you can choose to specify the `stringData` field instead, which accepts arbitrary strings as values.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [July 15, 2021, 8:40am UTC](https://discuss.elastic.co/t/set-custom-password-on-elasticsearch-resource/276147/4 "2021-07-15T08:40:33Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
