<p>my problem is that I need to increase NATS max_payload in production environment but it uses Kubernetes and I have no idea how to do that, I tried to use ConfigMap but I had not success.</p>
<p>In local/dev environment it uses a NATS config file with docker so it works fine.</p>
<p>Way to make it works local: <a href="https://stackoverflow.com/questions/65638631/nats-with-moleculer-how-can-i-change-nats-max-payload-value">NATS with moleculer. How can I change NATS max_payload value?</a></p>
<p>Code inside k8s/deployment.develop.yaml</p>
<pre><code>(...)
apiVersion: v1
kind: ServiceAccount
metadata:
  name: nats
  namespace: develop
  labels:
    account: nats
---
apiVersion: v1
kind: Service
metadata:
  name: nats
  namespace: develop
  labels:
    app: nats
    service: nats
spec:
  ports:
    - port: 4222
      targetPort: 4222
  selector:
    app: nats
---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: nats-v1
  namespace: develop
  labels:
    app: nats
    version: v1
spec:
  replicas: 1
  strategy: {}
  selector:
    matchLabels:
      app: nats
      version: v1
  template:
    metadata:
      labels:
        app: nats
        version: v1
    spec:
      serviceAccountName: nats
      containers:
        - image: 'nats:alpine'
          name: nats
          ports:
            - containerPort: 4222
      restartPolicy: Always
      tolerations: []
      affinity: {}
</code></pre>
<p>Thanks!</p>

Matheus Chignolli
<p>The payload value is hardcoded into the docker image (in the nats-server.conf file), so you cannot change it via a configmap. The only solution I found is to build my own nats image with a modified <code>nats-server.conf</code> file.</p>
<p>Here is how to do it.</p>
<ol>
<li>First, select an image flavor from <a href="https://github.com/nats-io/nats-docker" rel="nofollow noreferrer">the official repo</a> and download the content (for example <code>Dockerfile</code> and <code>nats-server.conf</code> from <a href="https://github.com/nats-io/nats-docker/tree/master/2.2.6/scratch" rel="nofollow noreferrer">here</a>).</li>
<li>Modify the <code>nats-server.conf</code> file to change the <code>max_payload</code> value : just add the following line (this file is NOT in JSON format)</li>
</ol>
<pre><code>max_payload: 4Mb
</code></pre>
<ol start="3">
<li>Then build the image : <code>docker image build .</code></li>
<li>Tag it, upload it to your own repo and use it instead of the official <code>nats</code> image</li>
</ol>
