Intellipaat Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in DevOps and Agile by (12.7k points)

Hi, i wanted to know how can I pass the nginx.conf (configuration file) to a nginx instance which is running inside a Kubernetes cluster?

1 Answer

0 votes
by (29.5k points)

Hi, the method that I can think of requires the creation of ConfigMap object and then mounting the values as files in places you require, you can refer the below given config: 

apiVersion: v1

kind: ConfigMap

metadata:

  name: nginx-config

data:

  nginx.conf: |

    your config

    comes here

    like this

  other.conf: |

    second file

    contents

Pod spec: 

spec:

  containers:

    - name: nginx

      image: nginx

      volumeMounts:

        - name: nginx-config

          mountPath: /etc/nginx/nginx.conf

          subPath: nginx.conf

        - name: nginx-config

          mountPath: /etc/nginx/other.conf

          subPath: other.conf

  volumes:

    - name: nginx-config

      configMap:

        name: nginx-config

you can learn more about configurations related to Kubernetes and Devops in 

Devops course

31k questions

32.8k answers

501 comments

693 users

Browse Categories

...