Improve documentation for kubernetes ingress configuration

Co-authored-by: jbdoumenjou <jb.doumenjou@gmail.com>
This commit is contained in:
robotte 2020-03-09 13:48:06 +01:00 committed by GitHub
parent d0f8c1834d
commit e511cfe2e4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -9,74 +9,184 @@ The provider then watches for incoming ingresses events, such as the example bel
and derives the corresponding dynamic configuration from it, and derives the corresponding dynamic configuration from it,
which in turn will create the resulting routers, services, handlers, etc. which in turn will create the resulting routers, services, handlers, etc.
```yaml ## Configuration Example
kind: Ingress
apiVersion: networking.k8s.io/v1beta1
metadata:
name: foo
namespace: production
spec: ??? example "Configuring Kubernetes Ingress Controller"
```yaml tab="RBAC"
---
kind: ClusterRole
apiVersion: rbac.authorization.k8s.io/v1beta1
metadata:
name: traefik-ingress-controller
rules: rules:
- host: foo.com - apiGroups:
http: - ""
paths: resources:
- path: /bar - services
backend: - endpoints
serviceName: service1 - secrets
servicePort: 80 verbs:
- path: /foo - get
backend: - list
serviceName: service1 - watch
servicePort: 80 - apiGroups:
- extensions
resources:
- ingresses
verbs:
- get
- list
- watch
- apiGroups:
- extensions
resources:
- ingresses/status
verbs:
- update
tls: ---
- secretName: mySecret kind: ClusterRoleBinding
``` apiVersion: rbac.authorization.k8s.io/v1beta1
metadata:
### Annotations name: traefik-ingress-controller
roleRef:
??? example apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: traefik-ingress-controller
subjects:
- kind: ServiceAccount
name: traefik-ingress-controller
namespace: default
```
```yaml tab="Ingress" ```yaml tab="Ingress"
kind: Ingress kind: Ingress
apiVersion: networking.k8s.io/v1beta1 apiVersion: networking.k8s.io/v1beta1
metadata: metadata:
name: foo name: myingress
namespace: production
annotations: annotations:
traefik.ingress.kubernetes.io/router.entrypoints: web traefik.ingress.kubernetes.io/router.entrypoints: web
spec: spec:
rules: rules:
- host: foo.com - host: mydomain.com
http: http:
paths: paths:
- path: /bar - path: /bar
backend: backend:
serviceName: service1 serviceName: whoami
servicePort: 80 servicePort: 80
- path: /foo - path: /foo
backend: backend:
serviceName: service1 serviceName: whoami
servicePort: 80 servicePort: 80
``` ```
```yaml tab="Service" ```yaml tab="Traefik"
kind: Service
apiVersion: v1 apiVersion: v1
kind: ServiceAccount
metadata: metadata:
name: service1 name: traefik-ingress-controller
namespace: testing
annotations: ---
traefik.ingress.kubernetes.io/service.passhostheader: "false" kind: Deployment
apiVersion: apps/v1
metadata:
name: traefik
labels:
app: traefik
spec:
replicas: 1
selector:
matchLabels:
app: traefik
template:
metadata:
labels:
app: traefik
spec:
serviceAccountName: traefik-ingress-controller
containers:
- name: traefik
image: traefik:v2.2
args:
- --log.level=DEBUG
- --api
- --api.insecure
- --entrypoints.web.address=:80
- --providers.kubernetesingress
ports:
- name: web
containerPort: 80
- name: admin
containerPort: 8080
---
apiVersion: v1
kind: Service
metadata:
name: traefik
spec:
type: LoadBalancer
selector:
app: traefik
ports:
- protocol: TCP
port: 80
name: web
targetPort: 80
- protocol: TCP
port: 8080
name: admin
targetPort: 8080
```
```yaml tab="Whoami"
kind: Deployment
apiVersion: apps/v1
metadata:
name: whoami
labels:
app: containous
name: whoami
spec:
replicas: 2
selector:
matchLabels:
app: containous
task: whoami
template:
metadata:
labels:
app: containous
task: whoami
spec:
containers:
- name: containouswhoami
image: containous/whoami
ports:
- containerPort: 80
---
apiVersion: v1
kind: Service
metadata:
name: whoami
spec: spec:
ports: ports:
- port: 80 - name: http
clusterIp: 10.0.0.1 port: 80
selector:
app: containous
task: whoami
``` ```
## Annotations
#### On Ingress #### On Ingress
??? info "`traefik.ingress.kubernetes.io/router.entrypoints`" ??? info "`traefik.ingress.kubernetes.io/router.entrypoints`"