Kubernetes ConfigMap

July 4, 2023

You can define a ConfigMap in the Helm chart which will provide a file to the Kubernetes Deployment docker image. An example of this is apache config:

{{ $env := .Values.global.env }}
apiVersion: v1
kind: ConfigMap
metadata:
  name: "{{ $env }}-{{ .Chart.Name }}-apache-config"
data:
  my-app-apache.conf: |
    <VirtualHost *:80>
        ServerName my-app

        DocumentRoot /home/my-app/www
        <Directory /home/my-app/www>
            Options -Indexes +FollowSymLinks +MultiViews
            AllowOverride All
            Require all granted
            DirectoryIndex index.php
        </Directory>

        <FilesMatch \.php$>
            SetHandler  "proxy:fcgi://localhost:9080"
        </FilesMatch>

        ErrorLog /dev/stdout
        CustomLog /dev/stdout combined
    </VirtualHost>

Logs are pushed to stdout and from there they will automatically be picked up and placed in New Relic.