Commit 94cc8aad authored by Matt Pryor's avatar Matt Pryor
Browse files

Make FIFO pipes for log files and tail in separate containers

parent 95cabe95
Loading
Loading
Loading
Loading
+38 −0
Original line number Diff line number Diff line
@@ -23,6 +23,26 @@ spec:
      {{- with .Values.data.podSecurityContext }}
      securityContext: {{ toYaml . | nindent 8 }}
      {{- end }}
      initContainers:
        # Create a named pipe for the access log
        # This allows us to separate the access log from the error log, so that it is tagged differently when forwarded
        # This makes processing the access log for statistics easier
        - name: make-log-pipes
          {{ include "esgf.deployment.image" (list . $fileServer.image) }}
          args:
            # Continue to send the error log to stderr, but send the access log to a named pipe
            - bash
            - -c
            - |
              set -ex
              ln -s /dev/stderr /var/log/nginx/error.log
              mkfifo /var/log/nginx/access.log
          {{- with .Values.data.securityContext }}
          securityContext: {{ toYaml . | nindent 12 }}
          {{- end }}
          volumeMounts:
            - name: nginx-logs
              mountPath: /var/log/nginx
      containers:
        - name: file-server
          {{ include "esgf.deployment.image" (list . $fileServer.image) }}
@@ -50,7 +70,22 @@ spec:
            - name: nginx-conf
              mountPath: /etc/nginx/conf.d
              readOnly: true
            - name: nginx-logs
              mountPath: /var/log/nginx
            {{- include "esgf.data.volumeMounts" . | nindent 12 }}
        # Tail the access log separately
        - name: file-server-access-log
          {{ include "esgf.deployment.image" (list . $fileServer.image) }}
          args:
            # Just cat the access log
            - cat
            - /var/log/nginx/access.log
          {{- with .Values.data.securityContext }}
          securityContext: {{ toYaml . | nindent 12 }}
          {{- end }}
          volumeMounts:
            - name: nginx-logs
              mountPath: /var/log/nginx
      {{- with $fileServer.nodeSelector }}
      nodeSelector: {{ toYaml . | nindent 8 }}
      {{- end }}
@@ -64,5 +99,8 @@ spec:
        - name: nginx-conf
          configMap:
            name: {{ include "esgf.component.fullname" (list . "fileServer") }}
        # Each pod gets a directory to hold the named pipes for the logs
        - name: nginx-logs
          emptyDir: {}
        {{- include "esgf.data.volumes" . | nindent 8 }}
{{- end -}}
+45 −3
Original line number Diff line number Diff line
@@ -27,9 +27,9 @@ spec:
      {{- with .Values.data.podSecurityContext }}
      securityContext: {{ toYaml . | nindent 8 }}
      {{- end }}
      initContainers:
        {{- if (and $thredds.catalogVolume $thredds.localCache.enabled) }}
        # If the local cache is enabled, wait for the node we have landed on to be initialised before starting
      initContainers:
        - name: wait-for-cache
          {{ include "esgf.deployment.image" (list . $thredds.image) }}
          env:
@@ -68,6 +68,27 @@ spec:
            - name: thredds-cache
              mountPath: /thredds/cache
        {{- end }}
        # Create named pipes for the log files
        - name: make-log-pipes
          {{ include "esgf.deployment.image" (list . $thredds.image) }}
          args:
            - bash
            - -c
            - |
              set -ex
              mkfifo /thredds/logs/serverStartup.log
              mkfifo /thredds/logs/catalogInit.log
              mkfifo /thredds/logs/httpout.log
              mkfifo /thredds/logs/featureCollectionScan.log
              mkfifo /thredds/logs/fmrc.log
              mkfifo /thredds/logs/threddsServlet.log
              mkfifo /thredds/logs/cache.log
          {{- with .Values.data.securityContext }}
          securityContext: {{ toYaml . | nindent 12 }}
          {{- end }}
          volumeMounts:
            - name: thredds-logs
              mountPath: /thredds/logs
      containers:
        - name: thredds
          {{ include "esgf.deployment.image" (list . $thredds.image) }}
@@ -106,7 +127,25 @@ spec:
              {{- end }}
            - name: thredds-cache
              mountPath: /opt/tomcat/content/thredds/cache
            - name: thredds-logs
              mountPath: /opt/tomcat/content/thredds/logs
            {{- include "esgf.data.volumeMounts" . | nindent 12 }}
        # Tail the log pipes
        {{- $topContext := . }}
        {{- range (list "serverStartup.log" "catalogInit.log" "httpout.log" "featureCollectionScan.log" "fmrc.log" "threddsServlet.log" "cache.log") }}
        - name: thredds-log-{{ trimSuffix ".log" . | lower }}
          {{ include "esgf.deployment.image" (list $topContext $thredds.image) }}
          args:
            # Just cat the log file
            - cat
            - /thredds/logs/{{ . }}
          {{- with $topContext.Values.data.securityContext }}
          securityContext: {{ toYaml . | nindent 12 }}
          {{- end }}
          volumeMounts:
            - name: thredds-logs
              mountPath: /thredds/logs
        {{- end }}
      {{- with $thredds.nodeSelector }}
      nodeSelector: {{ toYaml . | nindent 8 }}
      {{- end }}
@@ -135,5 +174,8 @@ spec:
        # Each pod gets its own cache directory on the local disk
        - name: thredds-cache
          emptyDir: {}
        # Each pod gets a directory to hold the named pipes for log files
        - name: thredds-logs
          emptyDir: {}
        {{- include "esgf.data.volumes" . | nindent 8 }}
{{- end -}}