Ingress-nginx: Configuration of log-format-upstream using configmap is not taking effect in /etc/nginx/nginx.conf

Created on 18 Mar 2019  路  4Comments  路  Source: kubernetes/ingress-nginx

Is this a request for help? (If yes, you should use our troubleshooting guide and community support channels, see https://kubernetes.io/docs/tasks/debug-application-cluster/troubleshooting/.):

What keywords did you search in NGINX Ingress controller issues before filing this one? (If you have found any duplicates, you should instead reply there.):


Is this a BUG REPORT or FEATURE REQUEST? (choose one):

NGINX Ingress controller version: quay.io/kubernetes-ingress-controller/nginx-ingress-controller:0.21.0

Kubernetes version (use kubectl version): v1.12.6

Environment:

  • Cloud provider or hardware configuration: Azure
  • OS (e.g. from /etc/os-release): Linux
  • Kernel (e.g. uname -a): Linux aks-agentpool-30801576-0 4.15.0-1039-azure
  • Install tools: helm
  • Others:

What happened:
When i access the ingress object with ingress host it logs with default format.
But for my scenario along with default format i need info like
$ssl_cipher, $ssl_protocol, $ssl_server_name etc...

So i have created a configmap as shown below

apiVersion: v1
kind: ConfigMap
metadata:
  labels:
    app: nginx-ingress
    chart: nginx-ingress-1.1.4
    component: "controller"
    heritage: Tiller
    release: kindly-seagull
  name: kindly-seagull-nginx-ingress-controller
  namespace: kube-system
data:
  log-format-upstream: "$ssl_protocol - $ssl_cipher - $$ssl_server_name - [$the_real_ip] - $remote_user [$time_local] \"$request\" $status $body_bytes_sent \"$http_referer\" \"$http_user_agent\" $request_length $request_time [$proxy_upstream_name] $upstream_addr $upstream_response_length $upstream_response_time $upstream_status $req_id"

and sent as argument to deployment

apiVersion: extensions/v1beta1
kind: Deployment
metadata:
  labels:
    app: nginx-ingress
    chart: nginx-ingress-1.1.4
    component: "controller"
    heritage: Tiller
    release: kindly-seagull
  name: kindly-seagull-nginx-ingress-controller
spec:
  replicas: 1
  revisionHistoryLimit: 10
  strategy:
    {}

  minReadySeconds: 0
  template:
    metadata:
      labels:
        app: nginx-ingress
        component: "controller"
        release: kindly-seagull
    spec:
      dnsPolicy: ClusterFirst
      containers:
        - name: nginx-ingress-controller
          image: "quay.io/kubernetes-ingress-controller/nginx-ingress-controller:0.21.0"
          imagePullPolicy: "IfNotPresent"
          args:
            - /nginx-ingress-controller
            - --default-backend-service=kube-system/kindly-seagull-nginx-ingress-default-backend
            - --election-id=ingress-controller-leader
            - --ingress-class=nginx
            - --configmap=kube-system/kindly-seagull-nginx-ingress-controller 
          securityContext:
            capabilities:
                drop:
                - ALL
                add:
                - NET_BIND_SERVICE
            runAsUser: 33
          env:
            - name: POD_NAME
              valueFrom:
                fieldRef:
                  fieldPath: metadata.name
            - name: POD_NAMESPACE
              valueFrom:
                fieldRef:
                  fieldPath: metadata.namespace
          livenessProbe:
            httpGet:
              path: /healthz
              port: 10254
              scheme: HTTP
            initialDelaySeconds: 10
            periodSeconds: 10
            timeoutSeconds: 1
            successThreshold: 1
            failureThreshold: 3
          ports:
            - name: http
              containerPort: 80
              protocol: TCP
            - name: https
              containerPort: 443
              protocol: TCP
          readinessProbe:
            httpGet:
              path: /healthz
              port: 10254
              scheme: HTTP
            initialDelaySeconds: 10
            periodSeconds: 10
            timeoutSeconds: 1
            successThreshold: 1
            failureThreshold: 3
          resources:
            {}

      hostNetwork: false
      serviceAccountName: kindly-seagull-nginx-ingress

Created, logged in to ingress controller and verified /etc/nginx/nginx.conf file the updated configuration has not effected.

Because of that when we do curl request to ingress object the logs with old format displays.

Followed below links to achieve this
https://github.com/kubernetes/ingress-nginx/blob/master/docs/user-guide/nginx-configuration/configmap.md
https://github.com/nginxinc/kubernetes-ingress/blob/master/deployments/deployment/nginx-ingress.yaml

But couldn't succeed

What you expected to happen:
When we add configuration through configmap it should effect in nginx.conf file and if we do request to ingress object it should show the output in the given format.

Please Let me know if i am missing something.

All 4 comments

Closing this issue..
Because i got the mistake which i did in configmap yaml file.

Closing this issue..
Because i got the mistake which i did in configmap yaml file.

Which was the mistake?

Closing this issue..
Because i got the mistake which i did in configmap yaml file.

Please post how you resolved the issue if you solve it yourself.

@here,

I got this working by putting following values in configmap -

log-format-upstream: '$remote_addr $host $remote_user [$time_local] $request $status $body_bytes_sent $http_referer $http_user_agent $request_length $request_time [$proxy_upstream_name] [$proxy_alternative_upstream_name] $upstream_addr $upstream_response_length $upstream_response_time $upstream_status $req_id'

It's default logging format except $host which I added for my own purpose instead of $host it was originally -

Was this page helpful?
0 / 5 - 0 ratings

Related issues

lachlancooper picture lachlancooper  路  3Comments

yuyang0 picture yuyang0  路  3Comments

cabrinoob picture cabrinoob  路  3Comments

sophaskins picture sophaskins  路  3Comments

silasbw picture silasbw  路  3Comments