<p>I want to maintain different configuration for each pod, so planning to fetch properties from spring cloud config based on pod name.</p>

<p>Ex: 
Properties in cloud</p>

<p>PodName1.property1  = "xxx"
PodName2.property1   ="yyy";</p>

<p>Property value will be different for each pod. Planning to fetch properties from cloud ,based on container name  Environment.get("current pod name"+ " propertyName").</p>

<p>So I want to set fixed hostname/pod name </p>

<p>If the above is not possible, is there any alternative ?</p>

<p>You can use <a href="https://kubernetes.io/docs/concepts/workloads/controllers/statefulset/" rel="nofollow noreferrer">statefulsets</a> if you want fixed pod names for your application.
e.g. </p>

<pre><code>apiVersion: apps/v1
kind: StatefulSet
metadata:
  name: web # this will be used as prefix in pod name 
spec:
  serviceName: "nginx"
  replicas: 2 # specify number of pods that should be running
  selector:
    matchLabels:
      app: nginx
  template:
    metadata:
      labels:
        app: nginx
    spec:
      containers:
      - name: nginx
        image: k8s.gcr.io/nginx-slim:0.8
        ports:
        - containerPort: 80
          name: web
</code></pre>

<p>This template will create 2 pods of nginx in default namespace with names as following:</p>

<pre><code>kubectl get pods -l app=nginx
NAME      READY     STATUS    RESTARTS   AGE
web-0     1/1       Running   0          1m
web-1     1/1       Running   0          1m
</code></pre>

<p>A basic example can be found <a href="https://kubernetes.io/docs/tutorials/stateful-application/basic-stateful-set/" rel="nofollow noreferrer">here</a>.</p>
