License 2017, Træfɪk => Træfik
Signed-off-by: Emile Vauge <emile@vauge.com>
This commit is contained in:
parent
6012a0f3c5
commit
19a7d22eef
16 changed files with 125 additions and 152 deletions
|
@ -1,7 +1,7 @@
|
|||
# Clustering / High Availability
|
||||
|
||||
This guide explains how tu use Træfɪk in high availability mode.
|
||||
In order to deploy and configure multiple Træfɪk instances, without copying the same configuration file on each instance, we will use a distributed Key-Value store.
|
||||
This guide explains how tu use Træfik in high availability mode.
|
||||
In order to deploy and configure multiple Træfik instances, without copying the same configuration file on each instance, we will use a distributed Key-Value store.
|
||||
|
||||
## Prerequisites
|
||||
|
||||
|
@ -9,11 +9,11 @@ You will need a working KV store cluster.
|
|||
|
||||
## File configuration to KV store migration
|
||||
|
||||
We created a special Træfɪk command to help configuring your Key Value store from a Træfɪk TOML configuration file.
|
||||
We created a special Træfik command to help configuring your Key Value store from a Træfik TOML configuration file.
|
||||
Please refer to [this section](/user-guide/kv-config/#store-configuration-in-key-value-store) to get more details.
|
||||
|
||||
## Deploy a Træfɪk cluster
|
||||
## Deploy a Træfik cluster
|
||||
|
||||
Once your Træfɪk configuration is uploaded on your KV store, you can start each Træfɪk instance.
|
||||
A Træfɪk cluster is based on a master/slave model. When starting, Træfɪk will elect a master. If this instance fails, another master will be automatically elected.
|
||||
Once your Træfik configuration is uploaded on your KV store, you can start each Træfik instance.
|
||||
A Træfik cluster is based on a master/slave model. When starting, Træfik will elect a master. If this instance fails, another master will be automatically elected.
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
|
||||
# Examples
|
||||
|
||||
You will find here some configuration examples of Træfɪk.
|
||||
You will find here some configuration examples of Træfik.
|
||||
|
||||
## HTTP only
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
# Kubernetes Ingress Controller
|
||||
|
||||
This guide explains how to use Træfɪk as an Ingress controller in a Kubernetes cluster.
|
||||
This guide explains how to use Træfik as an Ingress controller in a Kubernetes cluster.
|
||||
If you are not familiar with Ingresses in Kubernetes you might want to read the [Kubernetes user guide](http://kubernetes.io/docs/user-guide/ingress/)
|
||||
|
||||
The config files used in this guide can be found in the [examples directory](https://github.com/containous/traefik/tree/master/examples/k8s)
|
||||
|
@ -14,7 +14,7 @@ on your machine, as it is the quickest way to get a local Kubernetes cluster set
|
|||
|
||||
## Deploy Træfik using a Deployment object
|
||||
|
||||
We are going to deploy Træfɪk with a
|
||||
We are going to deploy Træfik with a
|
||||
[Deployment](http://kubernetes.io/docs/user-guide/deployments/), as this will
|
||||
allow you to easily roll out config changes or update the image.
|
||||
|
||||
|
@ -58,11 +58,11 @@ spec:
|
|||
```
|
||||
[examples/k8s/traefik.yaml](https://github.com/containous/traefik/tree/master/examples/k8s/traefik.yaml)
|
||||
|
||||
> notice that we binding port 80 on the Træfɪk container to port 80 on the host.
|
||||
> With a multi node cluster we might expose Træfɪk with a NodePort or LoadBalancer service
|
||||
> and run more than 1 replica of Træfɪk for high availability.
|
||||
> notice that we binding port 80 on the Træfik container to port 80 on the host.
|
||||
> With a multi node cluster we might expose Træfik with a NodePort or LoadBalancer service
|
||||
> and run more than 1 replica of Træfik for high availability.
|
||||
|
||||
To deploy Træfɪk to your cluster start by submitting the deployment to the cluster with `kubectl`:
|
||||
To deploy Træfik to your cluster start by submitting the deployment to the cluster with `kubectl`:
|
||||
|
||||
```sh
|
||||
kubectl apply -f examples/k8s/traefik.yaml
|
||||
|
@ -143,20 +143,20 @@ traefik-ingress-controller-678226159-eqseo 1/1 Running 0 7m
|
|||
|
||||
You should see that after submitting the Deployment to Kubernetes it has launched
|
||||
a pod, and it is now running. _It might take a few moments for kubernetes to pull
|
||||
the Træfɪk image and start the container._
|
||||
the Træfik image and start the container._
|
||||
|
||||
> You could also check the deployment with the Kubernetes dashboard, run
|
||||
> `minikube dashboard` to open it in your browser, then choose the `kube-system`
|
||||
> namespace from the menu at the top right of the screen.
|
||||
|
||||
You should now be able to access Træfɪk on port 80 of your minikube instance.
|
||||
You should now be able to access Træfik on port 80 of your minikube instance.
|
||||
|
||||
```sh
|
||||
curl $(minikube ip)
|
||||
404 page not found
|
||||
```
|
||||
|
||||
> We expect to see a 404 response here as we haven't yet given Træfɪk any configuration.
|
||||
> We expect to see a 404 response here as we haven't yet given Træfik any configuration.
|
||||
|
||||
## Deploy Træfik using Helm Chart
|
||||
|
||||
|
@ -173,7 +173,7 @@ For more information, check out [the doc](https://github.com/kubernetes/charts/t
|
|||
## Submitting An Ingress to the cluster.
|
||||
|
||||
Lets start by creating a Service and an Ingress that will expose the
|
||||
[Træfɪk Web UI](https://github.com/containous/traefik#web-ui).
|
||||
[Træfik Web UI](https://github.com/containous/traefik#web-ui).
|
||||
|
||||
```yaml
|
||||
apiVersion: v1
|
||||
|
@ -221,7 +221,7 @@ to our cluster.
|
|||
echo "$(minikube ip) traefik-ui.local" | sudo tee -a /etc/hosts
|
||||
```
|
||||
|
||||
We should now be able to visit [traefik-ui.local](http://traefik-ui.local) in the browser and view the Træfɪk Web UI.
|
||||
We should now be able to visit [traefik-ui.local](http://traefik-ui.local) in the browser and view the Træfik Web UI.
|
||||
|
||||
## Name based routing
|
||||
|
||||
|
@ -434,7 +434,7 @@ spec:
|
|||
kubectl apply -f examples/k8s/cheese-ingress.yaml
|
||||
```
|
||||
|
||||
Now visit the [Træfɪk dashboard](http://traefik-ui.local/) and you should
|
||||
Now visit the [Træfik dashboard](http://traefik-ui.local/) and you should
|
||||
see a frontend for each host. Along with a backend listing for each service
|
||||
with a Server set up for each pod.
|
||||
|
||||
|
@ -486,7 +486,7 @@ spec:
|
|||
```
|
||||
[examples/k8s/cheeses-ingress.yaml](https://github.com/containous/traefik/tree/master/examples/k8s/cheeses-ingress.yaml)
|
||||
|
||||
> Notice that we are configuring Træfɪk to strip the prefix from the url path
|
||||
> Notice that we are configuring Træfik to strip the prefix from the url path
|
||||
> with the `traefik.frontend.rule.type` annotation so that we can use
|
||||
> the containers from the previous example without modification.
|
||||
|
||||
|
@ -505,7 +505,7 @@ You should now be able to visit the websites in your browser.
|
|||
* [cheeses.local/wensleydale](http://cheeses.local/wensleydale/)
|
||||
|
||||
## Disable passing the Host header
|
||||
By default Træfɪk will pass the incoming Host header on to the upstream resource. There
|
||||
By default Træfik will pass the incoming Host header on to the upstream resource. There
|
||||
are times however where you may not want this to be the case. For example if your service
|
||||
is of the ExternalName type.
|
||||
|
||||
|
@ -561,8 +561,8 @@ Note: The per ingress annotation overides whatever the global value is set to. S
|
|||
could set `disablePassHostHeaders` to true in your toml file and then enable passing
|
||||
the host header per ingress if you wanted.
|
||||
|
||||
## Excluding an ingress from Træfɪk
|
||||
You can control which ingress Træfɪk cares about by using the "kubernetes.io/ingress.class"
|
||||
annotation. By default if the annotation is not set at all Træfɪk will include the
|
||||
## Excluding an ingress from Træfik
|
||||
You can control which ingress Træfik cares about by using the "kubernetes.io/ingress.class"
|
||||
annotation. By default if the annotation is not set at all Træfik will include the
|
||||
ingress. If the annotation is set to anything other than traefik or a blank string
|
||||
Træfɪk will ignore it.
|
||||
Træfik will ignore it.
|
||||
|
|
|
@ -3,9 +3,9 @@
|
|||
|
||||
Both [static global configuration](/user-guide/kv-config/#static-configuration-in-key-value-store) and [dynamic](/user-guide/kv-config/#dynamic-configuration-in-key-value-store) configuration can be sorted in a Key-value store.
|
||||
|
||||
This section explains how to launch Træfɪk using a configuration loaded from a Key-value store.
|
||||
This section explains how to launch Træfik using a configuration loaded from a Key-value store.
|
||||
|
||||
Træfɪk supports several Key-value stores:
|
||||
Træfik supports several Key-value stores:
|
||||
|
||||
- [Consul](https://consul.io)
|
||||
- [etcd](https://coreos.com/etcd/)
|
||||
|
@ -19,7 +19,7 @@ Note that we could do the same with any other Key-value Store.
|
|||
|
||||
## docker-compose file for Consul
|
||||
|
||||
The Træfɪk global configuration will be getted from a [Consul](https://consul.io) store.
|
||||
The Træfik global configuration will be getted from a [Consul](https://consul.io) store.
|
||||
|
||||
First we have to launch Consul in a container.
|
||||
The [docker-compose file](https://docs.docker.com/compose/compose-file/) allows us to launch Consul and four instances of the trivial app [emilevauge/whoamI](https://github.com/emilevauge/whoamI) :
|
||||
|
@ -54,11 +54,11 @@ whoami4:
|
|||
|
||||
## Upload the configuration in the Key-value store
|
||||
|
||||
We should now fill the store with the Træfɪk global configuration, as we do with a [TOML file configuration](/toml).
|
||||
We should now fill the store with the Træfik global configuration, as we do with a [TOML file configuration](/toml).
|
||||
To do that, we can send the Key-value pairs via [curl commands](https://www.consul.io/intro/getting-started/kv.html) or via the [Web UI](https://www.consul.io/intro/getting-started/ui.html).
|
||||
|
||||
Fortunately, Træfɪk allows automation of this process using the `storeconfig` subcommand.
|
||||
Please refer to the [store Træfɪk configuration](/user-guide/kv-config/#store-configuration-in-key-value-store) section to get documentation on it.
|
||||
Fortunately, Træfik allows automation of this process using the `storeconfig` subcommand.
|
||||
Please refer to the [store Træfik configuration](/user-guide/kv-config/#store-configuration-in-key-value-store) section to get documentation on it.
|
||||
|
||||
Here is the toml configuration we would like to store in the Key-value Store :
|
||||
|
||||
|
@ -118,10 +118,10 @@ In case you are setting key values manually,:
|
|||
|
||||
Note that we can either give path to certificate file or directly the file content itself.
|
||||
|
||||
## Launch Træfɪk
|
||||
## Launch Træfik
|
||||
|
||||
We will now launch Træfɪk in a container.
|
||||
We use CLI flags to setup the connection between Træfɪk and Consul.
|
||||
We will now launch Træfik in a container.
|
||||
We use CLI flags to setup the connection between Træfik and Consul.
|
||||
All the rest of the global configuration is stored in Consul.
|
||||
|
||||
Here is the [docker-compose file](https://docs.docker.com/compose/compose-file/) :
|
||||
|
@ -142,7 +142,7 @@ NB : Be careful to give the correct IP address and port in the flag `--consul.en
|
|||
So far, only [Consul](https://consul.io) and [etcd](https://coreos.com/etcd/) support TLS connections.
|
||||
To set it up, we should enable [consul security](https://www.consul.io/docs/internals/security.html) (or [etcd security](https://coreos.com/etcd/docs/latest/security.html)).
|
||||
|
||||
Then, we have to provide CA, Cert and Key to Træfɪk using `consul` flags :
|
||||
Then, we have to provide CA, Cert and Key to Træfik using `consul` flags :
|
||||
|
||||
- `--consul.tls`
|
||||
- `--consul.tls.ca=path/to/the/file`
|
||||
|
@ -161,9 +161,9 @@ Note that we can either give directly directly the file content itself (instead
|
|||
Remember the command `traefik --help` to display the updated list of flags.
|
||||
|
||||
# Dynamic configuration in Key-value store
|
||||
Following our example, we will provide backends/frontends rules to Træfɪk.
|
||||
Following our example, we will provide backends/frontends rules to Træfik.
|
||||
|
||||
Note that this section is independent of the way Træfɪk got its static configuration.
|
||||
Note that this section is independent of the way Træfik got its static configuration.
|
||||
It means that the static configuration can either come from the same Key-value store or from any other sources.
|
||||
|
||||
## Key-value storage structure
|
||||
|
@ -259,13 +259,13 @@ And there, the same dynamic configuration in a KV Store (using `prefix = "traefi
|
|||
|
||||
## Atomic configuration changes
|
||||
|
||||
Træfɪk can watch the backends/frontends configuration changes and generate its configuration automatically.
|
||||
Træfik can watch the backends/frontends configuration changes and generate its configuration automatically.
|
||||
|
||||
Note that only backends/frontends rules are dynamic, the rest of the Træfɪk configuration stay static.
|
||||
Note that only backends/frontends rules are dynamic, the rest of the Træfik configuration stay static.
|
||||
|
||||
The [Etcd](https://github.com/coreos/etcd/issues/860) and [Consul](https://github.com/hashicorp/consul/issues/886) backends do not support updating multiple keys atomically. As a result, it may be possible for Træfɪk to read an intermediate configuration state despite judicious use of the `--providersThrottleDuration` flag. To solve this problem, Træfɪk supports a special key called `/traefik/alias`. If set, Træfɪk use the value as an alternative key prefix.
|
||||
The [Etcd](https://github.com/coreos/etcd/issues/860) and [Consul](https://github.com/hashicorp/consul/issues/886) backends do not support updating multiple keys atomically. As a result, it may be possible for Træfik to read an intermediate configuration state despite judicious use of the `--providersThrottleDuration` flag. To solve this problem, Træfik supports a special key called `/traefik/alias`. If set, Træfik use the value as an alternative key prefix.
|
||||
|
||||
Given the key structure below, Træfɪk will use the `http://172.17.0.2:80` as its only backend (frontend keys have been omitted for brevity).
|
||||
Given the key structure below, Træfik will use the `http://172.17.0.2:80` as its only backend (frontend keys have been omitted for brevity).
|
||||
|
||||
| Key | Value |
|
||||
|-------------------------------------------------------------------------|-----------------------------|
|
||||
|
@ -297,19 +297,19 @@ Once the `/traefik/alias` key is updated, the new `/traefik_configurations/2` co
|
|||
| `/traefik_configurations/2/backends/backend1/servers/server2/url` | `http://172.17.0.4:80` |
|
||||
| `/traefik_configurations/2/backends/backend1/servers/server2/weight` | `5` |
|
||||
|
||||
Note that Træfɪk *will not watch for key changes in the `/traefik_configurations` prefix*. It will only watch for changes in the `/traefik/alias`.
|
||||
Note that Træfik *will not watch for key changes in the `/traefik_configurations` prefix*. It will only watch for changes in the `/traefik/alias`.
|
||||
Further, if the `/traefik/alias` key is set, all other configuration with `/traefik/backends` or `/traefik/frontends` prefix are ignored.
|
||||
|
||||
# Store configuration in Key-value store
|
||||
|
||||
Don't forget to [setup the connection between Træfɪk and Key-value store](/user-guide/kv-config/#launch-trfk).
|
||||
The static Træfɪk configuration in a key-value store can be automatically created and updated, using the [`storeconfig` subcommand](/basics/#commands).
|
||||
Don't forget to [setup the connection between Træfik and Key-value store](/user-guide/kv-config/#launch-trfk).
|
||||
The static Træfik configuration in a key-value store can be automatically created and updated, using the [`storeconfig` subcommand](/basics/#commands).
|
||||
|
||||
```bash
|
||||
$ traefik storeconfig [flags] ...
|
||||
```
|
||||
This command is here only to automate the [process which upload the configuration into the Key-value store](/user-guide/kv-config/#upload-the-configuration-in-the-key-value-store).
|
||||
Træfɪk will not start but the [static configuration](/basics/#static-trfk-configuration) will be uploaded into the Key-value store.
|
||||
Træfik will not start but the [static configuration](/basics/#static-trfk-configuration) will be uploaded into the Key-value store.
|
||||
If you configured ACME (Let's Encrypt), your registration account and your certificates will also be uploaded.
|
||||
|
||||
To upload your ACME certificates to the KV store, get your traefik TOML file and add the new `storage` option in the `acme` section:
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
This section explains how to create a multi-host docker cluster with
|
||||
swarm mode using [docker-machine](https://docs.docker.com/machine) and
|
||||
how to deploy Træfɪk on it.
|
||||
how to deploy Træfik on it.
|
||||
|
||||
The cluster consists of:
|
||||
|
||||
|
@ -143,7 +143,7 @@ cgfg5ifzrpgm whoami1 1/1 emilevauge/whoami
|
|||
dtpl249tfghc traefik 1/1 traefik --docker --docker.swarmmode --docker.domain=traefik --docker.watch --web
|
||||
```
|
||||
|
||||
## Access to your apps through Træfɪk
|
||||
## Access to your apps through Træfik
|
||||
|
||||
```sh
|
||||
curl -H Host:whoami0.traefik http://$(docker-machine ip manager)
|
||||
|
@ -242,7 +242,7 @@ ab046gpaqtln whoami0 5/5 emilevauge/whoami
|
|||
cgfg5ifzrpgm whoami1 5/5 emilevauge/whoami
|
||||
dtpl249tfghc traefik 1/1 traefik --docker --docker.swarmmode --docker.domain=traefik --docker.watch --web
|
||||
```
|
||||
## Access to your whoami0 through Træfɪk multiple times.
|
||||
## Access to your whoami0 through Træfik multiple times.
|
||||
|
||||
Repeat the following command multiple times and note that the Hostname changes each time as Traefik load balances each request against the 5 tasks.
|
||||
```sh
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
# Swarm cluster
|
||||
|
||||
This section explains how to create a multi-host [swarm](https://docs.docker.com/swarm) cluster using [docker-machine](https://docs.docker.com/machine/) and how to deploy Træfɪk on it.
|
||||
This section explains how to create a multi-host [swarm](https://docs.docker.com/swarm) cluster using [docker-machine](https://docs.docker.com/machine/) and how to deploy Træfik on it.
|
||||
The cluster consists of:
|
||||
|
||||
- 2 servers
|
||||
|
@ -70,9 +70,9 @@ eval $(docker-machine env --swarm mhs-demo0)
|
|||
docker network create --driver overlay --subnet=10.0.9.0/24 my-net
|
||||
```
|
||||
|
||||
## Deploy Træfɪk
|
||||
## Deploy Træfik
|
||||
|
||||
Deploy Træfɪk:
|
||||
Deploy Træfik:
|
||||
|
||||
```sh
|
||||
docker $(docker-machine config mhs-demo0) run \
|
||||
|
@ -126,7 +126,7 @@ ba2c21488299 emilevauge/whoami "/whoamI" 8 seconds ago
|
|||
8fbc39271b4c traefik "/traefik -l DEBUG -c" 36 seconds ago Up 37 seconds 192.168.99.101:80->80/tcp, 192.168.99.101:8080->8080/tcp mhs-demo0/serene_bhabha
|
||||
```
|
||||
|
||||
## Access to your apps through Træfɪk
|
||||
## Access to your apps through Træfik
|
||||
|
||||
```sh
|
||||
curl -H Host:whoami0.traefik http://$(docker-machine ip mhs-demo0)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue