title: Kubernetes basic authentication with Traefik
body: <p>I am trying to configure Basic Authentication on a Nginx example with Traefik as Ingress controller.</p>
  
  <p>I just create the secret <code>"mypasswd"</code> on the Kubernetes secrets.</p>
  
  <p>This is the Ingress I am using:</p>
  
  <pre><code>apiVersion: extensions/v1beta1
  kind: Ingress
  metadata:
    name: nginxingress
    annotations:
      ingress.kubernetes.io/auth-type: basic
      ingress.kubernetes.io/auth-realm: traefik
      ingress.kubernetes.io/auth-secret: mypasswd
  spec:
    rules:
    - host: nginx.mycompany.com
      http:
        paths:
        - path: /
          backend:
            serviceName: nginxservice
            servicePort: 80
  </code></pre>
  
  <p>I check in the Traefik dashboard and it appear, if I access to nginx.mycompany.com I can check the Nginx webpage, but without the basic authentication.</p>
  
  <p>This is my nginx deployment:</p>
  
  <pre><code>apiVersion: extensions/v1beta1
  kind: Deployment
  metadata:
    name: nginx-deployment
  spec:
    replicas: 3
    template:
      metadata:
        labels:
          app: nginx
      spec:
        containers:
        - name: nginx
          image: nginx:1.7.9
          ports:
          - containerPort: 80
  </code></pre>
  
  <p>Nginx service:</p>
  
  <pre><code>apiVersion: v1
  kind: Service
  metadata:
    labels:
      name: nginxservice
    name: nginxservice
  spec:
    ports:
      # The port that this service should serve on.
      - port: 80
    # Label keys and values that must match in order to receive traffic for this service.
    selector:
      app: nginx
    type: ClusterIP
  </code></pre>