[SOLUCIONADO] Problemas con Traefik

El servicio esta ahora creado usando traefik.yml y el log me dice…
time = “2020-06-25T14: 29: 57Z” nivel = error msg = “No se puede agregar el certificado /uunn.local.cert para almacenar: no se puede generar el certificado TLS: tls: no se encontraron datos PEM en la entrada del certificado” tlsStoreName = default

Yo había corrido estos dos comandos

docker config create traefik_tls_cert servicios/certs/uunn.local.crt
docker secret create traefik_tls_key servicios/certs/uunn.local.key
como dice la documentación
Este es el log completo

time=“2020-06-25T15:27:13Z” level=info msg=“Configuration loaded from flags.”,
time=“2020-06-25T15:27:13Z” level=info msg=“Traefik version 2.2.1 built on 2020-04-29T18:02:09Z”,
time=“2020-06-25T15:27:13Z” level=info msg=“\nStats collection is disabled.\nHelp us improve Traefik by turning this feature on :)\nMore details on: https://docs.traefik.io/contributing/data-collection/\n”,
time=“2020-06-25T15:27:13Z” level=info msg=“Starting provider aggregator.ProviderAggregator {}”,
time=“2020-06-25T15:27:13Z” level=info msg=“Starting provider *file.Provider {"watch":true,"filename":"/etc/traefik/tls.toml"}”,
time=“2020-06-25T15:27:13Z” level=info msg=“Starting provider *traefik.Provider {}”,
time=“2020-06-25T15:27:13Z” level=info msg=“Starting provider *docker.Provider {"watch":true,"endpoint":"unix:///var/run/docker.sock","defaultRule":"Host({{ normalize .Name }})","swarmMode":true,"network":"traefik-public","swarmModeRefreshSeconds":15000000000}”,
time=“2020-06-25T15:27:13Z” level=error msg=“Unable to append certificate /uunn.local.cert to store: unable to generate TLS certificate : tls: failed to find any PEM data in certificate input” tlsStoreName=default,
time=“2020-06-25T15:27:14Z” level=error msg=“Unable to append certificate /uunn.local.cert to store: unable to generate TLS certificate : tls: failed to find any PEM data in certificate input” tlsStoreName=default,
time=“2020-06-25T15:27:14Z” level=error msg=“Unable to append certificate /uunn.local.cert to store: unable to generate TLS certificate : tls: failed to find any PEM data in certificate input” tlsStoreName=default,
time=“2020-06-25T15:27:28Z” level=error msg=“Unable to append certificate /uunn.local.cert to store: unable to generate TLS certificate : tls: failed to find any PEM data in certificate input” tlsStoreName=default,
time=“2020-06-25T15:27:43Z” level=error msg=“Unable to append certificate /uunn.local.cert to store: unable to generate TLS certificate : tls: failed to find any PEM data in certificate input” tlsStoreName=default,
time=“2020-06-25T15:27:58Z” level=error msg=“Unable to append certificate /uunn.local.cert to store: unable to generate TLS certificate : tls: failed to find any PEM data in certificate input” tlsStoreName=default,

Para el caso del servicio usando traefik.le.yml con Let’s Encrypt
No se levanta el servicio y tira este error el log
traefik_reverse-proxy.0.ihshj1ec47n3@maqui | 2020/06/25 15:31:43 command traefik error: failed to decode configuration from flags: field not found, node: uncoma

Nos interesa usar la opción con Let’s Encrypt como seguimos?
Gracias

Para el caso utilizando certificados provistos por el entorno:
en que dominio estás tratando de levantar? Si estás tratando de inicializar la configuración en un dominio que no es ‘uunn.local’ entonces tenés que generar nuevos certificados para el dominio en cuestión. En el repo (https://hub.siu.edu.ar/siu/expedientes/-/blob/develop/var/template_certs.txt) se incluye ese template de script en donde hay que reemplazar ‘uunn.local’ por el dominio en cuestión. Una vez hecho esto, recrear config y secret traefik_tls_cert y traefik_tls_key por los certificados generados.

Para el caso con lets encrypt:
Tengan en cuenta, que para que esto funcione, el dominio que elijan debe ser público y estar bajo su control.
Para ver que puede estar pasando, suban su archivo traefik.le.yml con las modificaciones que hayan hecho

Saludos!

Ya solucionamos la primero opcion pero nos interesa usar la opción con lets encrypt, el traefik.le.yml queda asi:
services:
reverse-proxy:
image: traefik:2.2
ports:
- “80:80”
- “443:443”
configs:
- source: traefik_security
target: /etc/traefik/security.toml
command:
- --api.insecure=false # set to ‘false’ on production
- --api.dashboard=false
- --api.debug=false # enable additional endpoints for debugging and profiling
- --log.level=INFO # debug while we get it working, for more levels/info see https://docs.traefik.io/observability/logs/
- --providers.docker=true
- --providers.docker.swarmMode=true
- --providers.docker.exposedbydefault=false
- --providers.docker.network=traefik-public
- --entrypoints.web.address=:80
- --entrypoints.web.http.redirections.entryPoint.to=web-secured
- --entrypoints.web.http.redirections.entryPoint.scheme=https
- --entrypoints.web.http.redirections.entrypoint.permanent=true
- --entrypoints.web-secured.address=:443
- --providers.file=true
- --providers.file.directory=/etc/traefik
- --certificatesresolvers.le-expedientes.uncoma.edu.ar.acme.email=cristian.ilabaca@dti.uncoma.edu.ar
- --certificatesresolvers.le-expedientes.uncoma.edu.ar.acme.storage=/certs/acme-expedientes.uncoma.edu.ar.json
- --certificatesresolvers.le-expedientes.uncoma.edu.ar.acme.httpchallenge.entrypoint=web
- --certificatesresolvers.le-traefik-expedientes.uncoma.edu.ar.acme.email=cristian.ilabaca@dti.uncoma.edu.ar
- --certificatesresolvers.le-traefik-expedientes.uncoma.edu.ar.acme.storage=/certs/acme-traefik-expedientes.uncoma.edu.ar.json
- --certificatesresolvers.le-traefik-expedientes.uncoma.edu.ar.acme.httpchallenge.entrypoint=web
- --certificatesresolvers.le-expedientes.uncoma.edu.ar.acme.caserver=https://acme-staging-v02.api.letsencrypt.org/directory
- --certificatesresolvers.le-traefik-expedientes.uncoma.edu.ar.acme.caserver=https://acme-staging-v02.api.letsencrypt.org/directory
deploy:
mode: global
placement:
constraints:
- node.role == manager
labels:
- “traefik.enable=true”
- “traefik.http.routers.traefik-public-https.rule=Host(expedientes.uncoma.edu.ar)”
- “traefik.http.routers.traefik-public-https.entrypoints=web-secured”
- “traefik.http.routers.traefik-public-https.tls=true”
# Use the “le” (Let’s Encrypt) resolver created above
- “traefik.http.routers.traefik-public-https.tls.certresolver=le-expedientes.uncoma.edu.ar”
# Dasboard
- “traefik.http.routers.api.rule=Host(traefik.expedientes.uncoma.edu.ar)”
- “traefik.http.routers.api.entrypoints=web-secured”
- “traefik.http.routers.api.tls=true”
- “traefik.http.routers.api.tls.certresolver=le-traefik-expedientes.uncoma.edu.ar”
- “traefik.http.routers.api.service=api@internal”
- “traefik.http.routers.api.middlewares=auth”
- “traefik.http.middlewares.auth.basicauth.users=traefik:$$apr1$$ZCvAur.4$$M6z07aYv2PFlnzPkWVvi3”
# Dummy service for Swarm port detection. The port can be any valid integer value.
- “traefik.http.services.dummy-svc.loadbalancer.server.port=9999”
volumes:
- /var/run/docker.sock:/var/run/docker.sock
- traefik-certs:/certs
networks:
traefik-public:

configs:
traefik_security:
file: ./security.toml

volumes:
traefik-certs:

traefik-certs: # ejemplo con nfs

  # driver: local
  # driver_opts:
#   type: nfs

o: nfsvers=4,addr=170.210.81.17,rw

device: “:/var/nfsroot/certs”

networks:
traefik-public:
external: true

Gracias

Hola! Justo Carlos de UNGS se topó con el mismo problema. Era un tema en el sed de la documentación, faltaba escapar el punto del dominio.

Acá ya podés ver la doc actualizada: https://expedientes.siu.edu.ar/docs/redes/#modificación-de-dominio-base con el nuevo comando. Así tiene que quedar:

sed -i 's/uunn\.local/universidad.edu.ar/g' \
    traefik.le.yml \
    traefik.yml

Los pasos para revivirlo serían:

  • volver el traefik.le.yml a su estado inicial
  • ejecutar el sed nuevo (con el . escapado)
  • borrar stack de traefik
  • borrar el volumen traefik_traefik-certs
  • hacer el deploy nuevamente

Avisame como te va con estas instrucciones,

saludos

Si justo Carlos me comento eso. Era problema del sed.
Ahora esta andando perfectamente.
Gracias