how to add CATALINA_OPTS=-Djava.awt.headless=true this property in Kubernetes configuration

12/11/2019

To get one of our issue resolved, we need "CATALINA_OPTS=-Djava.awt.headless=true" this property in Kubernetes configuration. i guess this should be added in .yml file.

Please help us , under which this has to be added. Thanks in advance.

Any sample Yaml file or link to it if provided will be great.

-- saranya
kubernetes

2 Answers

12/11/2019

It could go as ConfigMap

As an example, if you want to have the variable CATALINA_OPTS, to contain the value "-Djava.awt.headless=true", you can do this:

apiVersion: v1
kind: ConfigMap
metadata:
  name: my-config
data:
  CATALINA_OPTS: "-Djava.awt.headless=true"

---

apiVersion: v1
kind: Pod
metadata:
  name: my-pod
spec:
  containers:
    - name: bb
      image: k8s.gcr.io/busybox
      command: [ "/bin/sh", "-c", "env" ]
      envFrom:
      - configMapRef:
          name: my-config
  restartPolicy: Never

# kubectl logs my-pod
...
CATALINA_OPTS=-Djava.awt.headless=true

Is this what you need?

-- suren
Source: StackOverflow

12/11/2019

CATALINA_OPTS is an environment variable. Here is how to define it and set it to a single value in Deployment configuration yaml:

...
spec:
  ...
  template:
    metadata:
      labels:
        ...
    spec:
      containers:
      - image: ...
        ...
        env:
          - name: CATALINA_OPTS
            value: -Djava.awt.headless=true
...
-- gears
Source: StackOverflow