<p>I've created an elasticsearch service to apply it like backend to jaeger tracing, using this <a href="https://github.com/jaegertracing/jaeger-kubernetes#backing-storage" rel="nofollow noreferrer">guide</a>, all over Kubernetes GCP cluster. </p>

<p>I have the elasticsearch service:</p>

<pre><code>~/w/jaeger-elasticsearch ❯❯❯ kubectl get service elasticsearch
NAME            TYPE        CLUSTER-IP   EXTERNAL-IP   PORT(S)             AGE
elasticsearch   ClusterIP   None         &lt;none&gt;        9200/TCP,9300/TCP   8m
~/w/jaeger-elasticsearch ❯❯❯
</code></pre>

<p>And their respective pod called elasticsearch-0</p>

<pre><code>~/w/jaeger-elasticsearch ❯❯❯ kubectl get pods
NAME                              READY   STATUS    RESTARTS   AGE
elasticsearch-0                   1/1     Running   0          37m
jaeger-agent-cnw9m                1/1     Running   0          2h
jaeger-agent-dl5n9                1/1     Running   0          2h
jaeger-agent-zzljk                1/1     Running   0          2h
jaeger-collector-9879cd76-fvpz4   1/1     Running   0          2h
jaeger-query-5584576487-dzqkd     1/1     Running   0          2h
~/w/jaeger-elasticsearch ❯❯❯ kubectl get pod elasticsearch-0
NAME              READY   STATUS    RESTARTS   AGE
elasticsearch-0   1/1     Running   0          38m
~/w/jaeger-elasticsearch ❯❯❯ 
</code></pre>

<p>I've enter to my pod configuration on GCP, and I can see that my elasticsearch-0 pod have limited resources:</p>

<pre><code>apiVersion: v1
kind: Pod
metadata:
  annotations:
    kubernetes.io/limit-ranger: 'LimitRanger plugin set: cpu request for container
      elasticsearch'
  creationTimestamp: 2019-01-03T09:11:10Z
  generateName: elasticsearch-
</code></pre>

<p>And then, I want to assign it specific CPU request and CPU limit <a href="https://kubernetes.io/docs/tasks/configure-pod-container/assign-cpu-resource/#specify-a-cpu-request-and-a-cpu-limit" rel="nofollow noreferrer">according to the documentation</a>, and then, I proceed to modufy the pod manifest, adding the following directives:</p>

<p><code>- cpu "2"</code> in the <code>args</code> section:</p>

<pre><code>args:
    - -cpus
    - "2"
</code></pre>

<p>And I am including a <code>resources:requests</code> field in the container resource, in order to specify a request of 0.5 CPU and  I've include a <code>resources:limits</code> in order to specify a CPU limit of this way: </p>

<pre><code>  limits:
    cpu: "1"
  requests:
    cpu: "0.5"
</code></pre>

<p>My complete pod manifest is this (See numerals 1,2,3,4 and 5 numerals commented with # symbol):</p>

<pre><code>apiVersion: v1
kind: Pod
metadata:
  annotations:
    kubernetes.io/limit-ranger: 'LimitRanger plugin set: cpu request for container
      elasticsearch'
  creationTimestamp: 2019-01-03T09:11:10Z
  generateName: elasticsearch-
  labels:
    app: jaeger-elasticsearch
    controller-revision-hash: elasticsearch-8684f69799
    jaeger-infra: elasticsearch-replica
    statefulset.kubernetes.io/pod-name: elasticsearch-0
  name: elasticsearch-0
  namespace: default
  ownerReferences:
  - apiVersion: apps/v1
    blockOwnerDeletion: true
    controller: true
    kind: StatefulSet
    name: elasticsearch
    uid: 86578784-0f36-11e9-b8b1-42010aa60019
  resourceVersion: "2778"
  selfLink: /api/v1/namespaces/default/pods/elasticsearch-0
  uid: 82d3be2f-0f37-11e9-b8b1-42010aa60019
spec:
  containers:
  - args:
    - -Ehttp.host=0.0.0.0
    - -Etransport.host=127.0.0.1
    - -cpus # 1
    - "2" # 2
    command:
    - bin/elasticsearch
    image: docker.elastic.co/elasticsearch/elasticsearch:5.6.0
    imagePullPolicy: Always
    name: elasticsearch
    readinessProbe:
      exec:
        command:
        - curl
        - --fail
        - --silent
        - --output
        - /dev/null
        - --user
        - elastic:changeme
        - localhost:9200
      failureThreshold: 3
      initialDelaySeconds: 5
      periodSeconds: 5
      successThreshold: 1
      timeoutSeconds: 4
    resources: # 3
      limits:
        cpu: "1" # 4
      requests:
        cpu: "0.5" # 5
        # container has a request of 0.5  CPU 
        #cpu: 100m
    terminationMessagePath: /dev/termination-log
    terminationMessagePolicy: File
    volumeMounts:
    - mountPath: /data
      name: data
    - mountPath: /var/run/secrets/kubernetes.io/serviceaccount
      name: default-token-96vwj
      readOnly: true
  dnsPolicy: ClusterFirst
  hostname: elasticsearch-0
  nodeName: gke-jaeger-persistent-st-default-pool-81004235-h8xt
  restartPolicy: Always
  schedulerName: default-scheduler
  securityContext: {}
  serviceAccount: default
  serviceAccountName: default
  subdomain: elasticsearch
  terminationGracePeriodSeconds: 30
  tolerations:
  - effect: NoExecute
    key: node.kubernetes.io/not-ready
    operator: Exists
    tolerationSeconds: 300
  - effect: NoExecute
    key: node.kubernetes.io/unreachable
    operator: Exists
    tolerationSeconds: 300
  volumes:
  - emptyDir: {}
    name: data
  - name: default-token-96vwj
    secret:
      defaultMode: 420
      secretName: default-token-96vwj
status:
  conditions:
  - lastProbeTime: null
    lastTransitionTime: 2019-01-03T09:11:10Z
    status: "True"
    type: Initialized
  - lastProbeTime: null
    lastTransitionTime: 2019-01-03T09:11:40Z
    status: "True"
    type: Ready
  - lastProbeTime: null
    lastTransitionTime: 2019-01-03T09:11:10Z
    status: "True"
    type: PodScheduled
  containerStatuses:
  - containerID: docker://46eb2c664f947a2a0a35ac7799b04c77756aef0a9935855c2dadcf959bd27030
    image: docker.elastic.co/elasticsearch/elasticsearch:5.6.0
    imageID: docker-pullable://docker.elastic.co/elasticsearch/elasticsearch@sha256:f95e7d4256197a9bb866b166d9ad37963dc7c5764d6ae6400e551f4987a659d7
    lastState: {}
    name: elasticsearch
    ready: true
    restartCount: 0
    state:
      running:
        startedAt: 2019-01-03T09:11:13Z
  hostIP: 10.166.0.2
  phase: Running
  podIP: 10.36.0.10
  qosClass: Burstable
  startTime: 2019-01-03T09:11:10Z
</code></pre>

<p>But when I apply my pod manifest file, I get the following output:</p>

<pre><code>Warning: kubectl apply should be used on resource created by either kubectl create --save-config or kubectl apply
Error from server (Conflict): error when applying patch:
.
.
.
for: "elasticsearch-0.yaml": Operation cannot be fulfilled on pods "elasticsearch-0": the object has been modified; please apply your changes to the latest version and try again
~/w/jaeger-elasticsearch ❯❯❯
</code></pre>

<p>The complete output of my <code>kubectl apply</code> command is this:</p>

<pre><code>~/w/jaeger-elasticsearch ❯❯❯ kubectl apply -f elasticsearch-0.yaml
Warning: kubectl apply should be used on resource created by either kubectl create --save-config or kubectl apply
Error from server (Conflict): error when applying patch:
{"metadata":{"annotations":{"kubectl.kubernetes.io/last-applied-configuration":"{\"apiVersion\":\"v1\",\"kind\":\"Pod\",\"metadata\":{\"annotations\":{\"kubernetes.io/limit-ranger\":\"LimitRanger plugin set: cpu request for container elasticsearch\"},\"creationTimestamp\":\"2019-01-03T09:11:10Z\",\"generateName\":\"elasticsearch-\",\"labels\":{\"app\":\"jaeger-elasticsearch\",\"controller-revision-hash\":\"elasticsearch-8684f69799\",\"jaeger-infra\":\"elasticsearch-replica\",\"statefulset.kubernetes.io/pod-name\":\"elasticsearch-0\"},\"name\":\"elasticsearch-0\",\"namespace\":\"default\",\"ownerReferences\":[{\"apiVersion\":\"apps/v1\",\"blockOwnerDeletion\":true,\"controller\":true,\"kind\":\"StatefulSet\",\"name\":\"elasticsearch\",\"uid\":\"86578784-0f36-11e9-b8b1-42010aa60019\"}],\"resourceVersion\":\"2778\",\"selfLink\":\"/api/v1/namespaces/default/pods/elasticsearch-0\",\"uid\":\"82d3be2f-0f37-11e9-b8b1-42010aa60019\"},\"spec\":{\"containers\":[{\"args\":[\"-Ehttp.host=0.0.0.0\",\"-Etransport.host=127.0.0.1\",\"-cpus\",\"2\"],\"command\":[\"bin/elasticsearch\"],\"image\":\"docker.elastic.co/elasticsearch/elasticsearch:5.6.0\",\"imagePullPolicy\":\"Always\",\"name\":\"elasticsearch\",\"readinessProbe\":{\"exec\":{\"command\":[\"curl\",\"--fail\",\"--silent\",\"--output\",\"/dev/null\",\"--user\",\"elastic:changeme\",\"localhost:9200\"]},\"failureThreshold\":3,\"initialDelaySeconds\":5,\"periodSeconds\":5,\"successThreshold\":1,\"timeoutSeconds\":4},\"resources\":{\"limits\":{\"cpu\":\"1\"},\"requests\":{\"cpu\":\"0.5\"}},\"terminationMessagePath\":\"/dev/termination-log\",\"terminationMessagePolicy\":\"File\",\"volumeMounts\":[{\"mountPath\":\"/data\",\"name\":\"data\"},{\"mountPath\":\"/var/run/secrets/kubernetes.io/serviceaccount\",\"name\":\"default-token-96vwj\",\"readOnly\":true}]}],\"dnsPolicy\":\"ClusterFirst\",\"hostname\":\"elasticsearch-0\",\"nodeName\":\"gke-jaeger-persistent-st-default-pool-81004235-h8xt\",\"restartPolicy\":\"Always\",\"schedulerName\":\"default-scheduler\",\"securityContext\":{},\"serviceAccount\":\"default\",\"serviceAccountName\":\"default\",\"subdomain\":\"elasticsearch\",\"terminationGracePeriodSeconds\":30,\"tolerations\":[{\"effect\":\"NoExecute\",\"key\":\"node.kubernetes.io/not-ready\",\"operator\":\"Exists\",\"tolerationSeconds\":300},{\"effect\":\"NoExecute\",\"key\":\"node.kubernetes.io/unreachable\",\"operator\":\"Exists\",\"tolerationSeconds\":300}],\"volumes\":[{\"emptyDir\":{},\"name\":\"data\"},{\"name\":\"default-token-96vwj\",\"secret\":{\"defaultMode\":420,\"secretName\":\"default-token-96vwj\"}}]},\"status\":{\"conditions\":[{\"lastProbeTime\":null,\"lastTransitionTime\":\"2019-01-03T09:11:10Z\",\"status\":\"True\",\"type\":\"Initialized\"},{\"lastProbeTime\":null,\"lastTransitionTime\":\"2019-01-03T09:11:40Z\",\"status\":\"True\",\"type\":\"Ready\"},{\"lastProbeTime\":null,\"lastTransitionTime\":\"2019-01-03T09:11:10Z\",\"status\":\"True\",\"type\":\"PodScheduled\"}],\"containerStatuses\":[{\"containerID\":\"docker://46eb2c664f947a2a0a35ac7799b04c77756aef0a9935855c2dadcf959bd27030\",\"image\":\"docker.elastic.co/elasticsearch/elasticsearch:5.6.0\",\"imageID\":\"docker-pullable://docker.elastic.co/elasticsearch/elasticsearch@sha256:f95e7d4256197a9bb866b166d9ad37963dc7c5764d6ae6400e551f4987a659d7\",\"lastState\":{},\"name\":\"elasticsearch\",\"ready\":true,\"restartCount\":0,\"state\":{\"running\":{\"startedAt\":\"2019-01-03T09:11:13Z\"}}}],\"hostIP\":\"10.166.0.2\",\"phase\":\"Running\",\"podIP\":\"10.36.0.10\",\"qosClass\":\"Burstable\",\"startTime\":\"2019-01-03T09:11:10Z\"}}\n"},"creationTimestamp":"2019-01-03T09:11:10Z","resourceVersion":"2778","uid":"82d3be2f-0f37-11e9-b8b1-42010aa60019"},"spec":{"$setElementOrder/containers":[{"name":"elasticsearch"}],"containers":[{"args":["-Ehttp.host=0.0.0.0","-Etransport.host=127.0.0.1","-cpus","2"],"name":"elasticsearch","resources":{"limits":{"cpu":"1"},"requests":{"cpu":"0.5"}}}]},"status":{"$setElementOrder/conditions":[{"type":"Initialized"},{"type":"Ready"},{"type":"PodScheduled"}],"conditions":[{"lastTransitionTime":"2019-01-03T09:11:10Z","type":"Initialized"},{"lastTransitionTime":"2019-01-03T09:11:40Z","type":"Ready"},{"lastTransitionTime":"2019-01-03T09:11:10Z","type":"PodScheduled"}],"containerStatuses":[{"containerID":"docker://46eb2c664f947a2a0a35ac7799b04c77756aef0a9935855c2dadcf959bd27030","image":"docker.elastic.co/elasticsearch/elasticsearch:5.6.0","imageID":"docker-pullable://docker.elastic.co/elasticsearch/elasticsearch@sha256:f95e7d4256197a9bb866b166d9ad37963dc7c5764d6ae6400e551f4987a659d7","lastState":{},"name":"elasticsearch","ready":true,"restartCount":0,"state":{"running":{"startedAt":"2019-01-03T09:11:13Z"}}}],"podIP":"10.36.0.10","startTime":"2019-01-03T09:11:10Z"}}
to:
Resource: "/v1, Resource=pods", GroupVersionKind: "/v1, Kind=Pod"
Name: "elasticsearch-0", Namespace: "default"
Object: &amp;{map["kind":"Pod" "apiVersion":"v1" "metadata":map["selfLink":"/api/v1/namespaces/default/pods/elasticsearch-0" "generateName":"elasticsearch-" "namespace":"default" "resourceVersion":"11515" "creationTimestamp":"2019-01-03T10:29:53Z""labels":map["controller-revision-hash":"elasticsearch-8684f69799" "jaeger-infra":"elasticsearch-replica" "statefulset.kubernetes.io/pod-name":"elasticsearch-0" "app":"jaeger-elasticsearch"] "annotations":map["kubernetes.io/limit-ranger":"LimitRanger plugin set: cpu request for container elasticsearch"] "ownerReferences":[map["controller":%!q(bool=true) "blockOwnerDeletion":%!q(bool=true) "apiVersion":"apps/v1" "kind":"StatefulSet" "name":"elasticsearch" "uid":"86578784-0f36-11e9-b8b1-42010aa60019"]] "name":"elasticsearch-0" "uid":"81cba2ad-0f42-11e9-b8b1-42010aa60019"] "spec":map["restartPolicy":"Always" "terminationGracePeriodSeconds":'\x1e' "serviceAccountName":"default" "securityContext":map[] "subdomain":"elasticsearch" "schedulerName":"default-scheduler" "tolerations":[map["operator":"Exists" "effect":"NoExecute" "tolerationSeconds":'\u012c' "key":"node.kubernetes.io/not-ready"] map["operator":"Exists" "effect":"NoExecute" "tolerationSeconds":'\u012c' "key":"node.kubernetes.io/unreachable"]] "volumes":[map["name":"data" "emptyDir":map[]] map["name":"default-token-96vwj" "secret":map["secretName":"default-token-96vwj" "defaultMode":'\u01a4']]] "dnsPolicy":"ClusterFirst" "serviceAccount":"default" "nodeName":"gke-jaeger-persistent-st-default-pool-81004235-h8xt" "hostname":"elasticsearch-0" "containers":[map["name":"elasticsearch" "image":"docker.elastic.co/elasticsearch/elasticsearch:5.6.0" "readinessProbe":map["exec":map["command":["curl" "--fail" "--silent" "--output" "/dev/null" "--user" "elastic:changeme" "localhost:9200"]] "initialDelaySeconds":'\x05' "timeoutSeconds":'\x04' "periodSeconds":'\x05' "successThreshold":'\x01' "failureThreshold":'\x03'] "terminationMessagePath":"/dev/termination-log" "imagePullPolicy":"Always" "command":["bin/elasticsearch"] "args":["-Ehttp.host=0.0.0.0" "-Etransport.host=127.0.0.1"] "resources":map["requests":map["cpu":"100m"]] "volumeMounts":[map["name":"data" "mountPath":"/data"] map["name":"default-token-96vwj" "readOnly":%!q(bool=true) "mountPath":"/var/run/secrets/kubernetes.io/serviceaccount"]] "terminationMessagePolicy":"File"]]] "status":map["qosClass":"Burstable" "phase":"Running" "conditions":[map["type":"Initialized" "status":"True" "lastProbeTime":&lt;nil&gt; "lastTransitionTime":"2019-01-03T10:29:53Z"] map["type":"Ready" "status":"True" "lastProbeTime":&lt;nil&gt; "lastTransitionTime":"2019-01-03T10:30:17Z"] map["type":"PodScheduled" "status":"True" "lastProbeTime":&lt;nil&gt; "lastTransitionTime":"2019-01-03T10:29:53Z"]] "hostIP":"10.166.0.2" "podIP":"10.36.0.11" "startTime":"2019-01-03T10:29:53Z" "containerStatuses":[map["name":"elasticsearch" "state":map["running":map["startedAt":"2019-01-03T10:29:55Z"]] "lastState":map[] "ready":%!q(bool=true) "restartCount":'\x00' "image":"docker.elastic.co/elasticsearch/elasticsearch:5.6.0" "imageID":"docker-pullable://docker.elastic.co/elasticsearch/elasticsearch@sha256:f95e7d4256197a9bb866b166d9ad37963dc7c5764d6ae6400e551f4987a659d7" "containerID":"docker://e7f629b79da33b482b38fdb990717b3d61d114503961302e2e8feccb213bbd4b"]]]]}
for: "elasticsearch-0.yaml": Operation cannot be fulfilled on pods "elasticsearch-0": the object has been modified; please apply your changes to the latest version and try again
~/w/jaeger-elasticsearch ❯❯❯
</code></pre>

<p>How to can I modify my pod yaml file in order to assign it more resources and solve the <code>kubernetes.io/limit-ranger: 'LimitRanger plugin set: cpu request for container elasticsearch'</code> message?     </p>

<p>Here's an article/guide on how to work with the limit-ranger and its default values [1]</p>

<p>[1]<a href="https://medium.com/@betz.mark/understanding-resource-limits-in-kubernetes-cpu-time-9eff74d3161b" rel="nofollow noreferrer">https://medium.com/@betz.mark/understanding-resource-limits-in-kubernetes-cpu-time-9eff74d3161b</a></p>
