<p>I want to make a folder called synonyms inside the Elasticsearch pod under this location<br />
/usr/share/elasticsearch/  using my deployment YAML file , what changes should I do so that I can create one folder.</p>
<p>here is my deployment manifest file</p>
<pre><code>apiVersion: apps/v1
kind: Deployment
metadata:
  name: elasticsearch
  namespace: elk
spec:
  replicas: 1
  selector:
    matchLabels:
      app: elasticsearch
  template:
    metadata:
      labels:
        app: elasticsearch
    spec:
      affinity:
        nodeAffinity:
          requiredDuringSchedulingIgnoredDuringExecution:
            nodeSelectorTerms:
            - matchExpressions:
              - key: app-elk
                operator: In
                values:
                - &quot;elastic-tomcat&quot;
      containers:
      - name: elasticsearch
        image: docker.elastic.co/elasticsearch/elasticsearch:7.17.5
        imagePullPolicy: Always
        resources:
            requests:
              memory: 1Gi
        ports:
        - containerPort: 9200
          protocol: TCP
          name: rest
        - containerPort: 9300
          protocol: TCP
          name: inter-node
        volumeMounts:
        - name: data-volume
          mountPath: /usr/share/elasticsearch/data  
        env:
          - name: cluster.name
            value: elasticsearch-cluster
          - name: node.name
            valueFrom:
              fieldRef:
                fieldPath: metadata.name
          - name: discovery.seed_hosts
            value: &quot;elasticsearch-cluster-0.elasticsearch&quot;
          - name: cluster.initial_master_nodes
            value: &quot;elasticsearch-cluster-0&quot;
          - name: ES_JAVA_OPTS
            value: &quot;-Xms512m -Xmx512m&quot;
          - name: network.host
            value: &quot;0.0.0.0&quot;
      initContainers:
      - name: fix-permissions
        image: busybox
        command: [&quot;sh&quot;, &quot;-c&quot;, &quot;chown -R 1000:1000 /usr/share/elasticsearch/data&quot;]
        securityContext:
          privileged: true
        volumeMounts:
        - name: data-volume
          mountPath: /usr/share/elasticsearch/data
      - name: increase-vm-max-map
        image: busybox
        command: [&quot;sysctl&quot;, &quot;-w&quot;, &quot;vm.max_map_count=262144&quot;]
        securityContext:
          privileged: true
      - name: increase-fd-ulimit
        image: busybox
        command: [&quot;sh&quot;, &quot;-c&quot;, &quot;ulimit -n 65536&quot;]
        securityContext:
          privileged: true
      volumes:
        - name: data-volume
          persistentVolumeClaim:
            claimName: elasticsearch-pvc  # Create a PVC for data storage
</code></pre>
<p>please help , the platform I am using google kubernetes engine.</p>

Nishit Kumar
<p>You can create the folder using <strong>init container</strong> with <strong>command</strong> that you are running and utilize it as per requirement later with Main container.</p>
<p>Also, you are running <strong>multiple different Init containers</strong> you can keep one container with multiple commands</p>
<pre><code>  dnsPolicy: ClusterFirst
  initContainers:
  - command:
    - sh
    - -c
    - chown -R 1000:1000 /usr/share/elasticsearch/data
    - mkdir /usr/share/elasticsearch/XYZ
    - sysctl -w vm.max_map_count=262144
    - chmod 777 /usr/share/elasticsearch/data
    - chomod 777 /usr/share/elasticsearch/data/node
    - chmod g+rwx /usr/share/elasticsearch/data
    - chgrp 1000 /usr/share/elasticsearch/data
    image: busybox:1.29.2
    imagePullPolicy: IfNotPresent
    name: set-dir-owner
    resources: {}
    securityContext:
      privileged: true
    terminationMessagePath: /dev/termination-log
    terminationMessagePolicy: File
    volumeMounts:
    - mountPath: /usr/share/elasticsearch/data
      name: elasticsearch-data
  restartPolicy: Always
</code></pre>
