<p>If I understand you question clearly, you're trying to mount <code>/jaeger-data</code> inside the elastic-search container or pod. To achieve this, what you can do is put this mount details inside the statefulset yaml of the Kubernetes pod for elastic-search. Using the volumeMounts inside the statefulset, you will not need to ssh or exec inside the container or bother about the change or container ID for each pod restart/recreation. You can use the below example as a reference for your <strong>PVC</strong> and <strong>volumeMounts</strong>, just edit your statefulset using <code>kubectl edit sts elasticsearch-0 -n default</code>, this will open an editor and you can replace you PVC details in the below yaml and append and save and exit will recreate your pod and attach the mountpoint:</p>

<pre><code>          volumeMounts:
            - mountPath: /es-storage
              name: jaeger-data
  volumeClaimTemplates:
  - metadata:
      name: es-storage
    spec:
      accessModes:
      - ReadWriteOnce
      resources:
        requests:
          storage: 100Gi
</code></pre>

<ul>
<li>Container ID will change with each recreation of containers;</li>
<li>If in case you need to exec into the container, the better way is to use <code>kubectl exec -ti &lt;pod-name&gt; -n &lt;namespace&gt; bash</code> to exec into the container from any of the master node(similar command as docker exec, just replace pod-name and namespace) or from your local laptop if you have kubeconfig configured.</li>
<li>Using <strong>Service</strong>, you can expose this application on a particular port, Kubernetes creates an abstraction and itself takes care of the change of pod IP</li>
</ul>

CC BY-SA 4.0
2019-01-16T13:15:29.077Z
2019-01-16T13:15:29.077Z
rebelution
<p>I have a kubernetes cluster on GCP, in which I have a elasticsearch service.
I  have a <code>elasticsearch-0</code> pod which is running a docker container of elasticsearch.</p>

<pre><code>~ ❯❯❯ kubectl describe pod elasticsearch-0
Name:           elasticsearch-0
Namespace:      default
Node:           gke-jaeger-persistent-st-default-pool-xxxxx-phvx/10.166.0.4
Start Time:     Mon, 07 Jan 2019 14:21:19 +0100
Labels:         app=jaeger-elasticsearch
                controller-revision-hash=elasticsearch-8684f69799
                jaeger-infra=elasticsearch-replica
                statefulset.kubernetes.io/pod-name=elasticsearch-0
Annotations:    kubernetes.io/limit-ranger: LimitRanger plugin set: cpu request for container elasticsearch
Status:         Running
IP:             10.36.2.27
Controlled By:  StatefulSet/elasticsearch
Containers:
  elasticsearch:
    Container ID:  docker://5212b8c223401355bd29a5639caea5097074a8a8101ceb10300f76465e4a6536
    Image:         docker.elastic.co/elasticsearch/elasticsearch:5.6.0
    Image ID:      docker-pullable://docker.elastic.co/elasticsearch/elasticsearch@sha256:f95e7d4256197a9bb866b166d9ad37963dc7c5764d6ae6400e551f4987a659d7
    Port:          &lt;none&gt;
    Host Port:     &lt;none&gt;
    Command:
</code></pre>

<p>And I need access to the node which manage my pod in order to get the container ID of my elasticsearch container. </p>

<p>I get the name of my instances with <code>gcloud compute instances list</code> and enter via  <code>gcloud compute ssh &lt;node-name&gt; --zone=&lt;zone-name&gt;</code> command and I've enter to the elasticsearch docker container with root privileges <code>docker exec -it -u root containerID bash</code> (following these <a href="https://stackoverflow.com/questions/42793382/exec-commands-on-kubernetes-pods-with-root-access">steps</a>) </p>

<p>I need perform this because I need add a new mountPath named  <code>/jaeger-data</code> in order to associate it to a persistent volume claim that I have prepared.</p>

<p>I enter to my docker container and create the mountPath</p>

<pre><code>[root@elasticsearch-0 elasticsearch]# mkdir /jaeger-data
[root@elasticsearch-0 elasticsearch]#
</code></pre>

<p>But I can see that I am disconnecting continously from my docker container because the <code>containerID</code> is changed of a continous way. 
Each time that I enter to my node to get my <code>containerID</code> with <code>docker ps -a</code> command, this <code>containerID</code> is different and when enter to the new container making use of the new ID, my <code>/jaeger-data</code> mountPath is not found, this mean that there isn't, may be because I am entering to a new container ...</p>

<p>What is the reason to my containerID change all time?
Is this related with Kubernetes node that contain my pod which have my elasticsearch docker container?</p>

<p>Is related with the <strong><a href="https://kubernetes.io/docs/concepts/services-networking/service/" rel="nofollow noreferrer">Service</a></strong> situation?</p>

<blockquote>
  <p>Kubernetes Pods are mortal. They are born and when they die, they are not resurrected. ReplicaSets in particular create and destroy Pods dynamically (e.g. when scaling out or in). While each Pod gets its own IP address, even those IP addresses cannot be relied upon to be stable over time. This leads to a problem: if some set of Pods (let’s call them backends) provides functionality to other Pods (let’s call them frontends) inside the Kubernetes cluster, how do those frontends find out and keep track of which backends are in that set?</p>
  
  <p>Enter Services.</p>
</blockquote>

<p>How to can I address this situation? </p>

<p>I need create my mountPath in order to associate it to my <code>elasticsearch-0</code> pod configuration</p>

<docker><kubernetes>
Entering to docker container of my elasticsearch google kubernetes pod - CONTAINER ID is changing
bgarcial
# Entering to docker container of my elasticsearch google kubernetes pod - CONTAINER ID is changing

(Asked by: username_0 on 2019-01-07)

I have a kubernetes cluster on GCP, in which I have a elasticsearch service.
I  have a elasticsearch-0 pod which is running a docker container of elasticsearch.
~ ❯❯❯ kubectl describe pod elasticsearch-0
Name:           elasticsearch-0
Namespace:      default
Node:           gke-jaeger-persistent-st-default-pool-xxxxx-phvx/10.166.0.4
Start Time:     Mon, 07 Jan 2019 14:21:19 +0100
Labels:         app=jaeger-elasticsearch
                controller-revision-hash=elasticsearch-8684f69799
                jaeger-infra=elasticsearch-replica
                statefulset.kubernetes.io/pod-name=elasticsearch-0
Annotations:    kubernetes.io/limit-ranger: LimitRanger plugin set: cpu request for container elasticsearch
Status:         Running
IP:             10.36.2.27
Controlled By:  StatefulSet/elasticsearch
Containers:
  elasticsearch:
    Container ID:  docker://5212b8c223401355bd29a5639caea5097074a8a8101ceb10300f76465e4a6536
    Image:         docker.elastic.co/elasticsearch/elasticsearch:5.6.0
    Image ID:      docker-pullable://docker.elastic.co/elasticsearch/elasticsearch@sha256:f95e7d4256197a9bb866b166d9ad37963dc7c5764d6ae6400e551f4987a659d7
    Port:          
    Host Port:     
    Command:

And I need access to the node which manage my pod in order to get the container ID of my elasticsearch container. 
I get the name of my instances with gcloud compute instances list and enter via  gcloud compute ssh  --zone= command and I've enter to the elasticsearch docker container with root privileges docker exec -it -u root containerID bash (following these steps) 
I need perform this because I need add a new mountPath named  /jaeger-data in order to associate it to a persistent volume claim that I have prepared.
I enter to my docker container and create the mountPath
[root@elasticsearch-0 elasticsearch]# mkdir /jaeger-data
[root@elasticsearch-0 elasticsearch]#

But I can see that I am disconnecting continously from my docker container because the containerID is changed of a continous way. 
Each time that I enter to my node to get my containerID with docker ps -a command, this containerID is different and when enter to the new container making use of the new ID, my /jaeger-data mountPath is not found, this mean that there isn't, may be because I am entering to a new container ...
What is the reason to my containerID change all time?
Is this related with Kubernetes node that contain my pod which have my elasticsearch docker container?
Is related with the Service situation?

Kubernetes Pods are mortal. They are born and when they die, they are not resurrected. ReplicaSets in particular create and destroy Pods dynamically (e.g. when scaling out or in). While each Pod gets its own IP address, even those IP addresses cannot be relied upon to be stable over time. This leads to a problem: if some set of Pods (let’s call them backends) provides functionality to other Pods (let’s call them frontends) inside the Kubernetes cluster, how do those frontends find out and keep track of which backends are in that set?
Enter Services.

How to can I address this situation? 
I need create my mountPath in order to associate it to my elasticsearch-0 pod configuration

**Tags:** docker, kubernetes


---

## 1 answers

### Answer by username_1 on 2019-01-16. Score: 1 | Accepted answer

If I understand you question clearly, you're trying to mount /jaeger-data inside the elastic-search container or pod. To achieve this, what you can do is put this mount details inside the statefulset yaml of the Kubernetes pod for elastic-search. Using the volumeMounts inside the statefulset, you will not need to ssh or exec inside the container or bother about the change or container ID for each pod restart/recreation. You can use the below example as a reference for your PVC and volumeMounts, just edit your statefulset using kubectl edit sts elasticsearch-0 -n default, this will open an editor and you can replace you PVC details in the below yaml and append and save and exit will recreate your pod and attach the mountpoint:
          volumeMounts:
            - mountPath: /es-storage
              name: jaeger-data
  volumeClaimTemplates:
  - metadata:
      name: es-storage
    spec:
      accessModes:
      - ReadWriteOnce
      resources:
        requests:
          storage: 100Gi


Container ID will change with each recreation of containers;
If in case you need to exec into the container, the better way is to use kubectl exec -ti  -n  bash to exec into the container from any of the master node(similar command as docker exec, just replace pod-name and namespace) or from your local laptop if you have kubeconfig configured.
Using Service, you can expose this application on a particular port, Kubernetes creates an abstraction and itself takes care of the change of pod IP


---

