Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Kubernetes and etcd backend : storeconfig fails. #1031

Closed
Smana opened this issue Jan 10, 2017 · 3 comments
Closed

Kubernetes and etcd backend : storeconfig fails. #1031

Smana opened this issue Jan 10, 2017 · 3 comments

Comments

@Smana
Copy link

Smana commented Jan 10, 2017

What version of Traefik are you using (traefik version)?

docker run traefik version
Version:      v1.1.2
Codename:     camembert
Go version:   go1.7.4
Built:        2016-12-15_10:21:15AM
OS/Arch:      linux/amd64

What is your environment & configuration (arguments, toml...)?

Platform : Google Container Engine (GKE)

What did you do?

I've deployed an etcd cluster using the operator

etcd-0000                          1/1       Running                 0          30m
etcd-0001                          1/1       Running                 0          30m
etcd-0002                          1/1       Running                 0          29m
etcd-operator-217127005-01dp9      1/1       Running                 0          30m

kubectl get svc
...
etcd          10.19.255.38    <none>        2379/TCP            31m
...

DaemonSet

---
apiVersion: extensions/v1beta1
kind: DaemonSet
metadata:
  name: traefik-ingress-controller
  labels:
    k8s-app: traefik-ingress-lb
spec:
  template:
    metadata:
      name: traefik-ingress-controller
      labels:
        k8s-app: traefik-ingress-lb
      annotations:
        pod.beta.kubernetes.io/init-containers: '[
            {
                "name": "storeconfig",
                "image": "traefik",
                "imagePullPolicy": "Always",
                "args": ["storeconfig", "--configfile=/config/traefik.toml"],
                "volumeMounts": [
                    {
                        "name": "config",
                        "mountPath": "/config"
                    }
                ]
            }
        ]'
    spec:
      terminationGracePeriodSeconds: 60
      volumes:
        - name: config
          configMap:
            name: traefik-conf
      containers:
        - image: traefik
          name: traefik-ingress-lb
          imagePullPolicy: Always
          volumeMounts:
            - mountPath: "/config"
              name: "config"
          ports:
            - containerPort: 80
              hostPort: 80
            - containerPort: 443
              hostPort: 443
            - containerPort: 8080
              hostPort: 8080
          args:
            - --web
            - --kubernetes
            - --logLevel=DEBUG

ConfigMap

apiVersion: v1
kind: ConfigMap
metadata:
  name: traefik-conf
data:
  traefik.toml: |-
    logLevel = "DEBUG"
    defaultEntryPoints = ["http", "https"]

    [etcd]
    endpoint = "etcd:2379"

    [acme]
    email = "[email protected]"
    storage = "traefik/acme/account"
    entryPoint = "https"
    OnHostRule = true

    [entryPoints]
    [entryPoints.http]
    address = ":80"
    [entryPoints.http.redirect]
    entryPoint = "https"
    [entryPoints.https]
    address = ":443"
    [entryPoints.https.tls]

    [web]
    address = ":8080"

What did you expect to see?

A traefik instance on each node with a shared config in the etcd backend.

What did you see instead?

The storeconfig command failed with the following output :

2017/01/10 16:40:29 Storing configuration: {"GraceTimeOut":10,"Debug":false,"CheckNewVersion":true,"AccessLogsFile":"","TraefikLogsFile":"","LogLevel":"DEBUG","EntryPoints":{"http":{"Network":"","Address":":80","TLS":null,"Redirect":{"EntryPoint":"https","Regex":"","Replacement":""},"Auth":null,"Compress":false},"https":{"Network":"","Address":":443","TLS":{"MinVersion":"","CipherSuites":null,"Certificates":null,"ClientCAFiles":null},"Redirect":null,"Auth":null,"Compress":false}},"Cluster":null,"Constraints":[],"ACME":{"Email":"[email protected]","Domains":null,"Storage":"traefik/acme/account","StorageFile":"","OnDemand":false,"OnHostRule":true,"CAServer":"","EntryPoint":"https"},"DefaultEntryPoints":["http","https"],"ProvidersThrottleDuration":2000000000,"MaxIdleConnsPerHost":200,"InsecureSkipVerify":false,"Retry":null,"Docker":null,"File":null,"Web":{"Address":":8080","CertFile":"","KeyFile":"","ReadOnly":false,"Auth":null},"Marathon":null,"Consul":null,"ConsulCatalog":null,"Etcd":{"Watch":true,"Filename":"","Constraints":[],"Endpoint":"etcd:2379","Prefix":"/traefik","TLS":null},"Zookeeper":null,"Boltdb":null,"Kubernetes":null,"Mesos":null}
2017/01/10 16:40:29 Error running traefik: 102: Not a file (/traefik/acme) [57]
@genti-t
Copy link

genti-t commented Jan 11, 2017

You can use the config map as a temporary config file and use a kubernetes job with the
--configfile=/config/traefik.toml option. After that the etcd KV will be populated and you can run your demon set.

There is another issue though, if you use traefik in cluster mode, etcd cluster as KV store and ACME.
Take a look at #926

@Smana
Copy link
Author

Smana commented Jan 12, 2017

ok @genti-t i'll keep you updated

@Smana
Copy link
Author

Smana commented Jan 12, 2017

Indeed, it's working using a job instead of using an initContainer.
so it's definitely caused by #853

Here is the job manifest

apiVersion: batch/v1
kind: Job
metadata:
  name: traefik-config
spec:
  template:
    metadata:
      name: traefik-config
    spec:
      containers:
      - name: traefik-config
        image: traefik
        args:
        - storeconfig
        - --configfile=/etc/traefik/traefik.toml
        volumeMounts:
        - name: traefik-config
          mountPath: /etc/traefik
      restartPolicy: Never
      volumes:
      - name: traefik-config
        configMap:
          name: traefik-conf

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants