Skip to content
This repository has been archived by the owner on Apr 27, 2021. It is now read-only.

Sync upstream #159

Merged
merged 65 commits into from
Nov 22, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
65 commits
Select commit Hold shift + click to select a range
5195600
Allows ModSecurity to be configured per location
Nov 4, 2018
d97999c
Merge pull request #3309 from diazjf/modsecurity-location
k8s-ci-robot Nov 7, 2018
b85f1fa
Fix typos
mikeweiwei Nov 8, 2018
92e540d
Merge pull request #3379 from mikeweiwei/my_fix
k8s-ci-robot Nov 8, 2018
b3d789e
Fix typos: reqrite -> rewrite
mooncak Nov 8, 2018
d2b1d37
Modify the wrong function name
xichengliudui Nov 8, 2018
889ead8
Merge pull request #3382 from mooncak/fix_bug
k8s-ci-robot Nov 9, 2018
50e30b4
Update annotations.md
cjyyb Nov 9, 2018
5928bc5
Merge pull request #3388 from crystaljade/patch-5
k8s-ci-robot Nov 9, 2018
950a2f9
Merge pull request #3387 from xichengliudui/fix181109
k8s-ci-robot Nov 9, 2018
95db733
add e2e test for round robin load balancing
Nov 9, 2018
5cc1399
Fix link in documentation [skip ci] (#3392)
aledbf Nov 9, 2018
55104c9
Merge pull request #3390 from Shopify/rr-e2e
k8s-ci-robot Nov 9, 2018
2d64e15
Fix some documents issues
mooncak Nov 10, 2018
14fe489
Merge pull request #3395 from mooncak/fix_doc_issue
k8s-ci-robot Nov 11, 2018
e1720d6
Prevent X-Forwarded-Proto forward during external auth subrequest
wayt Nov 9, 2018
e20d651
Update nginx and e2e image
aledbf Nov 12, 2018
ddd8eef
Update nginx image (#3404)
aledbf Nov 12, 2018
8b32c4c
Restructure load balance e2e tests and update round robin test
Nov 12, 2018
97b9bf9
Merge pull request #3406 from aledbf/update-image
k8s-ci-robot Nov 12, 2018
01a343c
Merge pull request #3407 from Shopify/rr-e2e
k8s-ci-robot Nov 12, 2018
debf024
Fix modsecurity configuration file location (#3408)
aledbf Nov 12, 2018
0232611
Merge pull request #3405 from Shopify/external-auth-proto
k8s-ci-robot Nov 12, 2018
2850fb5
fix logging calls
mikeweiwei Nov 13, 2018
4e4ec8b
Merge pull request #3410 from mikeweiwei/fix_glog
k8s-ci-robot Nov 13, 2018
41c925f
bugfix: set canary attributes when initializing balancer
ElvinEfendi Nov 13, 2018
764740a
be more defensive when deciding alternative balancer
ElvinEfendi Nov 13, 2018
9d4060c
Merge pull request #3415 from Shopify/fix-canary-bug
k8s-ci-robot Nov 13, 2018
0f3e2b9
Convert isValidClientBodyBufferSize to something more generic and use…
wayt Nov 9, 2018
a22c656
Merge pull request #3409 from Shopify/client-max-body-size
k8s-ci-robot Nov 13, 2018
ec28539
bugfix: do not merge catch-all canary backends with itself
Nov 13, 2018
20b095f
Fix X-Forwarded-Proto typo
wayt Nov 14, 2018
3febf97
Merge pull request #3421 from Shopify/external-auth-typo
k8s-ci-robot Nov 14, 2018
95b3042
Add a Snippet for ModSecurity
Nov 15, 2018
8aad76e
[404-server] Removes 404 server (#3156)
jonpulsifer Nov 15, 2018
c685662
Update nginx image
aledbf Nov 16, 2018
f314d88
Update nginx modules (#3425)
aledbf Nov 16, 2018
d26543a
Merge pull request #3424 from aledbf/update-image
k8s-ci-robot Nov 16, 2018
168f30d
Revert removal of support for TCP and UDP services
aledbf Nov 16, 2018
a2d50c2
Set proxy_host variable to avoid using default value from proxy_pass
aledbf Nov 16, 2018
654eced
Add tcp e2e test
aledbf Nov 16, 2018
442b01e
Merge pull request #3400 from diazjf/more-modsecurity
k8s-ci-robot Nov 17, 2018
34598e7
Merge pull request #3428 from aledbf/set-variables
k8s-ci-robot Nov 18, 2018
af2dce9
Fix tests
aledbf Nov 16, 2018
a51136b
Refactor assertions
aledbf Nov 18, 2018
bf7ad0d
Merge pull request #3374 from aledbf/restore-tcp-udp
k8s-ci-robot Nov 18, 2018
50b29fe
Add annotation for session affinity path
Nov 19, 2018
82721e5
Merge pull request #3372 from Shopify/session-cookie-path
k8s-ci-robot Nov 19, 2018
2b109b3
Only set cookies on paths that enable session affinity
Nov 19, 2018
e1780b4
Merge pull request #3383 from Shopify/affinity-fix
k8s-ci-robot Nov 20, 2018
96f5ae6
Merge pull request #3417 from Shopify/fix_canary_merge_self_def
k8s-ci-robot Nov 20, 2018
12766cd
Use struct to pack Ingress and its annotations
wayt Nov 19, 2018
35b8023
Match body buffer to max upload size
aledbf Nov 20, 2018
a534182
Increase log level when there is an invalid size value
aledbf Nov 20, 2018
5bf4221
Merge pull request #3442 from aledbf/increase-log-level
k8s-ci-robot Nov 21, 2018
e0f15af
Merge pull request #3441 from aledbf/match-buffer
k8s-ci-robot Nov 21, 2018
c99716a
Merge pull request #3437 from Shopify/ingress-annotations
k8s-ci-robot Nov 21, 2018
5d4dc78
Remove initial log error during reconfiguration
aledbf Nov 20, 2018
003027b
Merge pull request #3443 from aledbf/initial-reload
k8s-ci-robot Nov 21, 2018
068d633
fix Status key conflic, fixes https://github.com/kubernetes/ingress-n…
ElvinEfendi Nov 21, 2018
d8b928f
remove already unused endpoint metric
ElvinEfendi Nov 21, 2018
8aac340
Merge pull request #3453 from Shopify/monitor-fixes
k8s-ci-robot Nov 21, 2018
6eac578
Rever TCP/UDP documentation removal and links (#3456)
aledbf Nov 22, 2018
84c5575
Merge remote-tracking branch 'upstream/master' into sync-upstream
ElvinEfendi Nov 22, 2018
0b2625d
fix merge conflict resolution
ElvinEfendi Nov 22, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ IMAGE = $(REGISTRY)/$(IMGNAME)
MULTI_ARCH_IMG = $(IMAGE)-$(ARCH)

# Set default base image dynamically for each arch
BASEIMAGE?=quay.io/kubernetes-ingress-controller/nginx-$(ARCH):0.69
BASEIMAGE?=quay.io/kubernetes-ingress-controller/nginx-$(ARCH):0.70

ifeq ($(ARCH),arm)
QEMUARCH=arm
Expand Down
2 changes: 1 addition & 1 deletion build/go-in-docker.sh
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ if [ "$missing" = true ];then
exit 1
fi

E2E_IMAGE=quay.io/kubernetes-ingress-controller/e2e:v11122018-14fe4898a
E2E_IMAGE=quay.io/kubernetes-ingress-controller/e2e:v11162018-ef7143f5a

DOCKER_OPTS=${DOCKER_OPTS:-""}

Expand Down
14 changes: 14 additions & 0 deletions cmd/nginx/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,18 @@ Takes the form "namespace/name". When used together with update-status, the
controller mirrors the address of this service's endpoints to the load-balancer
status of all Ingress objects it satisfies.`)

tcpConfigMapName = flags.String("tcp-services-configmap", "",
`Name of the ConfigMap containing the definition of the TCP services to expose.
The key in the map indicates the external port to be used. The value is a
reference to a Service in the form "namespace/name:port", where "port" can
either be a port number or name. TCP ports 80 and 443 are reserved by the
controller for servicing HTTP traffic.`)
udpConfigMapName = flags.String("udp-services-configmap", "",
`Name of the ConfigMap containing the definition of the UDP services to expose.
The key in the map indicates the external port to be used. The value is a
reference to a Service in the form "namespace/name:port", where "port" can
either be a port name or number.`)

resyncPeriod = flags.Duration("sync-period", 0,
`Period at which the controller forces the repopulation of its local object stores. Disabled by default.`)

Expand Down Expand Up @@ -217,6 +229,8 @@ Feature backed by OpenResty Lua libraries. Requires that OCSP stapling is not en
DefaultService: *defaultSvc,
Namespace: *watchNamespace,
ConfigMapName: *configMap,
TCPConfigMapName: *tcpConfigMapName,
UDPConfigMapName: *udpConfigMapName,
DefaultSSLCertificate: *defSSLCertificate,
DefaultHealthzURL: *defHealthzURL,
HealthCheckTimeout: *healthCheckTimeout,
Expand Down
17 changes: 17 additions & 0 deletions deploy/configmap.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,21 @@ metadata:
app.kubernetes.io/part-of: ingress-nginx

---
kind: ConfigMap
apiVersion: v1
metadata:
name: tcp-services
namespace: ingress-nginx
labels:
app.kubernetes.io/name: ingress-nginx
app.kubernetes.io/part-of: ingress-nginx

---
kind: ConfigMap
apiVersion: v1
metadata:
name: udp-services
namespace: ingress-nginx
labels:
app.kubernetes.io/name: ingress-nginx
app.kubernetes.io/part-of: ingress-nginx
6 changes: 3 additions & 3 deletions deploy/mandatory.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ metadata:
name: ingress-nginx

---

kind: ConfigMap
apiVersion: v1
metadata:
Expand All @@ -15,7 +14,6 @@ metadata:
app.kubernetes.io/part-of: ingress-nginx

---

apiVersion: v1
kind: ServiceAccount
metadata:
Expand Down Expand Up @@ -162,7 +160,6 @@ subjects:
namespace: ingress-nginx

---

apiVersion: extensions/v1beta1
kind: Deployment
metadata:
Expand Down Expand Up @@ -193,6 +190,8 @@ spec:
args:
- /nginx-ingress-controller
- --configmap=$(POD_NAMESPACE)/nginx-configuration
- --tcp-services-configmap=$(POD_NAMESPACE)/tcp-services
- --udp-services-configmap=$(POD_NAMESPACE)/udp-services
- --publish-service=$(POD_NAMESPACE)/ingress-nginx
- --annotations-prefix=nginx.ingress.kubernetes.io
securityContext:
Expand Down Expand Up @@ -238,3 +237,4 @@ spec:
timeoutSeconds: 1

---

2 changes: 2 additions & 0 deletions deploy/with-rbac.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ spec:
args:
- /nginx-ingress-controller
- --configmap=$(POD_NAMESPACE)/nginx-configuration
- --tcp-services-configmap=$(POD_NAMESPACE)/tcp-services
- --udp-services-configmap=$(POD_NAMESPACE)/udp-services
- --publish-service=$(POD_NAMESPACE)/ingress-nginx
- --annotations-prefix=nginx.ingress.kubernetes.io
securityContext:
Expand Down
2 changes: 1 addition & 1 deletion docs/deploy/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ kubectl apply -f https://raw.githubusercontent.com/kubernetes/ingress-nginx/mast
```

!!! tip
For extended notes regarding deployments on bare-metal, see [Bare-metal considerations](./baremetal.md/).
For extended notes regarding deployments on bare-metal, see [Bare-metal considerations](./baremetal.md).

### Verify installation

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

## Ingress

The Ingress in this example adds a custom header to Nginx configuration that only applies to that specific Ingress. If you want to add headers that apply globally to all Ingresses, please have a look at [this example](/examples/customization/custom-headers/README).
The Ingress in this example adds a custom header to Nginx configuration that only applies to that specific Ingress. If you want to add headers that apply globally to all Ingresses, please have a look at [this example](../custom-headers/README.md).

```console
$ kubectl apply -f ingress.yaml
Expand Down
2 changes: 2 additions & 0 deletions docs/user-guide/cli-arguments.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ They are set in the container spec of the `nginx-ingress-controller` Deployment
| `--stderrthreshold severity` | logs at or above this threshold go to stderr (default 2) |
| `--sync-period duration` | Period at which the controller forces the repopulation of its local object stores. Disabled by default. |
| `--sync-rate-limit float32` | Define the sync frequency upper limit (default 0.3) |
| `--tcp-services-configmap string` | Name of the ConfigMap containing the definition of the TCP services to expose. The key in the map indicates the external port to be used. The value is a reference to a Service in the form "namespace/name:port", where "port" can either be a port number or name. TCP ports 80 and 443 are reserved by the controller for servicing HTTP traffic. |
| `--udp-services-configmap string` | Name of the ConfigMap containing the definition of the UDP services to expose. The key in the map indicates the external port to be used. The value is a reference to a Service in the form "namespace/name:port", where "port" can either be a port name or number. |
| `--update-status` | Update the load-balancer status of Ingress objects this controller satisfies. Requires setting the publish-service parameter to a valid Service reference. (default true) |
| `--update-status-on-shutdown` | Update the load-balancer status of Ingress objects when the controller shuts down. Requires the update-status parameter. (default true) |
| `-v`, `--v Level` | log level for V logs |
Expand Down
63 changes: 63 additions & 0 deletions docs/user-guide/exposing-tcp-udp-services.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
# Exposing TCP and UDP services

Ingress does not support TCP or UDP services. For this reason this Ingress controller uses the flags `--tcp-services-configmap` and `--udp-services-configmap` to point to an existing config map where the key is the external port to use and the value indicates the service to expose using the format:
`<namespace/service name>:<service port>:[PROXY]:[PROXY]`

It is also possible to use a number or the name of the port. The two last fields are optional.
Adding `PROXY` in either or both of the two last fields we can use Proxy Protocol decoding (listen) and/or encoding (proxy_pass) in a TCP service https://www.nginx.com/resources/admin-guide/proxy-protocol

The next example shows how to expose the service `example-go` running in the namespace `default` in the port `8080` using the port `9000`

```yaml
apiVersion: v1
kind: ConfigMap
metadata:
name: tcp-services
namespace: ingress-nginx
data:
9000: "default/example-go:8080"
```

Since 1.9.13 NGINX provides [UDP Load Balancing](https://www.nginx.com/blog/announcing-udp-load-balancing/).
The next example shows how to expose the service `kube-dns` running in the namespace `kube-system` in the port `53` using the port `53`

```yaml
apiVersion: v1
kind: ConfigMap
metadata:
name: udp-services
namespace: ingress-nginx
data:
53: "kube-system/kube-dns:53"
```

If TCP/UDP proxy support is used, then those ports need to be exposed in the Service defined for the Ingress.

```yaml
apiVersion: v1
kind: Service
metadata:
name: ingress-nginx
namespace: ingress-nginx
labels:
app.kubernetes.io/name: ingress-nginx
app.kubernetes.io/part-of: ingress-nginx
spec:
type: LoadBalancer
ports:
- name: http
port: 80
targetPort: 80
protocol: TCP
- name: https
port: 443
targetPort: 443
protocol: TCP
- name: proxied-tcp-9000
port: 9000
targetPort: 9000
protocol: TCP
selector:
app.kubernetes.io/name: ingress-nginx
app.kubernetes.io/part-of: ingress-nginx
```
29 changes: 28 additions & 1 deletion docs/user-guide/nginx-configuration/annotations.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ You can add these Kubernetes annotations to specific Ingress objects to customiz
|[nginx.ingress.kubernetes.io/service-upstream](#service-upstream)|"true" or "false"|
|[nginx.ingress.kubernetes.io/session-cookie-name](#cookie-affinity)|string|
|[nginx.ingress.kubernetes.io/session-cookie-hash](#cookie-affinity)|string|
|[nginx.ingress.kubernetes.io/session-cookie-path](#cookie-affinity)|string|
|[nginx.ingress.kubernetes.io/ssl-redirect](#server-side-https-enforcement-through-redirect)|"true" or "false"|
|[nginx.ingress.kubernetes.io/ssl-passthrough](#ssl-passthrough)|"true" or "false"|
|[nginx.ingress.kubernetes.io/upstream-hash-by](#custom-nginx-upstream-hashing)|string|
Expand Down Expand Up @@ -98,7 +99,7 @@ You can add these Kubernetes annotations to specific Ingress objects to customiz
|[nginx.ingress.kubernetes.io/enable-modsecurity](#modsecurity)|bool|
|[nginx.ingress.kubernetes.io/enable-owasp-core-rules](#modsecurity)|bool|
|[nginx.ingress.kubernetes.io/modsecurity-transaction-id](#modsecurity)|string|

|[nginx.ingress.kubernetes.io/modsecurity-snippet](#modsecurity)|string|

### Canary

Expand Down Expand Up @@ -136,6 +137,9 @@ If the Application Root is exposed in a different path and needs to be redirecte
The annotation `nginx.ingress.kubernetes.io/affinity` enables and sets the affinity type in all Upstreams of an Ingress. This way, a request will always be directed to the same upstream server.
The only affinity type available for NGINX is `cookie`.

!!! attention
If more than one Ingress is defined for a host and at least one Ingress uses `nginx.ingress.kubernetes.io/affinity: cookie`, then only paths on the Ingress using `nginx.ingress.kubernetes.io/affinity` will use session cookie affinity. All paths defined on other Ingresses for the host will be load balanced through the random selection of a backend server.

!!! example
Please check the [affinity](../../examples/affinity/cookie/README.md) example.

Expand All @@ -145,6 +149,8 @@ If you use the ``cookie`` affinity type you can also specify the name of the coo

In case of NGINX the annotation `nginx.ingress.kubernetes.io/session-cookie-hash` defines which algorithm will be used to hash the used upstream. Default value is `md5` and possible values are `md5`, `sha1` and `index`.

The NGINX annotation `nginx.ingress.kubernetes.io/session-cookie-path` defines the path that will be set on the cookie. This is optional unless the annotation `nginx.ingress.kubernetes.io/use-regex` is set to true; Session cookie paths do not support regex.

!!! attention
The `index` option is not an actual hash; an in-memory index is used instead, which has less overhead.
However, with `index`, matching against a changing upstream server list is inconsistent.
Expand Down Expand Up @@ -649,6 +655,7 @@ It can be enabled using the following annotation:
```yaml
nginx.ingress.kubernetes.io/enable-modsecurity: "true"
```
ModSecurity will run in "Detection-Only" mode using the [recommended configuration](https://github.com/SpiderLabs/ModSecurity/blob/v3/master/modsecurity.conf-recommended).

You can enable the [OWASP Core Rule Set](https://www.modsecurity.org/CRS/Documentation/) by
setting the following annotation:
Expand All @@ -661,6 +668,23 @@ You can pass transactionIDs from nginx by setting up the following:
nginx.ingress.kubernetes.io/modsecurity-transaction-id: "$request_id"
```

You can also add your own set of modsecurity rules via a snippet:
```yaml
nginx.ingress.kubernetes.io/modsecurity-snippet: |
SecRuleEngine On
SecDebugLog /tmp/modsec_debug.log
```

Note: If you use both `enable-owasp-core-rules` and `modsecurity-snippet` annotations together, only the
`modsecurity-snippet` will take effect. If you wish to include the [OWASP Core Rule Set](https://www.modsecurity.org/CRS/Documentation/) or
[recommended configuration](https://github.com/SpiderLabs/ModSecurity/blob/v3/master/modsecurity.conf-recommended) simply use the include
statement:
```yaml
nginx.ingress.kubernetes.io/modsecurity-snippet: |
Include /etc/nginx/owasp-modsecurity-crs/nginx-modsecurity.conf
Include /etc/nginx/modsecurity/modsecurity.conf
```

### InfluxDB

Using `influxdb-*` annotations we can monitor requests passing through a Location by sending them to an InfluxDB backend exposing the UDP socket
Expand Down Expand Up @@ -699,6 +723,9 @@ nginx.ingress.kubernetes.io/backend-protocol: "HTTPS"

### Use Regex

!!! attention
When using this annotation with the NGINX annotation `nginx.ingress.kubernetes.io/affinity` of type `cookie`, `nginx.ingress.kubernetes.io/session-cookie-path` must be also set; Session cookie paths do not support regex.

Using the `nginx.ingress.kubernetes.io/use-regex` annotation will indicate whether or not the paths defined on an Ingress use regular expressions. The default value is `false`.

The following will indicate that regular expression paths are being used:
Expand Down
2 changes: 1 addition & 1 deletion docs/user-guide/nginx-configuration/configmap.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ The following table shows a configuration option's name, type, and the default v
|[keep-alive-requests](#keep-alive-requests)|int|100|
|[large-client-header-buffers](#large-client-header-buffers)|string|"4 8k"|
|[log-format-escape-json](#log-format-escape-json)|bool|"false"|
|[log-format-upstream](#log-format-upstream)|string|`%v - [$the_real_ip] - $remote_user [$time_local] "$request" $status $body_bytes_sent "$http_referer" "$http_user_agent" $request_length $request_time [$proxy_upstream_name] $upstream_addr $upstream_response_length $upstream_response_time $upstream_status`|
|[log-format-upstream](#log-format-upstream)|string|`%v - [$the_real_ip] - $remote_user [$time_local] "$request" $status $body_bytes_sent "$http_referer" "$http_user_agent" $request_length $request_time [$proxy_upstream_name] $upstream_addr $upstream_response_length $upstream_response_time $upstream_status $req_id`|
|[log-format-stream](#log-format-stream)|string|`[$time_local] $protocol $status $bytes_sent $bytes_received $session_time`|
|[enable-multi-accept](#enable-multi-accept)|bool|"true"|
|[max-worker-connections](#max-worker-connections)|int|16384|
Expand Down
3 changes: 2 additions & 1 deletion docs/user-guide/nginx-configuration/log-format.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ log_format upstreaminfo
'[$the_real_ip] - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" "$http_user_agent" '
'$request_length $request_time [$proxy_upstream_name] $upstream_addr '
'$upstream_response_length $upstream_response_time $upstream_status';
'$upstream_response_length $upstream_response_time $upstream_status $req_id';
```

| Placeholder | Description |
Expand All @@ -30,6 +30,7 @@ log_format upstreaminfo
| `$upstream_response_length` | the length of the response obtained from the upstream server |
| `$upstream_response_time` | time spent on receiving the response from the upstream server as seconds with millisecond resolution |
| `$upstream_status` | status code of the response obtained from the upstream server |
| `$req_id` | the randomly generated ID of the request |

Additional available variables:

Expand Down
1 change: 0 additions & 1 deletion images/404-server/.gitignore

This file was deleted.

20 changes: 0 additions & 20 deletions images/404-server/Dockerfile

This file was deleted.

57 changes: 0 additions & 57 deletions images/404-server/Godeps/Godeps.json

This file was deleted.

5 changes: 0 additions & 5 deletions images/404-server/Godeps/Readme

This file was deleted.

Loading