-
Notifications
You must be signed in to change notification settings - Fork 217
Update the Traefik Version to 2.x #1814
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
Changes from 28 commits
b7eae38
6a326b4
d430260
5b3530a
f0c691f
d22e690
1fd8d84
f9226a3
4df4c34
046aa37
daf9dba
49ea53b
16e44a7
c04ea74
47a2c05
f7afd04
db1de82
53ae551
b7f6e1a
f43e0be
718b889
a41f261
2861f3e
f19e06f
a2bfa6e
acfbe79
071c996
4967ae5
674bf01
98eb1d6
9be887f
92416ea
6835a06
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,102 +4,106 @@ This sample demonstrates how to install the Traefik ingress controller to provid | |
load balancing for WebLogic clusters. | ||
|
||
## Install the Traefik operator with a Helm chart | ||
The Traefik Helm chart is located in the official Helm project `charts` directory at https://github.com/helm/charts/tree/master/stable/traefik. | ||
The chart is in the default repository for Helm. | ||
This document is based on Traefik version 2.x with the Helm chart at [Traefik Helm Repository](https://github.com/containous/traefik-helm-chart). | ||
For more information about Traefik, see the [Traefik Official Site](https://traefik.io/). | ||
|
||
To install the Traefik operator in the `traefik` namespace with default settings: | ||
To install the Traefik operator in the `traefik` namespace with the default settings: | ||
``` | ||
$ helm install --name traefik-operator --namespace traefik stable/traefik | ||
$ helm repo add traefik https://containous.github.io/traefik-helm-chart | ||
$ helm repo update | ||
$ kubectl create namespace traefik | ||
$ helm install traefik-operator traefik/traefik --namespace traefik | ||
markxnelson marked this conversation as resolved.
Show resolved
Hide resolved
|
||
``` | ||
Or, with a given `values.yaml`: | ||
You can also install the Traefik operator with a custom `values.yaml` file. For more detailed information, see the [Traefik GitHub Project](https://github.com/containous/traefik-helm-chart/blob/master/traefik/values.yaml). | ||
``` | ||
$ helm install --name traefik-operator --namespace traefik --values values.yaml stable/traefik | ||
``` | ||
With the dashboard enabled, you can access the Traefik dashboard with the URL `http://${HOSTNAME}:30305`, with the HTTP host `traefik.example.com`. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why were the instructions for accessing the Traefik dashboard, downloading the Traefik helm chart locally, and updating the Traefik values removed? This all seems like useful information. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Here we give reference to Official Website for more detail to avoid duplicate information. There is a sample value.yaml is already there in kubernetes/samples/charts/traefik/vlaues.yaml There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't see links to the doc for these areas - just a top level link to There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
``` | ||
$ curl -H 'host: traefik.example.com' http://${HOSTNAME}:30305/ | ||
``` | ||
|
||
## Optionally, download the Traefik Helm chart | ||
If you want, you can download the Traefik Helm chart and untar it into a local folder: | ||
``` | ||
$ helm fetch stable/traefik --untar | ||
``` | ||
|
||
## Update the Traefik operator | ||
After the Traefik operator is installed and running, if you want to change some configurations of the operator, use `helm upgrade` to achieve this. | ||
``` | ||
$ helm upgrade traefik-operator stable/traefik --values values.yaml | ||
$ helm install traefik-operator traefik/traefik --namespace traefik --values values.yaml | ||
``` | ||
|
||
## Configure Traefik as a load balancer for WLS domains | ||
In this section we'll demonstrate how to use Traefik to handle traffic to backend WLS domains. | ||
## Configure Traefik as a load balancer for WebLogic domains | ||
This section describes how to use Traefik to handle traffic to backend WebLogic domains. | ||
|
||
### 1. Install WLS domains | ||
Now we need to prepare some domains for Traefik load balancing. | ||
### 1. Install WebLogic domains | ||
First, we need to prepare two domains for Traefik load balancing. | ||
|
||
Create two WLS domains: | ||
- One domain with name `domain1` under namespace `default`. | ||
- One domain with name `domain2` under namespace `test1`. | ||
Create two WebLogic domains: | ||
- One domain with `domain1` as the domain UID and namespace `weblogic-domain1`. | ||
- One domain with `domain2` as the domain UID and namespace `weblogic-domain2`. | ||
- Each domain has a web application installed with the URL context `testwebapp`. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Removed the dash before the sentences There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. done |
||
- Each domain has a WebLogic cluster `cluster-1` where each Managed Server listens on port `8001`. | ||
|
||
### 2. Install the Traefik Ingress | ||
#### Install a host-routing Ingress | ||
### 2. Web request routing | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You need to add a sentence under the heading, "Web request routing", maybe something that describes what the next three sections show. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't see this change: You need to add a sentence under the heading, "Web request routing", maybe something that describes what the next three sections show. (Pani) I am not sure, how you can not see the change. I have updated it few days back Now the document is read follows ... 2. Web request routingThe following sections describe how to route an application web request to the WebLogic domain through a Traefik frontend. Host-based routingThis sample demonstrates how to access an application on two WebLogic domains using host-based routing. Install a host-based routing Traefik IngressRoute. Path-based routingThis sample demonstrates how to access an application on two WebLogic domains using path-based routing. Install a path-based routing Traefik IngressRoute and Middleware. |
||
The following sections describe how to route an application web request to the WebLogic domain through a Traefik frontend. | ||
|
||
#### Host-based routing | ||
This sample demonstrates how to access an application on two WebLogic domains using host-based routing. Install a host-based routing Traefik [IngressRoute](https://docs.traefik.io/routing/providers/kubernetes-crd/#kind-ingressroute). | ||
``` | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. should be a lead in sentence to explain the context, not just a heading then a command There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Now I added 3 sub headings under a section 2 2. Web request routingHost-based routingPath-based routingHost-based secured routingEach section/subsection has a descriptions explaining the content |
||
$ kubectl create -f samples/host-routing.yaml | ||
ingressroute.traefik.containo.us/traefik-hostrouting-1 created | ||
ingressroute.traefik.containo.us/traefik-hostrouting-2 created | ||
``` | ||
Now you can send requests to different WLS domains with the unique entry point of Traefik with different hostnames. | ||
Now you can send requests to different WebLogic domains with the unique Traefik entry point of different host names as defined in route section of `host-routing.yaml` file. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. as defined in route section -> as defined in the route section (add missing word, the) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. done in latest commit |
||
``` | ||
$ curl -H 'host: domain1.org' http://${HOSTNAME}:30305/testwebapp/ | ||
$ curl -H 'host: domain2.org' http://${HOSTNAME}:30305/testwebapp/ | ||
# Get the ingress controller web port | ||
$ export LB_PORT=$(kubectl -n traefik get service traefik-operator -o jsonpath='{.spec.ports[?(@.name=="web")].nodePort}') | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. explain what this does There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Added a line - Get the ingress controller web port |
||
$ curl -H 'host: domain1.org' http://${HOSTNAME}:${LB_PORT}/testwebapp/ | ||
$ curl -H 'host: domain2.org' http://${HOSTNAME}:${LB_PORT}/testwebapp/ | ||
``` | ||
#### Install a path-routing Ingress | ||
|
||
#### Path-based routing | ||
This sample demonstrates how to access an application on two WebLogic domains using path-based routing. Install a path-based routing Traefik [IngressRoute](https://docs.traefik.io/routing/providers/kubernetes-crd/#kind-ingressroute) and [Middleware](https://docs.traefik.io/middlewares/overview/). | ||
|
||
``` | ||
$ kubectl create -f samples/path-routing.yaml | ||
ingressroute.traefik.containo.us/traefik-pathrouting-1 created | ||
middleware.traefik.containo.us/middleware-domain1 created | ||
ingressroute.traefik.containo.us/traefik-pathrouting-2 created | ||
middleware.traefik.containo.us/middleware-domain2 created | ||
``` | ||
Now you can send requests to different WLS domains with the unique entry point of Traefik with different paths. | ||
Now you can send requests to different WebLogic domains with the unique Traefik entry point of different paths, as defined in the route section of the `path-routing.yaml` file. | ||
``` | ||
$ curl http://${HOSTNAME}:30305/domain1/ | ||
$ curl http://${HOSTNAME}:30305/domain2/ | ||
# Get the ingress controller web port | ||
$ export LB_PORT=$(kubectl -n traefik get service traefik-operator -o jsonpath='{.spec.ports[?(@.name=="web")].nodePort}') | ||
$ curl http://${HOSTNAME}:${LB_PORT}/domain1/ | ||
$ curl http://${HOSTNAME}:${LB_PORT}/domain2/ | ||
``` | ||
#### Install a TLS-enabled Ingress | ||
This sample demonstrates accessing the two WLS domains using an HTTPS endpoint and the WLS domains are protected by different TLS certificates. | ||
|
||
To make this sample work, you need to enable the TLS endpoint in the Traefik operator. If you use the `values.yaml` file in the same folder as this README, the TLS endpoint is already enabled. | ||
#### Host-based secured routing | ||
This sample demonstrates how to access an application on two WebLogic domains using an HTTPS endpoint. Install a TLS-enabled Traefik [IngressRoute](https://docs.traefik.io/routing/providers/kubernetes-crd/#kind-ingressroute). | ||
|
||
First, you need to create two secrets with TLS certificates, one with the common name `domain1.org`, the other with the common name `domain2.org`. We use `openssl` to generate self-signed certificates for demonstration purposes. Note that the TLS secret needs to be in the same namespace as the WLS domain. | ||
First, you need to create two secrets with TLS certificates, one with the common name `domain1.org`, the other with the common name `domain2.org`. We use `openssl` to generate self-signed certificates for demonstration purposes. Note that the TLS secret needs to be in the same namespace as the WebLogic domain. | ||
``` | ||
# create a TLS secret for domain1 | ||
$ openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout /tmp/tls1.key -out /tmp/tls1.crt -subj "/CN=domain1.org" | ||
$ kubectl create secret tls domain1-tls-cert --key /tmp/tls1.key --cert /tmp/tls1.crt | ||
|
||
$ kubectl -n weblogic-domain1 create secret tls domain1-tls-cert --key /tmp/tls1.key --cert /tmp/tls1.crt | ||
# create a TLS secret for domain2 | ||
$ openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout /tmp/tls2.key -out /tmp/tls2.crt -subj "/CN=domain2.org" | ||
$ kubectl -n test1 create secret tls domain2-tls-cert --key /tmp/tls2.key --cert /tmp/tls2.crt | ||
``` | ||
Then deploy the TLS Ingress. | ||
``` | ||
$ kubectl -n weblogic-domain2 create secret tls domain2-tls-cert --key /tmp/tls2.key --cert /tmp/tls2.crt | ||
|
||
# Deploy a TLS IngressRoute. | ||
$ kubectl create -f samples/tls.yaml | ||
ingressroute.traefik.containo.us/traefik-tls-1 created | ||
ingressroute.traefik.containo.us/traefik-tls-2 created | ||
``` | ||
Now you can access the two WLS domains with different hostnames using the HTTPS endpoint. | ||
Now you can access the application on the WebLogic domain with the host name in HTTP header. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. host name in HTTP header. -> host name in the HTTP header. (add missing word, the) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. done in the latest commit |
||
The ingress controller secure port can be obtained dynamically from the `traefik-operator` service in the `traefik` namespace. | ||
``` | ||
$ curl -k -H 'host: domain1.org' https://${HOSTNAME}:30443/testwebapp/ | ||
$ curl -k -H 'host: domain2.org' https://${HOSTNAME}:30443/testwebapp/ | ||
# Get the ingress controller secure web port | ||
TLS_PORT=`kubectl -n traefik get service traefik-operator -o jsonpath='{.spec.ports[?(@.name=="websecure")].nodePort}'` | ||
$ curl -k -H 'host: domain1.org' https://${HOSTNAME}:${TLS_PORT}/testwebapp/ | ||
``` | ||
|
||
## Uninstall the Traefik operator | ||
After removing all the Ingress resources, uninstall the Traefik operator: | ||
After removing all the ingress resources, uninstall the Traefik operator: | ||
``` | ||
$ helm delete --purge traefik-operator | ||
$ helm uninstall traefik-operator --namespace traefik --keep-history | ||
``` | ||
## Install and uninstall the Traefik operator with setup.sh | ||
Alternatively, you can run the helper script `setup.sh`, under the `kubernetes/samples/charts/util` folder, to install and uninstall Traefik. | ||
## Install and uninstall the Traefik operator with setupLoadBalancer.sh | ||
Alternatively, you can run the helper script `setupLoadBalancer.sh`, under the `kubernetes/samples/charts/util` folder, to install and uninstall Traefik. | ||
|
||
To install Traefik: | ||
``` | ||
$ ./setup.sh create traefik | ||
$ ./setupLoadBalancer.sh create traefik | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. traefik is an ingress controller, not a load balancer, they are different things There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. One of the suggestion by @tbarnes-us to ( Rename to something less generic than 'setup.sh' ( e.g. setupLoadBalancer.sh ). Here we are not referring to K8s object rather a generic fronted load balancer to route web request. Should I rename to setupProxy.sh or any other suggestion ? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Traefik still describes itself as an Ingress Controller, but using a CustomResourceDefinition: https://docs.traefik.io/providers/kubernetes-crd/. It's still confusing to call it a load balancer. |
||
``` | ||
To uninstall Traefik: | ||
``` | ||
$ ./setup.sh delete traefik | ||
$ ./setupLoadBalancer.sh delete traefik | ||
``` |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,35 +1,34 @@ | ||
apiVersion: networking.k8s.io/v1beta1 | ||
kind: Ingress | ||
# Copyright (c) 2018, 2020, Oracle Corporation and/or its affiliates. | ||
# Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl. | ||
|
||
apiVersion: traefik.containo.us/v1alpha1 | ||
kind: IngressRoute | ||
tbarnes-us marked this conversation as resolved.
Show resolved
Hide resolved
|
||
metadata: | ||
annotations: | ||
kubernetes.io/ingress.class: traefik | ||
name: traefik-hostrouting-1 | ||
namespace: default | ||
namespace: weblogic-domain1 | ||
spec: | ||
rules: | ||
- host: domain1.org | ||
http: | ||
paths: | ||
- path: | ||
backend: | ||
serviceName: domain1-cluster-cluster-1 | ||
servicePort: 8001 | ||
|
||
routes: | ||
- kind: Rule | ||
match: Host(`domain1.org`) | ||
services: | ||
- kind: Service | ||
name: domain1-cluster-cluster-1 | ||
port: 8001 | ||
--- | ||
apiVersion: networking.k8s.io/v1beta1 | ||
kind: Ingress | ||
apiVersion: traefik.containo.us/v1alpha1 | ||
kind: IngressRoute | ||
metadata: | ||
annotations: | ||
kubernetes.io/ingress.class: traefik | ||
name: traefik-hostrouting-2 | ||
namespace: test1 | ||
namespace: weblogic-domain2 | ||
spec: | ||
rules: | ||
- host: domain2.org | ||
http: | ||
paths: | ||
- path: | ||
backend: | ||
serviceName: domain2-cluster-cluster-1 | ||
servicePort: 8001 | ||
|
||
routes: | ||
- kind: Rule | ||
match: Host(`domain2.org`) | ||
services: | ||
- kind: Service | ||
name: domain2-cluster-cluster-1 | ||
port: 8001 |
Uh oh!
There was an error while loading. Please reload this page.