diff --git a/404.html b/404.html index 56dfe0070..6e398e11e 100644 --- a/404.html +++ b/404.html @@ -1 +1 @@ - Ingress-Nginx Controller
\ No newline at end of file + Ingress-Nginx Controller
\ No newline at end of file diff --git a/deploy/baremetal/index.html b/deploy/baremetal/index.html index f95e08951..cd190609b 100644 --- a/deploy/baremetal/index.html +++ b/deploy/baremetal/index.html @@ -1,4 +1,4 @@ - Bare-metal considerations - Ingress-Nginx Controller
Skip to content

Bare-metal considerations

In traditional cloud environments, where network load balancers are available on-demand, a single Kubernetes manifest suffices to provide a single point of contact to the Ingress-Nginx Controller to external clients and, indirectly, to any application running inside the cluster. Bare-metal environments lack this commodity, requiring a slightly different setup to offer the same kind of access to external consumers.

Cloud environment Bare-metal environment

The rest of this document describes a few recommended approaches to deploying the Ingress-Nginx Controller inside a Kubernetes cluster running on bare-metal.

A pure software solution: MetalLB

MetalLB provides a network load-balancer implementation for Kubernetes clusters that do not run on a supported cloud provider, effectively allowing the usage of LoadBalancer Services within any cluster.

This section demonstrates how to use the Layer 2 configuration mode of MetalLB together with the NGINX Ingress controller in a Kubernetes cluster that has publicly accessible nodes. In this mode, one node attracts all the traffic for the ingress-nginx Service IP. See Traffic policies for more details.

MetalLB in L2 mode

Note

The description of other supported configuration modes is off-scope for this document.

Warning

MetalLB is currently in beta. Read about the Project maturity and make sure you inform yourself by reading the official documentation thoroughly.

MetalLB can be deployed either with a simple Kubernetes manifest or with Helm. The rest of this example assumes MetalLB was deployed following the Installation instructions, and that the Ingress-Nginx Controller was installed using the steps described in the quickstart section of the installation guide.

MetalLB requires a pool of IP addresses in order to be able to take ownership of the ingress-nginx Service. This pool can be defined through IPAddressPool objects in the same namespace as the MetalLB controller. This pool of IPs must be dedicated to MetalLB's use, you can't reuse the Kubernetes node IPs or IPs handed out by a DHCP server.

Example

Given the following 3-node Kubernetes cluster (the external IP is added as an example, in most bare-metal environments this value is <None>)

$ kubectl get node
+ Bare-metal considerations - Ingress-Nginx Controller      

Bare-metal considerations

In traditional cloud environments, where network load balancers are available on-demand, a single Kubernetes manifest suffices to provide a single point of contact to the Ingress-Nginx Controller to external clients and, indirectly, to any application running inside the cluster. Bare-metal environments lack this commodity, requiring a slightly different setup to offer the same kind of access to external consumers.

Cloud environment Bare-metal environment

The rest of this document describes a few recommended approaches to deploying the Ingress-Nginx Controller inside a Kubernetes cluster running on bare-metal.

A pure software solution: MetalLB

MetalLB provides a network load-balancer implementation for Kubernetes clusters that do not run on a supported cloud provider, effectively allowing the usage of LoadBalancer Services within any cluster.

This section demonstrates how to use the Layer 2 configuration mode of MetalLB together with the NGINX Ingress controller in a Kubernetes cluster that has publicly accessible nodes. In this mode, one node attracts all the traffic for the ingress-nginx Service IP. See Traffic policies for more details.

MetalLB in L2 mode

Note

The description of other supported configuration modes is off-scope for this document.

Warning

MetalLB is currently in beta. Read about the Project maturity and make sure you inform yourself by reading the official documentation thoroughly.

MetalLB can be deployed either with a simple Kubernetes manifest or with Helm. The rest of this example assumes MetalLB was deployed following the Installation instructions, and that the Ingress-Nginx Controller was installed using the steps described in the quickstart section of the installation guide.

MetalLB requires a pool of IP addresses in order to be able to take ownership of the ingress-nginx Service. This pool can be defined through IPAddressPool objects in the same namespace as the MetalLB controller. This pool of IPs must be dedicated to MetalLB's use, you can't reuse the Kubernetes node IPs or IPs handed out by a DHCP server.

Example

Given the following 3-node Kubernetes cluster (the external IP is added as an example, in most bare-metal environments this value is <None>)

$ kubectl get node
 NAME     STATUS   ROLES    EXTERNAL-IP
 host-1   Ready    master   203.0.113.1
 host-2   Ready    node     203.0.113.2
diff --git a/deploy/hardening-guide/index.html b/deploy/hardening-guide/index.html
index 7fd8c1391..533689cab 100644
--- a/deploy/hardening-guide/index.html
+++ b/deploy/hardening-guide/index.html
@@ -1,4 +1,4 @@
- Hardening guide - Ingress-Nginx Controller      

Hardening Guide

Overview

There are several ways to do hardening and securing of nginx. In this documentation two guides are used, the guides are overlapping in some points:

This guide describes, what of the different configurations described in those guides is already implemented as default in the nginx implementation of kubernetes ingress, what needs to be configured, what is obsolete due to the fact that the nginx is running as container (the CIS benchmark relates to a non-containerized installation) and what is difficult or not possible.

Be aware that this is only a guide and you are responsible for your own implementation. Some of the configurations may lead to have specific clients unable to reach your site or similar consequences.

This guide refers to chapters in the CIS Benchmark. For full explanation you should refer to the benchmark document itself

Configuration Guide

Chapter in CIS benchmark Status Default Action to do if not default
1 Initial Setup
1.1 Installation
1.1.1 Ensure NGINX is installed (Scored) OK done through helm charts / following documentation to deploy nginx ingress
1.1.2 Ensure NGINX is installed from source (Not Scored) OK done through helm charts / following documentation to deploy nginx ingress
1.2 Configure Software Updates
1.2.1 Ensure package manager repositories are properly configured (Not Scored) OK done via helm, nginx version could be overwritten, however compatibility is not ensured then
1.2.2 Ensure the latest software package is installed (Not Scored) ACTION NEEDED done via helm, nginx version could be overwritten, however compatibility is not ensured then Plan for periodic updates
2 Basic Configuration
2.1 Minimize NGINX Modules
2.1.1 Ensure only required modules are installed (Not Scored) OK Already only needed modules are installed, however proposals for further reduction are welcome
2.1.2 Ensure HTTP WebDAV module is not installed (Scored) OK
2.1.3 Ensure modules with gzip functionality are disabled (Scored) OK
2.1.4 Ensure the autoindex module is disabled (Scored) OK No autoindex configs so far in ingress defaults
2.2 Account Security
2.2.1 Ensure that NGINX is run using a non-privileged, dedicated service account (Not Scored) OK Pod configured as user www-data: See this line in helm chart values. Compiled with user www-data: See this line in build script
2.2.2 Ensure the NGINX service account is locked (Scored) OK Docker design ensures this
2.2.3 Ensure the NGINX service account has an invalid shell (Scored) OK Shell is nologin: see this line in build script
2.3 Permissions and Ownership
2.3.1 Ensure NGINX directories and files are owned by root (Scored) OK Obsolete through docker-design and ingress controller needs to update the configs dynamically
2.3.2 Ensure access to NGINX directories and files is restricted (Scored) OK See previous answer
2.3.3 Ensure the NGINX process ID (PID) file is secured (Scored) OK No PID-File due to docker design
2.3.4 Ensure the core dump directory is secured (Not Scored) OK No working_directory configured by default
2.4 Network Configuration
2.4.1 Ensure NGINX only listens for network connections on authorized ports (Not Scored) OK Ensured by automatic nginx.conf configuration
2.4.2 Ensure requests for unknown host names are rejected (Not Scored) OK They are not rejected but send to the "default backend" delivering appropriate errors (mostly 404)
2.4.3 Ensure keepalive_timeout is 10 seconds or less, but not 0 (Scored) ACTION NEEDED Default is 75s configure keep-alive to 10 seconds according to this documentation
2.4.4 Ensure send_timeout is set to 10 seconds or less, but not 0 (Scored) RISK TO BE ACCEPTED Not configured, however the nginx default is 60s Not configurable
2.5 Information Disclosure
2.5.1 Ensure server_tokens directive is set to off (Scored) OK server_tokens is configured to off by default
2.5.2 Ensure default error and index.html pages do not reference NGINX (Scored) ACTION NEEDED 404 shows no version at all, 503 and 403 show "nginx", which is hardcoded see this line in nginx source code configure custom error pages at least for 403, 404 and 503 and 500
2.5.3 Ensure hidden file serving is disabled (Not Scored) ACTION NEEDED config not set configure a config.server-snippet Snippet, but beware of .well-known challenges or similar. Refer to the benchmark here please
2.5.4 Ensure the NGINX reverse proxy does not enable information disclosure (Scored) ACTION NEEDED hide not configured configure hide-headers with array of "X-Powered-By" and "Server": according to this documentation
3 Logging
3.1 Ensure detailed logging is enabled (Not Scored) OK nginx ingress has a very detailed log format by default
3.2 Ensure access logging is enabled (Scored) OK Access log is enabled by default
3.3 Ensure error logging is enabled and set to the info logging level (Scored) OK Error log is configured by default. The log level does not matter, because it is all sent to STDOUT anyway
3.4 Ensure log files are rotated (Scored) OBSOLETE Log file handling is not part of the nginx ingress and should be handled separately
3.5 Ensure error logs are sent to a remote syslog server (Not Scored) OBSOLETE See previous answer
3.6 Ensure access logs are sent to a remote syslog server (Not Scored) OBSOLETE See previous answer
3.7 Ensure proxies pass source IP information (Scored) OK Headers are set by default
4 Encryption
4.1 TLS / SSL Configuration
4.1.1 Ensure HTTP is redirected to HTTPS (Scored) OK Redirect to TLS is default
4.1.2 Ensure a trusted certificate and trust chain is installed (Not Scored) ACTION NEEDED For installing certs there are enough manuals in the web. A good way is to use lets encrypt through cert-manager Install proper certificates or use lets encrypt with cert-manager
4.1.3 Ensure private key permissions are restricted (Scored) ACTION NEEDED See previous answer
4.1.4 Ensure only modern TLS protocols are used (Scored) OK/ACTION NEEDED Default is TLS 1.2 + 1.3, while this is okay for CIS Benchmark, cipherlist.eu only recommends 1.3. This may cut off old OS's Set controller.config.ssl-protocols to "TLSv1.3"
4.1.5 Disable weak ciphers (Scored) ACTION NEEDED Default ciphers are already good, but cipherlist.eu recommends even stronger ciphers Set controller.config.ssl-ciphers to "EECDH+AESGCM:EDH+AESGCM"
4.1.6 Ensure custom Diffie-Hellman parameters are used (Scored) ACTION NEEDED No custom DH parameters are generated Generate dh parameters for each ingress deployment you use - see here for a how to
4.1.7 Ensure Online Certificate Status Protocol (OCSP) stapling is enabled (Scored) ACTION NEEDED Not enabled set via this configuration parameter
4.1.8 Ensure HTTP Strict Transport Security (HSTS) is enabled (Scored) OK HSTS is enabled by default
4.1.9 Ensure HTTP Public Key Pinning is enabled (Not Scored) ACTION NEEDED / RISK TO BE ACCEPTED HKPK not enabled by default If lets encrypt is not used, set correct HPKP header. There are several ways to implement this - with the helm charts it works via controller.add-headers. If lets encrypt is used, this is complicated, a solution here is yet unknown
4.1.10 Ensure upstream server traffic is authenticated with a client certificate (Scored) DEPENDS ON BACKEND Highly dependent on backends, not every backend allows configuring this, can also be mitigated via a service mesh If backend allows it, manual is here
4.1.11 Ensure the upstream traffic server certificate is trusted (Not Scored) DEPENDS ON BACKEND Highly dependent on backends, not every backend allows configuring this, can also be mitigated via a service mesh If backend allows it, see configuration here
4.1.12 Ensure your domain is preloaded (Not Scored) ACTION NEEDED Preload is not active by default Set controller.config.hsts-preload to true
4.1.13 Ensure session resumption is disabled to enable perfect forward security (Scored) OK Session tickets are disabled by default
4.1.14 Ensure HTTP/2.0 is used (Not Scored) OK http2 is set by default
5 Request Filtering and Restrictions
5.1 Access Control
5.1.1 Ensure allow and deny filters limit access to specific IP addresses (Not Scored) OK/ACTION NEEDED Depends on use case, geo ip module is compiled into Ingress-Nginx Controller, there are several ways to use it If needed set IP restrictions via annotations or work with config snippets (be careful with lets-encrypt-http-challenge!)
5.1.2 Ensure only whitelisted HTTP methods are allowed (Not Scored) OK/ACTION NEEDED Depends on use case If required it can be set via config snippet
5.2 Request Limits
5.2.1 Ensure timeout values for reading the client header and body are set correctly (Scored) ACTION NEEDED Default timeout is 60s Set via this configuration parameter and respective body equivalent
5.2.2 Ensure the maximum request body size is set correctly (Scored) ACTION NEEDED Default is 1m set via this configuration parameter
5.2.3 Ensure the maximum buffer size for URIs is defined (Scored) ACTION NEEDED Default is 4 8k Set via this configuration parameter
5.2.4 Ensure the number of connections per IP address is limited (Not Scored) OK/ACTION NEEDED No limit set Depends on use case, limit can be set via these annotations
5.2.5 Ensure rate limits by IP address are set (Not Scored) OK/ACTION NEEDED No limit set Depends on use case, limit can be set via these annotations
5.3 Browser Security
5.3.1 Ensure X-Frame-Options header is configured and enabled (Scored) ACTION NEEDED Header not set by default Several ways to implement this - with the helm charts it works via controller.add-headers
5.3.2 Ensure X-Content-Type-Options header is configured and enabled (Scored) ACTION NEEDED See previous answer See previous answer
5.3.3 Ensure the X-XSS-Protection Header is enabled and configured properly (Scored) ACTION NEEDED See previous answer See previous answer
5.3.4 Ensure that Content Security Policy (CSP) is enabled and configured properly (Not Scored) ACTION NEEDED See previous answer See previous answer
5.3.5 Ensure the Referrer Policy is enabled and configured properly (Not Scored) ACTION NEEDED Depends on application. It should be handled in the applications webserver itself, not in the load balancing ingress check backend webserver
6 Mandatory Access Control n/a too high level, depends on backends

Hardening Guide

Overview

There are several ways to do hardening and securing of nginx. In this documentation two guides are used, the guides are overlapping in some points:

This guide describes, what of the different configurations described in those guides is already implemented as default in the nginx implementation of kubernetes ingress, what needs to be configured, what is obsolete due to the fact that the nginx is running as container (the CIS benchmark relates to a non-containerized installation) and what is difficult or not possible.

Be aware that this is only a guide and you are responsible for your own implementation. Some of the configurations may lead to have specific clients unable to reach your site or similar consequences.

This guide refers to chapters in the CIS Benchmark. For full explanation you should refer to the benchmark document itself

Configuration Guide

Chapter in CIS benchmark Status Default Action to do if not default
1 Initial Setup
1.1 Installation
1.1.1 Ensure NGINX is installed (Scored) OK done through helm charts / following documentation to deploy nginx ingress
1.1.2 Ensure NGINX is installed from source (Not Scored) OK done through helm charts / following documentation to deploy nginx ingress
1.2 Configure Software Updates
1.2.1 Ensure package manager repositories are properly configured (Not Scored) OK done via helm, nginx version could be overwritten, however compatibility is not ensured then
1.2.2 Ensure the latest software package is installed (Not Scored) ACTION NEEDED done via helm, nginx version could be overwritten, however compatibility is not ensured then Plan for periodic updates
2 Basic Configuration
2.1 Minimize NGINX Modules
2.1.1 Ensure only required modules are installed (Not Scored) OK Already only needed modules are installed, however proposals for further reduction are welcome
2.1.2 Ensure HTTP WebDAV module is not installed (Scored) OK
2.1.3 Ensure modules with gzip functionality are disabled (Scored) OK
2.1.4 Ensure the autoindex module is disabled (Scored) OK No autoindex configs so far in ingress defaults
2.2 Account Security
2.2.1 Ensure that NGINX is run using a non-privileged, dedicated service account (Not Scored) OK Pod configured as user www-data: See this line in helm chart values. Compiled with user www-data: See this line in build script
2.2.2 Ensure the NGINX service account is locked (Scored) OK Docker design ensures this
2.2.3 Ensure the NGINX service account has an invalid shell (Scored) OK Shell is nologin: see this line in build script
2.3 Permissions and Ownership
2.3.1 Ensure NGINX directories and files are owned by root (Scored) OK Obsolete through docker-design and ingress controller needs to update the configs dynamically
2.3.2 Ensure access to NGINX directories and files is restricted (Scored) OK See previous answer
2.3.3 Ensure the NGINX process ID (PID) file is secured (Scored) OK No PID-File due to docker design
2.3.4 Ensure the core dump directory is secured (Not Scored) OK No working_directory configured by default
2.4 Network Configuration
2.4.1 Ensure NGINX only listens for network connections on authorized ports (Not Scored) OK Ensured by automatic nginx.conf configuration
2.4.2 Ensure requests for unknown host names are rejected (Not Scored) OK They are not rejected but send to the "default backend" delivering appropriate errors (mostly 404)
2.4.3 Ensure keepalive_timeout is 10 seconds or less, but not 0 (Scored) ACTION NEEDED Default is 75s configure keep-alive to 10 seconds according to this documentation
2.4.4 Ensure send_timeout is set to 10 seconds or less, but not 0 (Scored) RISK TO BE ACCEPTED Not configured, however the nginx default is 60s Not configurable
2.5 Information Disclosure
2.5.1 Ensure server_tokens directive is set to off (Scored) OK server_tokens is configured to off by default
2.5.2 Ensure default error and index.html pages do not reference NGINX (Scored) ACTION NEEDED 404 shows no version at all, 503 and 403 show "nginx", which is hardcoded see this line in nginx source code configure custom error pages at least for 403, 404 and 503 and 500
2.5.3 Ensure hidden file serving is disabled (Not Scored) ACTION NEEDED config not set configure a config.server-snippet Snippet, but beware of .well-known challenges or similar. Refer to the benchmark here please
2.5.4 Ensure the NGINX reverse proxy does not enable information disclosure (Scored) ACTION NEEDED hide not configured configure hide-headers with array of "X-Powered-By" and "Server": according to this documentation
3 Logging
3.1 Ensure detailed logging is enabled (Not Scored) OK nginx ingress has a very detailed log format by default
3.2 Ensure access logging is enabled (Scored) OK Access log is enabled by default
3.3 Ensure error logging is enabled and set to the info logging level (Scored) OK Error log is configured by default. The log level does not matter, because it is all sent to STDOUT anyway
3.4 Ensure log files are rotated (Scored) OBSOLETE Log file handling is not part of the nginx ingress and should be handled separately
3.5 Ensure error logs are sent to a remote syslog server (Not Scored) OBSOLETE See previous answer
3.6 Ensure access logs are sent to a remote syslog server (Not Scored) OBSOLETE See previous answer
3.7 Ensure proxies pass source IP information (Scored) OK Headers are set by default
4 Encryption
4.1 TLS / SSL Configuration
4.1.1 Ensure HTTP is redirected to HTTPS (Scored) OK Redirect to TLS is default
4.1.2 Ensure a trusted certificate and trust chain is installed (Not Scored) ACTION NEEDED For installing certs there are enough manuals in the web. A good way is to use lets encrypt through cert-manager Install proper certificates or use lets encrypt with cert-manager
4.1.3 Ensure private key permissions are restricted (Scored) ACTION NEEDED See previous answer
4.1.4 Ensure only modern TLS protocols are used (Scored) OK/ACTION NEEDED Default is TLS 1.2 + 1.3, while this is okay for CIS Benchmark, cipherlist.eu only recommends 1.3. This may cut off old OS's Set controller.config.ssl-protocols to "TLSv1.3"
4.1.5 Disable weak ciphers (Scored) ACTION NEEDED Default ciphers are already good, but cipherlist.eu recommends even stronger ciphers Set controller.config.ssl-ciphers to "EECDH+AESGCM:EDH+AESGCM"
4.1.6 Ensure custom Diffie-Hellman parameters are used (Scored) ACTION NEEDED No custom DH parameters are generated Generate dh parameters for each ingress deployment you use - see here for a how to
4.1.7 Ensure Online Certificate Status Protocol (OCSP) stapling is enabled (Scored) ACTION NEEDED Not enabled set via this configuration parameter
4.1.8 Ensure HTTP Strict Transport Security (HSTS) is enabled (Scored) OK HSTS is enabled by default
4.1.9 Ensure HTTP Public Key Pinning is enabled (Not Scored) ACTION NEEDED / RISK TO BE ACCEPTED HKPK not enabled by default If lets encrypt is not used, set correct HPKP header. There are several ways to implement this - with the helm charts it works via controller.add-headers. If lets encrypt is used, this is complicated, a solution here is yet unknown
4.1.10 Ensure upstream server traffic is authenticated with a client certificate (Scored) DEPENDS ON BACKEND Highly dependent on backends, not every backend allows configuring this, can also be mitigated via a service mesh If backend allows it, manual is here
4.1.11 Ensure the upstream traffic server certificate is trusted (Not Scored) DEPENDS ON BACKEND Highly dependent on backends, not every backend allows configuring this, can also be mitigated via a service mesh If backend allows it, see configuration here
4.1.12 Ensure your domain is preloaded (Not Scored) ACTION NEEDED Preload is not active by default Set controller.config.hsts-preload to true
4.1.13 Ensure session resumption is disabled to enable perfect forward security (Scored) OK Session tickets are disabled by default
4.1.14 Ensure HTTP/2.0 is used (Not Scored) OK http2 is set by default
5 Request Filtering and Restrictions
5.1 Access Control
5.1.1 Ensure allow and deny filters limit access to specific IP addresses (Not Scored) OK/ACTION NEEDED Depends on use case, geo ip module is compiled into Ingress-Nginx Controller, there are several ways to use it If needed set IP restrictions via annotations or work with config snippets (be careful with lets-encrypt-http-challenge!)
5.1.2 Ensure only whitelisted HTTP methods are allowed (Not Scored) OK/ACTION NEEDED Depends on use case If required it can be set via config snippet
5.2 Request Limits
5.2.1 Ensure timeout values for reading the client header and body are set correctly (Scored) ACTION NEEDED Default timeout is 60s Set via this configuration parameter and respective body equivalent
5.2.2 Ensure the maximum request body size is set correctly (Scored) ACTION NEEDED Default is 1m set via this configuration parameter
5.2.3 Ensure the maximum buffer size for URIs is defined (Scored) ACTION NEEDED Default is 4 8k Set via this configuration parameter
5.2.4 Ensure the number of connections per IP address is limited (Not Scored) OK/ACTION NEEDED No limit set Depends on use case, limit can be set via these annotations
5.2.5 Ensure rate limits by IP address are set (Not Scored) OK/ACTION NEEDED No limit set Depends on use case, limit can be set via these annotations
5.3 Browser Security
5.3.1 Ensure X-Frame-Options header is configured and enabled (Scored) ACTION NEEDED Header not set by default Several ways to implement this - with the helm charts it works via controller.add-headers
5.3.2 Ensure X-Content-Type-Options header is configured and enabled (Scored) ACTION NEEDED See previous answer See previous answer
5.3.3 Ensure the X-XSS-Protection Header is enabled and configured properly (Scored) ACTION NEEDED See previous answer See previous answer
5.3.4 Ensure that Content Security Policy (CSP) is enabled and configured properly (Not Scored) ACTION NEEDED See previous answer See previous answer
5.3.5 Ensure the Referrer Policy is enabled and configured properly (Not Scored) ACTION NEEDED Depends on application. It should be handled in the applications webserver itself, not in the load balancing ingress check backend webserver
6 Mandatory Access Control n/a too high level, depends on backends

Installation Guide

There are multiple ways to install the Ingress-Nginx Controller:

  • with Helm, using the project repository chart;
  • with kubectl apply, using YAML manifests;
  • with specific addons (e.g. for minikube or MicroK8s).

On most Kubernetes clusters, the ingress controller will work without requiring any extra configuration. If you want to get started as fast as possible, you can check the quick start instructions. However, in many environments, you can improve the performance or get better logs by enabling extra features. We recommend that you check the environment-specific instructions for details about optimizing the ingress controller for your particular environment or cloud provider.

Contents

kubernetes/ingress-nginx

Installation Guide

There are multiple ways to install the Ingress-Nginx Controller:

  • with Helm, using the project repository chart;
  • with kubectl apply, using YAML manifests;
  • with specific addons (e.g. for minikube or MicroK8s).

On most Kubernetes clusters, the ingress controller will work without requiring any extra configuration. If you want to get started as fast as possible, you can check the quick start instructions. However, in many environments, you can improve the performance or get better logs by enabling extra features. We recommend that you check the environment-specific instructions for details about optimizing the ingress controller for your particular environment or cloud provider.

Contents

kubernetes/ingress-nginx

Role Based Access Control (RBAC)

Overview

This example applies to ingress-nginx-controllers being deployed in an environment with RBAC enabled.

Role Based Access Control is comprised of four layers:

  1. ClusterRole - permissions assigned to a role that apply to an entire cluster
  2. ClusterRoleBinding - binding a ClusterRole to a specific account
  3. Role - permissions assigned to a role that apply to a specific namespace
  4. RoleBinding - binding a Role to a specific account

In order for RBAC to be applied to an ingress-nginx-controller, that controller should be assigned to a ServiceAccount. That ServiceAccount should be bound to the Roles and ClusterRoles defined for the ingress-nginx-controller.

Service Accounts created in this example

One ServiceAccount is created in this example, ingress-nginx.

Permissions Granted in this example

There are two sets of permissions defined in this example. Cluster-wide permissions defined by the ClusterRole named ingress-nginx, and namespace specific permissions defined by the Role named ingress-nginx.

Cluster Permissions

These permissions are granted in order for the ingress-nginx-controller to be able to function as an ingress across the cluster. These permissions are granted to the ClusterRole named ingress-nginx

  • configmaps, endpoints, nodes, pods, secrets: list, watch
  • nodes: get
  • services, ingresses, ingressclasses, endpointslices: get, list, watch
  • events: create, patch
  • ingresses/status: update
  • leases: list, watch

Namespace Permissions

These permissions are granted specific to the ingress-nginx namespace. These permissions are granted to the Role named ingress-nginx

  • configmaps, pods, secrets: get
  • endpoints: get

Furthermore to support leader-election, the ingress-nginx-controller needs to have access to a leases using the resourceName ingress-nginx-leader

Note that resourceNames can NOT be used to limit requests using the “create” verb because authorizers only have access to information that can be obtained from the request URL, method, and headers (resource names in a “create” request are part of the request body).

  • leases: get, update (for resourceName ingress-controller-leader)
  • leases: create

This resourceName is the election-id defined by the ingress-controller, which defaults to:

  • election-id: ingress-controller-leader
  • resourceName : <election-id>

Please adapt accordingly if you overwrite either parameter when launching the ingress-nginx-controller.

Bindings

The ServiceAccount ingress-nginx is bound to the Role ingress-nginx and the ClusterRole ingress-nginx.

The serviceAccountName associated with the containers in the deployment must match the serviceAccount. The namespace references in the Deployment metadata, container arguments, and POD_NAMESPACE should be in the ingress-nginx namespace.

\ No newline at end of file + Role Based Access Control (RBAC) - Ingress-Nginx Controller

Role Based Access Control (RBAC)

Overview

This example applies to ingress-nginx-controllers being deployed in an environment with RBAC enabled.

Role Based Access Control is comprised of four layers:

  1. ClusterRole - permissions assigned to a role that apply to an entire cluster
  2. ClusterRoleBinding - binding a ClusterRole to a specific account
  3. Role - permissions assigned to a role that apply to a specific namespace
  4. RoleBinding - binding a Role to a specific account

In order for RBAC to be applied to an ingress-nginx-controller, that controller should be assigned to a ServiceAccount. That ServiceAccount should be bound to the Roles and ClusterRoles defined for the ingress-nginx-controller.

Service Accounts created in this example

One ServiceAccount is created in this example, ingress-nginx.

Permissions Granted in this example

There are two sets of permissions defined in this example. Cluster-wide permissions defined by the ClusterRole named ingress-nginx, and namespace specific permissions defined by the Role named ingress-nginx.

Cluster Permissions

These permissions are granted in order for the ingress-nginx-controller to be able to function as an ingress across the cluster. These permissions are granted to the ClusterRole named ingress-nginx

  • configmaps, endpoints, nodes, pods, secrets: list, watch
  • nodes: get
  • services, ingresses, ingressclasses, endpointslices: get, list, watch
  • events: create, patch
  • ingresses/status: update
  • leases: list, watch

Namespace Permissions

These permissions are granted specific to the ingress-nginx namespace. These permissions are granted to the Role named ingress-nginx

  • configmaps, pods, secrets: get
  • endpoints: get

Furthermore to support leader-election, the ingress-nginx-controller needs to have access to a leases using the resourceName ingress-nginx-leader

Note that resourceNames can NOT be used to limit requests using the “create” verb because authorizers only have access to information that can be obtained from the request URL, method, and headers (resource names in a “create” request are part of the request body).

  • leases: get, update (for resourceName ingress-controller-leader)
  • leases: create

This resourceName is the election-id defined by the ingress-controller, which defaults to:

  • election-id: ingress-controller-leader
  • resourceName : <election-id>

Please adapt accordingly if you overwrite either parameter when launching the ingress-nginx-controller.

Bindings

The ServiceAccount ingress-nginx is bound to the Role ingress-nginx and the ClusterRole ingress-nginx.

The serviceAccountName associated with the containers in the deployment must match the serviceAccount. The namespace references in the Deployment metadata, container arguments, and POD_NAMESPACE should be in the ingress-nginx namespace.

\ No newline at end of file diff --git a/deploy/upgrade/index.html b/deploy/upgrade/index.html index 5623810d0..e0c5a0cd5 100644 --- a/deploy/upgrade/index.html +++ b/deploy/upgrade/index.html @@ -1,4 +1,4 @@ - Upgrade - Ingress-Nginx Controller

Upgrading

Important

No matter the method you use for upgrading, if you use template overrides, make sure your templates are compatible with the new version of ingress-nginx.

Without Helm

To upgrade your ingress-nginx installation, it should be enough to change the version of the image in the controller Deployment.

I.e. if your deployment resource looks like (partial example):

kind: Deployment
+ Upgrade - Ingress-Nginx Controller      

Upgrading

Important

No matter the method you use for upgrading, if you use template overrides, make sure your templates are compatible with the new version of ingress-nginx.

Without Helm

To upgrade your ingress-nginx installation, it should be enough to change the version of the image in the controller Deployment.

I.e. if your deployment resource looks like (partial example):

kind: Deployment
 metadata:
   name: ingress-nginx-controller
   namespace: ingress-nginx
diff --git a/developer-guide/code-overview/index.html b/developer-guide/code-overview/index.html
index 6622e3a78..ddf6111ec 100644
--- a/developer-guide/code-overview/index.html
+++ b/developer-guide/code-overview/index.html
@@ -1 +1 @@
- Code Overview - Ingress-Nginx Controller      

Ingress NGINX - Code Overview

This document provides an overview of Ingress NGINX code.

Core Golang code

This part of the code is responsible for the main logic of Ingress NGINX. It contains all the logics that parses Ingress Objects, annotations, watches Endpoints and turn them into usable nginx.conf configuration.

Core Sync Logics:

Ingress-nginx has an internal model of the ingresses, secrets and endpoints in a given cluster. It maintains two copies of that:

  1. One copy is the currently running configuration model
  2. Second copy is the one generated in response to some changes in the cluster

The sync logic diffs the two models and if there's a change it tries to converge the running configuration to the new one.

There are static and dynamic configuration changes.

All endpoints and certificate changes are handled dynamically by posting the payload to an internal NGINX endpoint that is handled by Lua.


The following parts of the code can be found:

Entrypoint

The main package is responsible for starting ingress-nginx program, which can be found in cmd/nginx directory.

Version

Is the package of the code responsible for adding version subcommand, and can be found in version directory.

Internal code

This part of the code contains the internal logics that compose Ingress NGINX Controller, and it's split into:

Admission Controller

Contains the code of Kubernetes Admission Controller which validates the syntax of ingress objects before accepting it.

This code can be found in internal/admission/controller directory.

File functions

Contains auxiliary codes that deal with files, such as generating the SHA1 checksum of a file, or creating required directories.

This code can be found in internal/file directory.

Ingress functions

Contains all the logics from Ingress-Nginx Controller, with some examples being:

And other parts of the code that will be written in this document in a future.

K8s functions

Contains helper functions for parsing Kubernetes objects.

This part of the code can be found in internal/k8s directory.

Networking functions

Contains helper functions for networking, such as IPv4 and IPv6 parsing, SSL certificate parsing, etc.

This part of the code can be found in internal/net directory.

NGINX functions

Contains helper function to deal with NGINX, such as verify if it's running and reading it's configuration file parts.

This part of the code can be found in internal/nginx directory.

Tasks / Queue

Contains the functions responsible for the sync queue part of the controller.

This part of the code can be found in internal/task directory.

Other parts of internal

Other parts of internal code might not be covered here, like runtime and watch but they can be added in a future.

E2E Test

The e2e tests code is in test directory.

Other programs

Describe here kubectl plugin, dbg, waitshutdown and cover the hack scripts.

kubectl plugin

It contains kubectl plugin for inspecting your ingress-nginx deployments. This part of code can be found in cmd/plugin directory Detail functions flow and available flow can be found in kubectl-plugin

Deploy files

This directory contains the yaml deploy files used as examples or references in the docs to deploy Ingress NGINX and other components.

Those files are in deploy directory.

Helm Chart

Used to generate the Helm chart published.

Code is in charts/ingress-nginx.

Documentation/Website

The documentation used to generate the website https://kubernetes.github.io/ingress-nginx/

This code is available in docs and it's main "language" is Markdown, used by mkdocs file to generate static pages.

Container Images

Container images used to run ingress-nginx, or to build the final image.

Base Images

Contains the Dockerfiles and scripts used to build base images that are used in other parts of the repo. They are present in images repo. Some examples: * nginx - The base NGINX image ingress-nginx uses is not a vanilla NGINX. It bundles many libraries together and it is a job in itself to maintain that and keep things up-to-date. * custom-error-pages - Used on the custom error page examples.

There are other images inside this directory.

Ingress Controller Image

The image used to build the final ingress controller, used in deploy scripts and Helm charts.

This is NGINX with some Lua enhancement. We do dynamic certificate, endpoints handling, canary traffic split, custom load balancing etc at this component. One can also add new functionalities using Lua plugin system.

The files are in rootfs directory and contains:

Ingress NGINX Lua Scripts

Ingress NGINX uses Lua Scripts to enable features like hot reloading, rate limiting and monitoring. Some are written using the OpenResty helper.

The directory containing Lua scripts is rootfs/etc/nginx/lua.

Nginx Go template file

One of the functions of Ingress NGINX is to turn Ingress objects into nginx.conf file.

To do so, the final step is to apply those configurations in nginx.tmpl turning it into a final nginx.conf file.

\ No newline at end of file + Code Overview - Ingress-Nginx Controller

Ingress NGINX - Code Overview

This document provides an overview of Ingress NGINX code.

Core Golang code

This part of the code is responsible for the main logic of Ingress NGINX. It contains all the logics that parses Ingress Objects, annotations, watches Endpoints and turn them into usable nginx.conf configuration.

Core Sync Logics:

Ingress-nginx has an internal model of the ingresses, secrets and endpoints in a given cluster. It maintains two copies of that:

  1. One copy is the currently running configuration model
  2. Second copy is the one generated in response to some changes in the cluster

The sync logic diffs the two models and if there's a change it tries to converge the running configuration to the new one.

There are static and dynamic configuration changes.

All endpoints and certificate changes are handled dynamically by posting the payload to an internal NGINX endpoint that is handled by Lua.


The following parts of the code can be found:

Entrypoint

The main package is responsible for starting ingress-nginx program, which can be found in cmd/nginx directory.

Version

Is the package of the code responsible for adding version subcommand, and can be found in version directory.

Internal code

This part of the code contains the internal logics that compose Ingress NGINX Controller, and it's split into:

Admission Controller

Contains the code of Kubernetes Admission Controller which validates the syntax of ingress objects before accepting it.

This code can be found in internal/admission/controller directory.

File functions

Contains auxiliary codes that deal with files, such as generating the SHA1 checksum of a file, or creating required directories.

This code can be found in internal/file directory.

Ingress functions

Contains all the logics from Ingress-Nginx Controller, with some examples being:

And other parts of the code that will be written in this document in a future.

K8s functions

Contains helper functions for parsing Kubernetes objects.

This part of the code can be found in internal/k8s directory.

Networking functions

Contains helper functions for networking, such as IPv4 and IPv6 parsing, SSL certificate parsing, etc.

This part of the code can be found in internal/net directory.

NGINX functions

Contains helper function to deal with NGINX, such as verify if it's running and reading it's configuration file parts.

This part of the code can be found in internal/nginx directory.

Tasks / Queue

Contains the functions responsible for the sync queue part of the controller.

This part of the code can be found in internal/task directory.

Other parts of internal

Other parts of internal code might not be covered here, like runtime and watch but they can be added in a future.

E2E Test

The e2e tests code is in test directory.

Other programs

Describe here kubectl plugin, dbg, waitshutdown and cover the hack scripts.

kubectl plugin

It contains kubectl plugin for inspecting your ingress-nginx deployments. This part of code can be found in cmd/plugin directory Detail functions flow and available flow can be found in kubectl-plugin

Deploy files

This directory contains the yaml deploy files used as examples or references in the docs to deploy Ingress NGINX and other components.

Those files are in deploy directory.

Helm Chart

Used to generate the Helm chart published.

Code is in charts/ingress-nginx.

Documentation/Website

The documentation used to generate the website https://kubernetes.github.io/ingress-nginx/

This code is available in docs and it's main "language" is Markdown, used by mkdocs file to generate static pages.

Container Images

Container images used to run ingress-nginx, or to build the final image.

Base Images

Contains the Dockerfiles and scripts used to build base images that are used in other parts of the repo. They are present in images repo. Some examples: * nginx - The base NGINX image ingress-nginx uses is not a vanilla NGINX. It bundles many libraries together and it is a job in itself to maintain that and keep things up-to-date. * custom-error-pages - Used on the custom error page examples.

There are other images inside this directory.

Ingress Controller Image

The image used to build the final ingress controller, used in deploy scripts and Helm charts.

This is NGINX with some Lua enhancement. We do dynamic certificate, endpoints handling, canary traffic split, custom load balancing etc at this component. One can also add new functionalities using Lua plugin system.

The files are in rootfs directory and contains:

Ingress NGINX Lua Scripts

Ingress NGINX uses Lua Scripts to enable features like hot reloading, rate limiting and monitoring. Some are written using the OpenResty helper.

The directory containing Lua scripts is rootfs/etc/nginx/lua.

Nginx Go template file

One of the functions of Ingress NGINX is to turn Ingress objects into nginx.conf file.

To do so, the final step is to apply those configurations in nginx.tmpl turning it into a final nginx.conf file.

\ No newline at end of file diff --git a/developer-guide/getting-started/index.html b/developer-guide/getting-started/index.html index 7593cb632..df49e7ad1 100644 --- a/developer-guide/getting-started/index.html +++ b/developer-guide/getting-started/index.html @@ -1,4 +1,4 @@ - Getting Started - Ingress-Nginx Controller

Getting Started

Developing for Ingress-Nginx Controller

This document explains how to get started with developing for Ingress-Nginx Controller.

For the really new contributors, who want to contribute to the INGRESS-NGINX project, but need help with understanding some basic concepts, that are needed to work with the Kubernetes ingress resource, here is a link to the New Contributors Guide. This guide contains tips on how a http/https request travels, from a browser or a curl command, to the webserver process running inside a container, in a pod, in a Kubernetes cluster, but enters the cluster via a ingress resource. For those who are familiar with those basic networking concepts like routing of a packet with regards to a http request, termination of connection, reverseproxy etc. etc., you can skip this and move on to the sections below. (or read it anyways just for context and also provide feedbacks if any)

Prerequisites

Install Go 1.14 or later.

Note

The project uses Go Modules

Install Docker (v19.03.0 or later with experimental feature on)

Important

The majority of make tasks run as docker containers

Quick Start

  1. Fork the repository
  2. Clone the repository to any location in your work station
  3. Add a GO111MODULE environment variable with export GO111MODULE=on
  4. Run go mod download to install dependencies

Local build

Start a local Kubernetes cluster using kind, build and deploy the ingress controller

make dev-env
+ Getting Started - Ingress-Nginx Controller      

Getting Started

Developing for Ingress-Nginx Controller

This document explains how to get started with developing for Ingress-Nginx Controller.

For the really new contributors, who want to contribute to the INGRESS-NGINX project, but need help with understanding some basic concepts, that are needed to work with the Kubernetes ingress resource, here is a link to the New Contributors Guide. This guide contains tips on how a http/https request travels, from a browser or a curl command, to the webserver process running inside a container, in a pod, in a Kubernetes cluster, but enters the cluster via a ingress resource. For those who are familiar with those basic networking concepts like routing of a packet with regards to a http request, termination of connection, reverseproxy etc. etc., you can skip this and move on to the sections below. (or read it anyways just for context and also provide feedbacks if any)

Prerequisites

Install Go 1.14 or later.

Note

The project uses Go Modules

Install Docker (v19.03.0 or later with experimental feature on)

Important

The majority of make tasks run as docker containers

Quick Start

  1. Fork the repository
  2. Clone the repository to any location in your work station
  3. Add a GO111MODULE environment variable with export GO111MODULE=on
  4. Run go mod download to install dependencies

Local build

Start a local Kubernetes cluster using kind, build and deploy the ingress controller

make dev-env
 
- If you are working on the v1.x.x version of this controller, and you want to create a cluster with kubernetes version 1.22, then please visit the documentation for kind, and look for how to set a custom image for the kind node (image: kindest/node...), in the kind config file.

Testing

Run go unit tests

make test
 

Run unit-tests for lua code

make lua-test
 

Lua tests are located in the directory rootfs/etc/nginx/lua/test

Important

Test files must follow the naming convention <mytest>_test.lua or it will be ignored

Run e2e test suite

make kind-e2e-test
diff --git a/e2e-tests/index.html b/e2e-tests/index.html
index 9c391fe0d..caf89f322 100644
--- a/e2e-tests/index.html
+++ b/e2e-tests/index.html
@@ -1,4 +1,4 @@
- E2e tests - Ingress-Nginx Controller      
kubernetes/ingress-nginx

e2e test suite for Ingress NGINX Controller

[Admission] admission controller

affinitymode

server-alias

app-root

auth-*

auth-tls-*

backend-protocol

canary-*

client-body-buffer-size

connection-proxy-header

cors-*

custom-http-errors

default-backend

disable-access-log disable-http-access-log disable-stream-access-log

backend-protocol - FastCGI

force-ssl-redirect

from-to-www-redirect

annotation-global-rate-limit

backend-protocol - GRPC

http2-push-preload

allowlist-source-range

denylist-source-range

Annotation - limit-connections

limit-rate

enable-access-log enable-rewrite-log

mirror-*

modsecurity owasp

preserve-trailing-slash

proxy-*

proxy-ssl-*

permanent-redirect permanent-redirect-code

rewrite-target use-regex enable-rewrite-log

satisfy

server-snippet

service-upstream

configuration-snippet

ssl-ciphers

stream-snippet

upstream-hash-by-*

upstream-vhost

x-forwarded-prefix

Debug CLI

[Default Backend] custom service

[Default Backend]

[Default Backend] SSL

[Default Backend] change default settings

[Endpointslices] long service name

[TopologyHints] topology aware routing

[Shutdown] Grace period shutdown

[Shutdown] ingress controller

[Shutdown] Graceful shutdown with pending request

[Ingress] DeepInspection

single ingress - multiple hosts

[Ingress] [PathType] exact

[Ingress] [PathType] mix Exact and Prefix paths

[Ingress] [PathType] prefix checks

[Ingress] definition without host

[Memory Leak] Dynamic Certificates

[Load Balancer] load-balance

[Load Balancer] EWMA

[Load Balancer] round-robin

[Lua] dynamic certificates

[Lua] dynamic configuration

[metrics] exported prometheus metrics

nginx-configuration

[Security] request smuggling

[Service] backend status code 503

[Service] Type ExternalName

[Service] Nil Service Backend

access-log

aio-write

Bad annotation values

brotli

Configmap change

add-headers

[SSL] [Flag] default-ssl-certificate

[Flag] disable-catch-all

[Flag] disable-service-external-name

[Flag] disable-sync-events

enable-real-ip

use-forwarded-headers

Geoip2

[Security] block-*

[Security] global-auth-url

global-options

settings-global-rate-limit

gzip

hash size

[Flag] ingress-class

keep-alive keep-alive-requests

Configmap - limit-rate

[Flag] custom HTTP and HTTPS ports

log-format-*

[Lua] lua-shared-dicts

main-snippet

[Security] modsecurity-snippet

enable-multi-accept

[Flag] watch namespace selector

[Security] no-auth-locations

Add no tls redirect locations

OCSP

Configure Opentelemetry

Configure OpenTracing

plugins

[Security] Pod Security Policies

[Security] Pod Security Policies with volumes

proxy-connect-timeout

Dynamic $proxy_host

proxy-next-upstream

use-proxy-protocol

proxy-read-timeout

proxy-send-timeout

reuse-port

configmap server-snippet

server-tokens

ssl-ciphers

[Flag] enable-ssl-passthrough

With enable-ssl-passthrough enabled

configmap stream-snippet

[SSL] TLS protocols, ciphers and headers)

annotation validations

[SSL] redirect to HTTPS

[SSL] secret update

[Status] status update

[TCP] tcp-services

\ No newline at end of file +-->

e2e test suite for Ingress NGINX Controller

[Admission] admission controller

affinitymode

server-alias

app-root

auth-*

auth-tls-*

backend-protocol

canary-*

client-body-buffer-size

connection-proxy-header

cors-*

custom-http-errors

default-backend

disable-access-log disable-http-access-log disable-stream-access-log

backend-protocol - FastCGI

force-ssl-redirect

from-to-www-redirect

annotation-global-rate-limit

backend-protocol - GRPC

http2-push-preload

allowlist-source-range

denylist-source-range

Annotation - limit-connections

limit-rate

enable-access-log enable-rewrite-log

mirror-*

modsecurity owasp

preserve-trailing-slash

proxy-*

proxy-ssl-*

permanent-redirect permanent-redirect-code

rewrite-target use-regex enable-rewrite-log

satisfy

server-snippet

service-upstream

configuration-snippet

ssl-ciphers

stream-snippet

upstream-hash-by-*

upstream-vhost

x-forwarded-prefix

Debug CLI

[Default Backend] custom service

[Default Backend]

[Default Backend] SSL

[Default Backend] change default settings

[Endpointslices] long service name

[TopologyHints] topology aware routing

[Shutdown] Grace period shutdown

[Shutdown] ingress controller

[Shutdown] Graceful shutdown with pending request

[Ingress] DeepInspection

single ingress - multiple hosts

[Ingress] [PathType] exact

[Ingress] [PathType] mix Exact and Prefix paths

[Ingress] [PathType] prefix checks

[Ingress] definition without host

[Memory Leak] Dynamic Certificates

[Load Balancer] load-balance

[Load Balancer] EWMA

[Load Balancer] round-robin

[Lua] dynamic certificates

[Lua] dynamic configuration

[metrics] exported prometheus metrics

nginx-configuration

[Security] request smuggling

[Service] backend status code 503

[Service] Type ExternalName

[Service] Nil Service Backend

access-log

aio-write

Bad annotation values

brotli

Configmap change

add-headers

[SSL] [Flag] default-ssl-certificate

[Flag] disable-catch-all

[Flag] disable-service-external-name

[Flag] disable-sync-events

enable-real-ip

use-forwarded-headers

Geoip2

[Security] block-*

[Security] global-auth-url

global-options

settings-global-rate-limit

gzip

hash size

[Flag] ingress-class

keep-alive keep-alive-requests

Configmap - limit-rate

[Flag] custom HTTP and HTTPS ports

log-format-*

[Lua] lua-shared-dicts

main-snippet

[Security] modsecurity-snippet

enable-multi-accept

[Flag] watch namespace selector

[Security] no-auth-locations

Add no tls redirect locations

OCSP

Configure Opentelemetry

Configure OpenTracing

plugins

[Security] Pod Security Policies

[Security] Pod Security Policies with volumes

proxy-connect-timeout

Dynamic $proxy_host

proxy-next-upstream

use-proxy-protocol

proxy-read-timeout

proxy-send-timeout

reuse-port

configmap server-snippet

server-tokens

ssl-ciphers

[Flag] enable-ssl-passthrough

With enable-ssl-passthrough enabled

configmap stream-snippet

[SSL] TLS protocols, ciphers and headers)

annotation validations

[SSL] redirect to HTTPS

[SSL] secret update

[Status] status update

[TCP] tcp-services

\ No newline at end of file diff --git a/enhancements/20190724-only-dynamic-ssl/index.html b/enhancements/20190724-only-dynamic-ssl/index.html index 6d34b3f42..929ae9b8c 100644 --- a/enhancements/20190724-only-dynamic-ssl/index.html +++ b/enhancements/20190724-only-dynamic-ssl/index.html @@ -1 +1 @@ - Remove static SSL configuration mode - Ingress-Nginx Controller

Remove static SSL configuration mode

Table of Contents

Summary

Since release 0.19.0 is possible to configure SSL certificates without the need of NGINX reloads (thanks to lua) and after release 0.24.0 the default enabled mode is dynamic.

Motivation

The static configuration implies reloads, something that affects the majority of the users.

Goals

  • Deprecation of the flag --enable-dynamic-certificates.
  • Cleanup of the codebase.

Non-Goals

  • Features related to certificate authentication are not changed in any way.

Proposal

  • Remove static SSL configuration

Implementation Details/Notes/Constraints

  • Deprecate the flag Move the directives ssl_certificate and ssl_certificate_key from each server block to the http section. These settings are required to avoid NGINX errors in the logs.
  • Remove any action of the flag --enable-dynamic-certificates

Drawbacks

Alternatives

Keep both implementations

\ No newline at end of file + Remove static SSL configuration mode - Ingress-Nginx Controller

Remove static SSL configuration mode

Table of Contents

Summary

Since release 0.19.0 is possible to configure SSL certificates without the need of NGINX reloads (thanks to lua) and after release 0.24.0 the default enabled mode is dynamic.

Motivation

The static configuration implies reloads, something that affects the majority of the users.

Goals

  • Deprecation of the flag --enable-dynamic-certificates.
  • Cleanup of the codebase.

Non-Goals

  • Features related to certificate authentication are not changed in any way.

Proposal

  • Remove static SSL configuration

Implementation Details/Notes/Constraints

  • Deprecate the flag Move the directives ssl_certificate and ssl_certificate_key from each server block to the http section. These settings are required to avoid NGINX errors in the logs.
  • Remove any action of the flag --enable-dynamic-certificates

Drawbacks

Alternatives

Keep both implementations

\ No newline at end of file diff --git a/enhancements/20190815-zone-aware-routing/index.html b/enhancements/20190815-zone-aware-routing/index.html index 781467a44..cf1f9614f 100644 --- a/enhancements/20190815-zone-aware-routing/index.html +++ b/enhancements/20190815-zone-aware-routing/index.html @@ -1 +1 @@ - Availability zone aware routing - Ingress-Nginx Controller

Availability zone aware routing

Table of Contents

Summary

Teach ingress-nginx about availability zones where endpoints are running in. This way ingress-nginx pod will do its best to proxy to zone-local endpoint.

Motivation

When users run their services across multiple availability zones they usually pay for egress traffic between zones. Providers such as GCP, and Amazon EC2 usually charge extra for this feature. ingress-nginx when picking an endpoint to route request to does not consider whether the endpoint is in a different zone or the same one. That means it's at least equally likely that it will pick an endpoint from another zone and proxy the request to it. In this situation response from the endpoint to the ingress-nginx pod is considered inter-zone traffic and usually costs extra money.

At the time of this writing, GCP charges $0.01 per GB of inter-zone egress traffic according to https://cloud.google.com/compute/network-pricing. According to https://datapath.io/resources/blog/what-are-aws-data-transfer-costs-and-how-to-minimize-them/ Amazon also charges the same amount of money as GCP for cross-zone, egress traffic.

This can be a lot of money depending on once's traffic. By teaching ingress-nginx about zones we can eliminate or at least decrease this cost.

Arguably inter-zone network latency should also be better than cross-zone.

Goals

  • Given a regional cluster running ingress-nginx, ingress-nginx should do best-effort to pick a zone-local endpoint when proxying
  • This should not impact canary feature
  • ingress-nginx should be able to operate successfully if there are no zonal endpoints

Non-Goals

  • This feature inherently assumes that endpoints are distributed across zones in a way that they can handle all the traffic from ingress-nginx pod(s) in that zone
  • This feature will be relying on https://kubernetes.io/docs/reference/kubernetes-api/labels-annotations-taints/#failure-domainbetakubernetesiozone, it is not this KEP's goal to support other cases

Proposal

The idea here is to have the controller part of ingress-nginx (1) detect what zone its current pod is running in and (2) detect the zone for every endpoint it knows about. After that, it will post that data as part of endpoints to Lua land. When picking an endpoint, the Lua balancer will try to pick zone-local endpoint first and if there is no zone-local endpoint then it will fall back to current behavior.

Initially, this feature should be optional since it is going to make it harder to reason about the load balancing and not everyone might want that.

How does controller know what zone it runs in? We can have the pod spec pass the node name using downward API as an environment variable. Upon startup, the controller can get node details from the API based on the node name. Once the node details are obtained we can extract the zone from the failure-domain.beta.kubernetes.io/zone annotation. Then we can pass that value to Lua land through Nginx configuration when loading lua_ingress.lua module in init_by_lua phase.

How do we extract zones for endpoints? We can have the controller watch create and update events on nodes in the entire cluster and based on that keep the map of nodes to zones in the memory. And when we generate endpoints list, we can access node name using .subsets.addresses[i].nodeName and based on that fetch zone from the map in memory and store it as a field on the endpoint. This solution assumes failure-domain.beta.kubernetes.io/zone annotation does not change until the end of the node's life. Otherwise, we have to watch update events as well on the nodes and that'll add even more overhead.

Alternatively, we can get the list of nodes only when there's no node in the memory for the given node name. This is probably a better solution because then we would avoid watching for API changes on node resources. We can eagerly fetch all the nodes and build node name to zone mapping on start. From there on, it will sync during endpoint building in the main event loop if there's no existing entry for the node of an endpoint. This means an extra API call in case cluster has expanded.

How do we make sure we do our best to choose zone-local endpoint? This will be done on the Lua side. For every backend, we will initialize two balancer instances: (1) with all endpoints (2) with all endpoints corresponding to the current zone for the backend. Then given the request once we choose what backend needs to serve the request, we will first try to use a zonal balancer for that backend. If a zonal balancer does not exist (i.e. there's no zonal endpoint) then we will use a general balancer. In case of zonal outages, we assume that the readiness probe will fail and the controller will see no endpoints for the backend and therefore we will use a general balancer.

We can enable the feature using a configmap setting. Doing it this way makes it easier to rollback in case of a problem.

Implementation History

  • initial version of KEP is shipped
  • proposal and implementation details are done

Drawbacks [optional]

More load on the Kubernetes API server.

\ No newline at end of file + Availability zone aware routing - Ingress-Nginx Controller

Availability zone aware routing

Table of Contents

Summary

Teach ingress-nginx about availability zones where endpoints are running in. This way ingress-nginx pod will do its best to proxy to zone-local endpoint.

Motivation

When users run their services across multiple availability zones they usually pay for egress traffic between zones. Providers such as GCP, and Amazon EC2 usually charge extra for this feature. ingress-nginx when picking an endpoint to route request to does not consider whether the endpoint is in a different zone or the same one. That means it's at least equally likely that it will pick an endpoint from another zone and proxy the request to it. In this situation response from the endpoint to the ingress-nginx pod is considered inter-zone traffic and usually costs extra money.

At the time of this writing, GCP charges $0.01 per GB of inter-zone egress traffic according to https://cloud.google.com/compute/network-pricing. According to https://datapath.io/resources/blog/what-are-aws-data-transfer-costs-and-how-to-minimize-them/ Amazon also charges the same amount of money as GCP for cross-zone, egress traffic.

This can be a lot of money depending on once's traffic. By teaching ingress-nginx about zones we can eliminate or at least decrease this cost.

Arguably inter-zone network latency should also be better than cross-zone.

Goals

  • Given a regional cluster running ingress-nginx, ingress-nginx should do best-effort to pick a zone-local endpoint when proxying
  • This should not impact canary feature
  • ingress-nginx should be able to operate successfully if there are no zonal endpoints

Non-Goals

  • This feature inherently assumes that endpoints are distributed across zones in a way that they can handle all the traffic from ingress-nginx pod(s) in that zone
  • This feature will be relying on https://kubernetes.io/docs/reference/kubernetes-api/labels-annotations-taints/#failure-domainbetakubernetesiozone, it is not this KEP's goal to support other cases

Proposal

The idea here is to have the controller part of ingress-nginx (1) detect what zone its current pod is running in and (2) detect the zone for every endpoint it knows about. After that, it will post that data as part of endpoints to Lua land. When picking an endpoint, the Lua balancer will try to pick zone-local endpoint first and if there is no zone-local endpoint then it will fall back to current behavior.

Initially, this feature should be optional since it is going to make it harder to reason about the load balancing and not everyone might want that.

How does controller know what zone it runs in? We can have the pod spec pass the node name using downward API as an environment variable. Upon startup, the controller can get node details from the API based on the node name. Once the node details are obtained we can extract the zone from the failure-domain.beta.kubernetes.io/zone annotation. Then we can pass that value to Lua land through Nginx configuration when loading lua_ingress.lua module in init_by_lua phase.

How do we extract zones for endpoints? We can have the controller watch create and update events on nodes in the entire cluster and based on that keep the map of nodes to zones in the memory. And when we generate endpoints list, we can access node name using .subsets.addresses[i].nodeName and based on that fetch zone from the map in memory and store it as a field on the endpoint. This solution assumes failure-domain.beta.kubernetes.io/zone annotation does not change until the end of the node's life. Otherwise, we have to watch update events as well on the nodes and that'll add even more overhead.

Alternatively, we can get the list of nodes only when there's no node in the memory for the given node name. This is probably a better solution because then we would avoid watching for API changes on node resources. We can eagerly fetch all the nodes and build node name to zone mapping on start. From there on, it will sync during endpoint building in the main event loop if there's no existing entry for the node of an endpoint. This means an extra API call in case cluster has expanded.

How do we make sure we do our best to choose zone-local endpoint? This will be done on the Lua side. For every backend, we will initialize two balancer instances: (1) with all endpoints (2) with all endpoints corresponding to the current zone for the backend. Then given the request once we choose what backend needs to serve the request, we will first try to use a zonal balancer for that backend. If a zonal balancer does not exist (i.e. there's no zonal endpoint) then we will use a general balancer. In case of zonal outages, we assume that the readiness probe will fail and the controller will see no endpoints for the backend and therefore we will use a general balancer.

We can enable the feature using a configmap setting. Doing it this way makes it easier to rollback in case of a problem.

Implementation History

  • initial version of KEP is shipped
  • proposal and implementation details are done

Drawbacks [optional]

More load on the Kubernetes API server.

\ No newline at end of file diff --git a/enhancements/20231001-split-containers/index.html b/enhancements/20231001-split-containers/index.html index 7686d1295..33d950a61 100644 --- a/enhancements/20231001-split-containers/index.html +++ b/enhancements/20231001-split-containers/index.html @@ -1,4 +1,4 @@ - Proposal to split containers - Ingress-Nginx Controller

Proposal to split containers

  • All the NGINX files should live on one container
  • No file other than NGINX files should exist on this container
  • This includes not mounting the service account
  • All the controller files should live on a different container
  • Controller container should have bare minimum to work (just go program)
  • ServiceAccount should be mounted just on controller

  • Inside nginx container, there should be a really small http listener just able to start, stop and reload NGINX

Roadmap (what needs to be done)

  • Map what needs to be done to mount the SA just on controller container
  • Map all the required files for NGINX to work
  • Map all the required network calls between controller and NGINX
  • eg.: Dynamic lua reconfiguration
  • Map problematic features that will need attention
  • SSLPassthrough today happens on controller process and needs to happen on NGINX

Ports and endpoints on NGINX container

  • Public HTTP/HTTPs port - 80 and 443
  • Lua configuration port - 10246 (HTTP) and 10247 (Stream)
  • 3333 (temp) - Dataplane controller http server
  • /reload - (POST) Reloads the configuration.
    • "config" argument is the location of temporary file that should be used / moved to nginx.conf
  • /test - (POST) Test the configuration of a given file location
    • "config" argument is the location of temporary file that should be tested

Mounting empty SA on controller container

kind: Pod
+ Proposal to split containers - Ingress-Nginx Controller      

Proposal to split containers

  • All the NGINX files should live on one container
  • No file other than NGINX files should exist on this container
  • This includes not mounting the service account
  • All the controller files should live on a different container
  • Controller container should have bare minimum to work (just go program)
  • ServiceAccount should be mounted just on controller

  • Inside nginx container, there should be a really small http listener just able to start, stop and reload NGINX

Roadmap (what needs to be done)

  • Map what needs to be done to mount the SA just on controller container
  • Map all the required files for NGINX to work
  • Map all the required network calls between controller and NGINX
  • eg.: Dynamic lua reconfiguration
  • Map problematic features that will need attention
  • SSLPassthrough today happens on controller process and needs to happen on NGINX

Ports and endpoints on NGINX container

  • Public HTTP/HTTPs port - 80 and 443
  • Lua configuration port - 10246 (HTTP) and 10247 (Stream)
  • 3333 (temp) - Dataplane controller http server
  • /reload - (POST) Reloads the configuration.
    • "config" argument is the location of temporary file that should be used / moved to nginx.conf
  • /test - (POST) Test the configuration of a given file location
    • "config" argument is the location of temporary file that should be tested

Mounting empty SA on controller container

kind: Pod
 apiVersion: v1
 metadata:
   name: test
diff --git a/enhancements/YYYYMMDD-kep-template/index.html b/enhancements/YYYYMMDD-kep-template/index.html
index 15d350b0c..945d3f5bd 100644
--- a/enhancements/YYYYMMDD-kep-template/index.html
+++ b/enhancements/YYYYMMDD-kep-template/index.html
@@ -1 +1 @@
- KEP Template - Ingress-Nginx Controller      

Title

This is the title of the KEP. Keep it simple and descriptive. A good title can help communicate what the KEP is and should be considered as part of any review.

The title should be lowercased and spaces/punctuation should be replaced with -.

To get started with this template:

  1. Make a copy of this template. Create a copy of this template and name it YYYYMMDD-my-title.md, where YYYYMMDD is the date the KEP was first drafted.
  2. Fill out the "overview" sections. This includes the Summary and Motivation sections. These should be easy if you've preflighted the idea of the KEP in an issue.
  3. Create a PR. Assign it to folks that are sponsoring this process.
  4. Create an issue When filing an enhancement tracking issue, please ensure to complete all fields in the template.
  5. Merge early. Avoid getting hung up on specific details and instead aim to get the goal of the KEP merged quickly. The best way to do this is to just start with the "Overview" sections and fill out details incrementally in follow on PRs. View anything marked as a provisional as a working document and subject to change. Aim for single topic PRs to keep discussions focused. If you disagree with what is already in a document, open a new PR with suggested changes.

The canonical place for the latest set of instructions (and the likely source of this file) is here.

The Metadata section above is intended to support the creation of tooling around the KEP process. This will be a YAML section that is fenced as a code block. See the KEP process for details on each of these items.

Table of Contents

A table of contents is helpful for quickly jumping to sections of a KEP and for highlighting any additional information provided beyond the standard KEP template.

Ensure the TOC is wrapped with <!-- toc --&rt;<!-- /toc --&rt; tags, and then generate with hack/update-toc.sh.

Summary

The Summary section is incredibly important for producing high quality user-focused documentation such as release notes or a development roadmap. It should be possible to collect this information before implementation begins in order to avoid requiring implementers to split their attention between writing release notes and implementing the feature itself.

A good summary is probably at least a paragraph in length.

Motivation

This section is for explicitly listing the motivation, goals and non-goals of this KEP. Describe why the change is important and the benefits to users. The motivation section can optionally provide links to experience reports to demonstrate the interest in a KEP within the wider Kubernetes community.

Goals

List the specific goals of the KEP. How will we know that this has succeeded?

Non-Goals

What is out of scope for this KEP? Listing non-goals helps to focus discussion and make progress.

Proposal

This is where we get down to the nitty gritty of what the proposal actually is.

User Stories [optional]

Detail the things that people will be able to do if this KEP is implemented. Include as much detail as possible so that people can understand the "how" of the system. The goal here is to make this feel real for users without getting bogged down.

Story 1

Story 2

Implementation Details/Notes/Constraints [optional]

What are the caveats to the implementation? What are some important details that didn't come across above. Go in to as much detail as necessary here. This might be a good place to talk about core concepts and how they relate.

Risks and Mitigations

What are the risks of this proposal and how do we mitigate. Think broadly. For example, consider both security and how this will impact the larger kubernetes ecosystem.

How will security be reviewed and by whom? How will UX be reviewed and by whom?

Consider including folks that also work outside project.

Design Details

Test Plan

Note: Section not required until targeted at a release.

Consider the following in developing a test plan for this enhancement:

  • Will there be e2e and integration tests, in addition to unit tests?
  • How will it be tested in isolation vs with other components?

No need to outline all of the test cases, just the general strategy. Anything that would count as tricky in the implementation and anything particularly challenging to test should be called out.

All code is expected to have adequate tests (eventually with coverage expectations). Please adhere to the Kubernetes testing guidelines when drafting this test plan.

Removing a deprecated flag

  • Announce deprecation and support policy of the existing flag
  • Two versions passed since introducing the functionality which deprecates the flag (to address version skew)
  • Address feedback on usage/changed behavior, provided on GitHub issues
  • Deprecate the flag

Implementation History

Major milestones in the life cycle of a KEP should be tracked in Implementation History. Major milestones might include

  • the Summary and Motivation sections being merged signaling acceptance
  • the Proposal section being merged signaling agreement on a proposed design
  • the date implementation started
  • the first Kubernetes release where an initial version of the KEP was available
  • the version of Kubernetes where the KEP graduated to general availability
  • when the KEP was retired or superseded

Drawbacks [optional]

Why should this KEP not be implemented.

Alternatives [optional]

Similar to the Drawbacks section the Alternatives section is used to highlight and record other possible approaches to delivering the value proposed by a KEP.

\ No newline at end of file + KEP Template - Ingress-Nginx Controller

Title

This is the title of the KEP. Keep it simple and descriptive. A good title can help communicate what the KEP is and should be considered as part of any review.

The title should be lowercased and spaces/punctuation should be replaced with -.

To get started with this template:

  1. Make a copy of this template. Create a copy of this template and name it YYYYMMDD-my-title.md, where YYYYMMDD is the date the KEP was first drafted.
  2. Fill out the "overview" sections. This includes the Summary and Motivation sections. These should be easy if you've preflighted the idea of the KEP in an issue.
  3. Create a PR. Assign it to folks that are sponsoring this process.
  4. Create an issue When filing an enhancement tracking issue, please ensure to complete all fields in the template.
  5. Merge early. Avoid getting hung up on specific details and instead aim to get the goal of the KEP merged quickly. The best way to do this is to just start with the "Overview" sections and fill out details incrementally in follow on PRs. View anything marked as a provisional as a working document and subject to change. Aim for single topic PRs to keep discussions focused. If you disagree with what is already in a document, open a new PR with suggested changes.

The canonical place for the latest set of instructions (and the likely source of this file) is here.

The Metadata section above is intended to support the creation of tooling around the KEP process. This will be a YAML section that is fenced as a code block. See the KEP process for details on each of these items.

Table of Contents

A table of contents is helpful for quickly jumping to sections of a KEP and for highlighting any additional information provided beyond the standard KEP template.

Ensure the TOC is wrapped with <!-- toc --&rt;<!-- /toc --&rt; tags, and then generate with hack/update-toc.sh.

Summary

The Summary section is incredibly important for producing high quality user-focused documentation such as release notes or a development roadmap. It should be possible to collect this information before implementation begins in order to avoid requiring implementers to split their attention between writing release notes and implementing the feature itself.

A good summary is probably at least a paragraph in length.

Motivation

This section is for explicitly listing the motivation, goals and non-goals of this KEP. Describe why the change is important and the benefits to users. The motivation section can optionally provide links to experience reports to demonstrate the interest in a KEP within the wider Kubernetes community.

Goals

List the specific goals of the KEP. How will we know that this has succeeded?

Non-Goals

What is out of scope for this KEP? Listing non-goals helps to focus discussion and make progress.

Proposal

This is where we get down to the nitty gritty of what the proposal actually is.

User Stories [optional]

Detail the things that people will be able to do if this KEP is implemented. Include as much detail as possible so that people can understand the "how" of the system. The goal here is to make this feel real for users without getting bogged down.

Story 1

Story 2

Implementation Details/Notes/Constraints [optional]

What are the caveats to the implementation? What are some important details that didn't come across above. Go in to as much detail as necessary here. This might be a good place to talk about core concepts and how they relate.

Risks and Mitigations

What are the risks of this proposal and how do we mitigate. Think broadly. For example, consider both security and how this will impact the larger kubernetes ecosystem.

How will security be reviewed and by whom? How will UX be reviewed and by whom?

Consider including folks that also work outside project.

Design Details

Test Plan

Note: Section not required until targeted at a release.

Consider the following in developing a test plan for this enhancement:

  • Will there be e2e and integration tests, in addition to unit tests?
  • How will it be tested in isolation vs with other components?

No need to outline all of the test cases, just the general strategy. Anything that would count as tricky in the implementation and anything particularly challenging to test should be called out.

All code is expected to have adequate tests (eventually with coverage expectations). Please adhere to the Kubernetes testing guidelines when drafting this test plan.

Removing a deprecated flag

  • Announce deprecation and support policy of the existing flag
  • Two versions passed since introducing the functionality which deprecates the flag (to address version skew)
  • Address feedback on usage/changed behavior, provided on GitHub issues
  • Deprecate the flag

Implementation History

Major milestones in the life cycle of a KEP should be tracked in Implementation History. Major milestones might include

  • the Summary and Motivation sections being merged signaling acceptance
  • the Proposal section being merged signaling agreement on a proposed design
  • the date implementation started
  • the first Kubernetes release where an initial version of the KEP was available
  • the version of Kubernetes where the KEP graduated to general availability
  • when the KEP was retired or superseded

Drawbacks [optional]

Why should this KEP not be implemented.

Alternatives [optional]

Similar to the Drawbacks section the Alternatives section is used to highlight and record other possible approaches to delivering the value proposed by a KEP.

\ No newline at end of file diff --git a/enhancements/index.html b/enhancements/index.html index 07bf11b9f..ee60e596f 100644 --- a/enhancements/index.html +++ b/enhancements/index.html @@ -1 +1 @@ - Kubernetes Enhancement Proposals (KEPs) - Ingress-Nginx Controller

Kubernetes Enhancement Proposals (KEPs)

A Kubernetes Enhancement Proposal (KEP) is a way to propose, communicate and coordinate on new efforts for the Kubernetes project. For this reason, the ingress-nginx project is adopting it.

Quick start for the KEP process

Follow the process outlined in the KEP template

Do I have to use the KEP process?

No... but we hope that you will. Over time having a rich set of KEPs in one place will make it easier for people to track what is going on in the community and find a structured historic record.

KEPs are only required when the changes are wide ranging and impact most of the project.

Why would I want to use the KEP process?

Our aim with KEPs is to clearly communicate new efforts to the Kubernetes contributor community. As such, we want to build a well curated set of clear proposals in a common format with useful metadata.

Benefits to KEP users (in the limit):

  • Exposure on a kubernetes blessed web site that is findable via web search engines.
  • Cross indexing of KEPs so that users can find connections and the current status of any KEP.
  • A clear process with approvers and reviewers for making decisions. This will lead to more structured decisions that stick as there is a discoverable record around the decisions.

We are inspired by IETF RFCs, Python PEPs, and Rust RFCs.

\ No newline at end of file + Kubernetes Enhancement Proposals (KEPs) - Ingress-Nginx Controller

Kubernetes Enhancement Proposals (KEPs)

A Kubernetes Enhancement Proposal (KEP) is a way to propose, communicate and coordinate on new efforts for the Kubernetes project. For this reason, the ingress-nginx project is adopting it.

Quick start for the KEP process

Follow the process outlined in the KEP template

Do I have to use the KEP process?

No... but we hope that you will. Over time having a rich set of KEPs in one place will make it easier for people to track what is going on in the community and find a structured historic record.

KEPs are only required when the changes are wide ranging and impact most of the project.

Why would I want to use the KEP process?

Our aim with KEPs is to clearly communicate new efforts to the Kubernetes contributor community. As such, we want to build a well curated set of clear proposals in a common format with useful metadata.

Benefits to KEP users (in the limit):

  • Exposure on a kubernetes blessed web site that is findable via web search engines.
  • Cross indexing of KEPs so that users can find connections and the current status of any KEP.
  • A clear process with approvers and reviewers for making decisions. This will lead to more structured decisions that stick as there is a discoverable record around the decisions.

We are inspired by IETF RFCs, Python PEPs, and Rust RFCs.

\ No newline at end of file diff --git a/examples/PREREQUISITES/index.html b/examples/PREREQUISITES/index.html index 90a44c98f..44bb9068b 100644 --- a/examples/PREREQUISITES/index.html +++ b/examples/PREREQUISITES/index.html @@ -1,4 +1,4 @@ - Prerequisites - Ingress-Nginx Controller

Prerequisites

Many of the examples in this directory have common prerequisites.

TLS certificates

Unless otherwise mentioned, the TLS secret used in examples is a 2048 bit RSA key/cert pair with an arbitrarily chosen hostname, created as follows

$ openssl req -x509 -sha256 -nodes -days 365 -newkey rsa:2048 -keyout tls.key -out tls.crt -subj "/CN=nginxsvc/O=nginxsvc"
+ Prerequisites - Ingress-Nginx Controller      

Prerequisites

Many of the examples in this directory have common prerequisites.

TLS certificates

Unless otherwise mentioned, the TLS secret used in examples is a 2048 bit RSA key/cert pair with an arbitrarily chosen hostname, created as follows

$ openssl req -x509 -sha256 -nodes -days 365 -newkey rsa:2048 -keyout tls.key -out tls.crt -subj "/CN=nginxsvc/O=nginxsvc"
 Generating a 2048 bit RSA private key
 ................+++
 ................+++
diff --git a/examples/affinity/cookie/index.html b/examples/affinity/cookie/index.html
index 02f1f97b3..f88c027fb 100644
--- a/examples/affinity/cookie/index.html
+++ b/examples/affinity/cookie/index.html
@@ -1,4 +1,4 @@
- Sticky Sessions - Ingress-Nginx Controller      

Sticky sessions

This example demonstrates how to achieve session affinity using cookies.

Deployment

Session affinity can be configured using the following annotations:

Name Description Value
nginx.ingress.kubernetes.io/affinity Type of the affinity, set this to cookie to enable session affinity string (NGINX only supports cookie)
nginx.ingress.kubernetes.io/affinity-mode The affinity mode defines how sticky a session is. Use balanced to redistribute some sessions when scaling pods or persistent for maximum stickiness. balanced (default) or persistent
nginx.ingress.kubernetes.io/affinity-canary-behavior Defines session affinity behavior of canaries. By default the behavior is sticky, and canaries respect session affinity configuration. Set this to legacy to restore original canary behavior, when session affinity parameters were not respected. sticky (default) or legacy
nginx.ingress.kubernetes.io/session-cookie-name Name of the cookie that will be created string (defaults to INGRESSCOOKIE)
nginx.ingress.kubernetes.io/session-cookie-secure Set the cookie as secure regardless the protocol of the incoming request "true" or "false"
nginx.ingress.kubernetes.io/session-cookie-path Path that will be set on the cookie (required if your Ingress paths use regular expressions) string (defaults to the currently matched path)
nginx.ingress.kubernetes.io/session-cookie-domain Domain that will be set on the cookie string
nginx.ingress.kubernetes.io/session-cookie-samesite SameSite attribute to apply to the cookie Browser accepted values are None, Lax, and Strict
nginx.ingress.kubernetes.io/session-cookie-conditional-samesite-none Will omit SameSite=None attribute for older browsers which reject the more-recently defined SameSite=None value "true" or "false"
nginx.ingress.kubernetes.io/session-cookie-max-age Time until the cookie expires, corresponds to the Max-Age cookie directive number of seconds
nginx.ingress.kubernetes.io/session-cookie-expires Legacy version of the previous annotation for compatibility with older browsers, generates an Expires cookie directive by adding the seconds to the current date number of seconds
nginx.ingress.kubernetes.io/session-cookie-change-on-failure When set to false nginx ingress will send request to upstream pointed by sticky cookie even if previous attempt failed. When set to true and previous attempt failed, sticky cookie will be changed to point to another upstream. true or false (defaults to false)

You can create the session affinity example Ingress to test this:

kubectl create -f ingress.yaml
+ Sticky Sessions - Ingress-Nginx Controller      

Sticky sessions

This example demonstrates how to achieve session affinity using cookies.

Deployment

Session affinity can be configured using the following annotations:

Name Description Value
nginx.ingress.kubernetes.io/affinity Type of the affinity, set this to cookie to enable session affinity string (NGINX only supports cookie)
nginx.ingress.kubernetes.io/affinity-mode The affinity mode defines how sticky a session is. Use balanced to redistribute some sessions when scaling pods or persistent for maximum stickiness. balanced (default) or persistent
nginx.ingress.kubernetes.io/affinity-canary-behavior Defines session affinity behavior of canaries. By default the behavior is sticky, and canaries respect session affinity configuration. Set this to legacy to restore original canary behavior, when session affinity parameters were not respected. sticky (default) or legacy
nginx.ingress.kubernetes.io/session-cookie-name Name of the cookie that will be created string (defaults to INGRESSCOOKIE)
nginx.ingress.kubernetes.io/session-cookie-secure Set the cookie as secure regardless the protocol of the incoming request "true" or "false"
nginx.ingress.kubernetes.io/session-cookie-path Path that will be set on the cookie (required if your Ingress paths use regular expressions) string (defaults to the currently matched path)
nginx.ingress.kubernetes.io/session-cookie-domain Domain that will be set on the cookie string
nginx.ingress.kubernetes.io/session-cookie-samesite SameSite attribute to apply to the cookie Browser accepted values are None, Lax, and Strict
nginx.ingress.kubernetes.io/session-cookie-conditional-samesite-none Will omit SameSite=None attribute for older browsers which reject the more-recently defined SameSite=None value "true" or "false"
nginx.ingress.kubernetes.io/session-cookie-max-age Time until the cookie expires, corresponds to the Max-Age cookie directive number of seconds
nginx.ingress.kubernetes.io/session-cookie-expires Legacy version of the previous annotation for compatibility with older browsers, generates an Expires cookie directive by adding the seconds to the current date number of seconds
nginx.ingress.kubernetes.io/session-cookie-change-on-failure When set to false nginx ingress will send request to upstream pointed by sticky cookie even if previous attempt failed. When set to true and previous attempt failed, sticky cookie will be changed to point to another upstream. true or false (defaults to false)

You can create the session affinity example Ingress to test this:

kubectl create -f ingress.yaml
 

Validation

You can confirm that the Ingress works:

$ kubectl describe ing nginx-test
 Name:           nginx-test
 Namespace:      default
diff --git a/examples/auth/basic/index.html b/examples/auth/basic/index.html
index 2b711929c..e129789d7 100644
--- a/examples/auth/basic/index.html
+++ b/examples/auth/basic/index.html
@@ -1,4 +1,4 @@
- Basic Authentication - Ingress-Nginx Controller      

Basic Authentication

This example shows how to add authentication in a Ingress rule using a secret that contains a file generated with htpasswd. It's important the file generated is named auth (actually - that the secret has a key data.auth), otherwise the ingress-controller returns a 503.

Create htpasswd file

$ htpasswd -c auth foo
+ Basic Authentication - Ingress-Nginx Controller      

Basic Authentication

This example shows how to add authentication in a Ingress rule using a secret that contains a file generated with htpasswd. It's important the file generated is named auth (actually - that the secret has a key data.auth), otherwise the ingress-controller returns a 503.

Create htpasswd file

$ htpasswd -c auth foo
 New password: <bar>
 New password:
 Re-type new password:
diff --git a/examples/auth/client-certs/index.html b/examples/auth/client-certs/index.html
index 82f42ccbf..ab363f8cc 100644
--- a/examples/auth/client-certs/index.html
+++ b/examples/auth/client-certs/index.html
@@ -1,4 +1,4 @@
- Client Certificate Authentication - Ingress-Nginx Controller      

Client Certificate Authentication

It is possible to enable Client-Certificate Authentication by adding additional annotations to your Ingress Resource.

1. Prerequisites / Certificates

  • Certificate Authority (CA) Certificate ca-cert.pem
  • Server Certificate (Signed by CA) and Key server-cert.pem and server-key.pem
  • Client Certificate (Signed by CA), Key and CA Certificate for following client side authentication (See Sub-Section 4 - Test)

📝 If Intermediate CA-Certificates (Official CA, non-self-signed) used, they all need to be concatenated (CA authority chain) in one CA file.

The following commands let you generate self-signed Certificates and Keys for testing-purpose.

  • Generate the CA Key and Certificate:
openssl req -x509 -sha256 -newkey rsa:4096 -keyout ca-key.der -out ca-cert.der -days 356 -nodes -subj '/CN=My Cert Authority'
+ Client Certificate Authentication - Ingress-Nginx Controller      

Client Certificate Authentication

It is possible to enable Client-Certificate Authentication by adding additional annotations to your Ingress Resource.

1. Prerequisites / Certificates

  • Certificate Authority (CA) Certificate ca-cert.pem
  • Server Certificate (Signed by CA) and Key server-cert.pem and server-key.pem
  • Client Certificate (Signed by CA), Key and CA Certificate for following client side authentication (See Sub-Section 4 - Test)

📝 If Intermediate CA-Certificates (Official CA, non-self-signed) used, they all need to be concatenated (CA authority chain) in one CA file.

The following commands let you generate self-signed Certificates and Keys for testing-purpose.

  • Generate the CA Key and Certificate:
openssl req -x509 -sha256 -newkey rsa:4096 -keyout ca-key.der -out ca-cert.der -days 356 -nodes -subj '/CN=My Cert Authority'
 
  • Generate the Server Key, and Certificate and Sign with the CA Certificate:
openssl req -new -newkey rsa:4096 -keyout server-key.der -out server.csr -nodes -subj '/CN=mydomain.com'
 openssl x509 -req -sha256 -days 365 -in server.csr -CA ca-cert.der -CAkey ca-key.der -set_serial 01 -out server-cert.der
 

📝 The CN (Common Name) x.509 attribute for the server Certificate must match the dns hostname referenced in ingress definition, see example below.

  • Generate the Client Key, and Certificate and Sign with the CA Certificate:
openssl req -new -newkey rsa:4096 -keyout client-key.der -out client.csr -nodes -subj '/CN=My Client'
diff --git a/examples/auth/external-auth/index.html b/examples/auth/external-auth/index.html
index 26532545b..4e33d9e91 100644
--- a/examples/auth/external-auth/index.html
+++ b/examples/auth/external-auth/index.html
@@ -1,4 +1,4 @@
- External Basic Authentication - Ingress-Nginx Controller      

External Basic Authentication

Example 1

Use an external service (Basic Auth) located in https://httpbin.org

$ kubectl create -f ingress.yaml
+ External Basic Authentication - Ingress-Nginx Controller      

External Basic Authentication

Example 1

Use an external service (Basic Auth) located in https://httpbin.org

$ kubectl create -f ingress.yaml
 ingress "external-auth" created
 
 $ kubectl get ing external-auth
diff --git a/examples/auth/oauth-external-auth/index.html b/examples/auth/oauth-external-auth/index.html
index 012f48ac2..73c35b3e5 100644
--- a/examples/auth/oauth-external-auth/index.html
+++ b/examples/auth/oauth-external-auth/index.html
@@ -1,4 +1,4 @@
- External OAUTH Authentication - Ingress-Nginx Controller      

External OAUTH Authentication

Overview

The auth-url and auth-signin annotations allow you to use an external authentication provider to protect your Ingress resources.

Important

This annotation requires ingress-nginx-controller v0.9.0 or greater.

Key Detail

This functionality is enabled by deploying multiple Ingress objects for a single host. One Ingress object has no special annotations and handles authentication.

Other Ingress objects can then be annotated in such a way that require the user to authenticate against the first Ingress's endpoint, and can redirect 401s to the same endpoint.

Sample:

...
+ External OAUTH Authentication - Ingress-Nginx Controller      

External OAUTH Authentication

Overview

The auth-url and auth-signin annotations allow you to use an external authentication provider to protect your Ingress resources.

Important

This annotation requires ingress-nginx-controller v0.9.0 or greater.

Key Detail

This functionality is enabled by deploying multiple Ingress objects for a single host. One Ingress object has no special annotations and handles authentication.

Other Ingress objects can then be annotated in such a way that require the user to authenticate against the first Ingress's endpoint, and can redirect 401s to the same endpoint.

Sample:

...
 metadata:
   name: application
   annotations:
diff --git a/examples/canary/index.html b/examples/canary/index.html
index c63b22142..ff57c53d6 100644
--- a/examples/canary/index.html
+++ b/examples/canary/index.html
@@ -1,4 +1,4 @@
- Canary Deployments - Ingress-Nginx Controller      

Canary

Ingress Nginx Has the ability to handle canary routing by setting specific annotations, the following is an example of how to configure a canary deployment with weighted canary routing.

Create your main deployment and service

This is the main deployment of your application with the service that will be used to route to it

echo "
+ Canary Deployments - Ingress-Nginx Controller      

Canary

Ingress Nginx Has the ability to handle canary routing by setting specific annotations, the following is an example of how to configure a canary deployment with weighted canary routing.

Create your main deployment and service

This is the main deployment of your application with the service that will be used to route to it

echo "
 ---
 # Deployment
 apiVersion: apps/v1
diff --git a/examples/customization/configuration-snippets/index.html b/examples/customization/configuration-snippets/index.html
index b1f7adeb2..1f924e53e 100644
--- a/examples/customization/configuration-snippets/index.html
+++ b/examples/customization/configuration-snippets/index.html
@@ -1,3 +1,3 @@
- Configuration Snippets - Ingress-Nginx Controller      

Configuration Snippets

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 an example of specifying custom headers.

kubectl apply -f ingress.yaml
+ Configuration Snippets - Ingress-Nginx Controller      

Configuration Snippets

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 an example of specifying custom headers.

kubectl apply -f ingress.yaml
 

Test

Check if the contents of the annotation are present in the nginx.conf file using:

kubectl exec ingress-nginx-controller-873061567-4n3k2 -n kube-system -- cat /etc/nginx/nginx.conf
 
\ No newline at end of file diff --git a/examples/customization/custom-configuration/index.html b/examples/customization/custom-configuration/index.html index 44a070650..4e52973bd 100644 --- a/examples/customization/custom-configuration/index.html +++ b/examples/customization/custom-configuration/index.html @@ -1,4 +1,4 @@ - Custom Configuration - Ingress-Nginx Controller

Custom Configuration

Using a ConfigMap is possible to customize the NGINX configuration

For example, if we want to change the timeouts we need to create a ConfigMap:

$ cat configmap.yaml
+ Custom Configuration - Ingress-Nginx Controller      

Custom Configuration

Using a ConfigMap is possible to customize the NGINX configuration

For example, if we want to change the timeouts we need to create a ConfigMap:

$ cat configmap.yaml
 apiVersion: v1
 data:
   proxy-connect-timeout: "10"
diff --git a/examples/customization/custom-errors/index.html b/examples/customization/custom-errors/index.html
index 770f89444..8bfcd7727 100644
--- a/examples/customization/custom-errors/index.html
+++ b/examples/customization/custom-errors/index.html
@@ -1,4 +1,4 @@
- Custom Errors - Ingress-Nginx Controller      

Custom Errors

This example demonstrates how to use a custom backend to render custom error pages.

If you are using Helm Chart, look at example values and don't forget to add configMap to your deployment, otherwise continue with Customized default backend manual deployment.

Customized default backend

First, create the custom default-backend. It will be used by the Ingress controller later on.
To do that, you can take a look at the example manifest in this project's GitHub repository.

$ kubectl create -f custom-default-backend.yaml
+ Custom Errors - Ingress-Nginx Controller      

Custom Errors

This example demonstrates how to use a custom backend to render custom error pages.

If you are using Helm Chart, look at example values and don't forget to add configMap to your deployment, otherwise continue with Customized default backend manual deployment.

Customized default backend

First, create the custom default-backend. It will be used by the Ingress controller later on.
To do that, you can take a look at the example manifest in this project's GitHub repository.

$ kubectl create -f custom-default-backend.yaml
 service "nginx-errors" created
 deployment.apps "nginx-errors" created
 

This should have created a Deployment and a Service with the name nginx-errors.

$ kubectl get deploy,svc
diff --git a/examples/customization/custom-headers/index.html b/examples/customization/custom-headers/index.html
index 967f0baeb..1048d0de9 100644
--- a/examples/customization/custom-headers/index.html
+++ b/examples/customization/custom-headers/index.html
@@ -1,4 +1,4 @@
- Custom Headers - Ingress-Nginx Controller      

Custom Headers

Caveats

Changes to the custom header config maps do not force a reload of the ingress-nginx-controllers.

Workaround

To work around this limitation, perform a rolling restart of the deployment.

Example

This example demonstrates configuration of the Ingress-Nginx Controller via a ConfigMap to pass a custom list of headers to the upstream server.

custom-headers.yaml defines a ConfigMap in the ingress-nginx namespace named custom-headers, holding several custom X-prefixed HTTP headers.

kubectl apply -f https://raw.githubusercontent.com/kubernetes/ingress-nginx/main/docs/examples/customization/custom-headers/custom-headers.yaml
+ Custom Headers - Ingress-Nginx Controller      

Custom Headers

Caveats

Changes to the custom header config maps do not force a reload of the ingress-nginx-controllers.

Workaround

To work around this limitation, perform a rolling restart of the deployment.

Example

This example demonstrates configuration of the Ingress-Nginx Controller via a ConfigMap to pass a custom list of headers to the upstream server.

custom-headers.yaml defines a ConfigMap in the ingress-nginx namespace named custom-headers, holding several custom X-prefixed HTTP headers.

kubectl apply -f https://raw.githubusercontent.com/kubernetes/ingress-nginx/main/docs/examples/customization/custom-headers/custom-headers.yaml
 

configmap.yaml defines a ConfigMap in the ingress-nginx namespace named ingress-nginx-controller. This controls the global configuration of the ingress controller, and already exists in a standard installation. The key proxy-set-headers is set to cite the previously-created ingress-nginx/custom-headers ConfigMap.

kubectl apply -f https://raw.githubusercontent.com/kubernetes/ingress-nginx/main/docs/examples/customization/custom-headers/configmap.yaml
 

The Ingress-Nginx Controller will read the ingress-nginx/ingress-nginx-controller ConfigMap, find the proxy-set-headers key, read HTTP headers from the ingress-nginx/custom-headers ConfigMap, and include those HTTP headers in all requests flowing from nginx to the backends.

The above example was for passing a custom list of headers to the upstream server. To pass the custom headers before sending response traffic to the client, use the add-headers key:

kubectl apply -f https://raw.githubusercontent.com/kubernetes/ingress-nginx/main/docs/examples/customization/custom-headers/configmap-client-response.yaml
 

Test

Check the contents of the ConfigMaps are present in the nginx.conf file using: kubectl exec ingress-nginx-controller-873061567-4n3k2 -n ingress-nginx -- cat /etc/nginx/nginx.conf

\ No newline at end of file diff --git a/examples/customization/external-auth-headers/index.html b/examples/customization/external-auth-headers/index.html index e0eb497a4..0738208c9 100644 --- a/examples/customization/external-auth-headers/index.html +++ b/examples/customization/external-auth-headers/index.html @@ -1,4 +1,4 @@ - External authentication - Ingress-Nginx Controller

External authentication, authentication service response headers propagation

This example demonstrates propagation of selected authentication service response headers to a backend service.

Sample configuration includes:

  • Sample authentication service producing several response headers
  • Authentication logic is based on HTTP header: requests with header User containing string internal are considered authenticated
  • After successful authentication service generates response headers UserID and UserRole
  • Sample echo service displaying header information
  • Two ingress objects pointing to echo service
  • Public, which allows access from unauthenticated users
  • Private, which allows access from authenticated users only

You can deploy the controller as follows:

$ kubectl create -f deploy/
+ External authentication - Ingress-Nginx Controller      

External authentication, authentication service response headers propagation

This example demonstrates propagation of selected authentication service response headers to a backend service.

Sample configuration includes:

  • Sample authentication service producing several response headers
  • Authentication logic is based on HTTP header: requests with header User containing string internal are considered authenticated
  • After successful authentication service generates response headers UserID and UserRole
  • Sample echo service displaying header information
  • Two ingress objects pointing to echo service
  • Public, which allows access from unauthenticated users
  • Private, which allows access from authenticated users only

You can deploy the controller as follows:

$ kubectl create -f deploy/
 deployment "demo-auth-service" created
 service "demo-auth-service" created
 ingress "demo-auth-service" created
diff --git a/examples/customization/jwt/index.html b/examples/customization/jwt/index.html
index 016c2ffb7..4c16cf15a 100644
--- a/examples/customization/jwt/index.html
+++ b/examples/customization/jwt/index.html
@@ -1,4 +1,4 @@
- Accommodation for JWT - Ingress-Nginx Controller      

Accommodation for JWT

JWT (short for Json Web Token) is an authentication method widely used. Basically an authentication server generates a JWT and you then use this token in every request you make to a backend service. The JWT can be quite big and is present in every http headers. This means you may have to adapt the max-header size of your nginx-ingress in order to support it.

Symptoms

If you use JWT and you get http 502 error from your ingress, it may be a sign that the buffer size is not big enough.

To be 100% sure look at the logs of the ingress-nginx-controller pod, you should see something like this:

upstream sent too big header while reading response header from upstream...
+ Accommodation for JWT - Ingress-Nginx Controller      

Accommodation for JWT

JWT (short for Json Web Token) is an authentication method widely used. Basically an authentication server generates a JWT and you then use this token in every request you make to a backend service. The JWT can be quite big and is present in every http headers. This means you may have to adapt the max-header size of your nginx-ingress in order to support it.

Symptoms

If you use JWT and you get http 502 error from your ingress, it may be a sign that the buffer size is not big enough.

To be 100% sure look at the logs of the ingress-nginx-controller pod, you should see something like this:

upstream sent too big header while reading response header from upstream...
 

Increase buffer size for headers

In nginx, we want to modify the property proxy-buffer-size. The size is arbitrary. It depends on your needs. Be aware that a high value can lower the performance of your ingress proxy. In general a value of 16k should get you covered.

Using helm

If you're using helm you can simply use the config properties.

 # -- Will add custom configuration options to Nginx https://kubernetes.github.io/ingress-nginx/user-guide/nginx-configuration/configmap/
   config: 
     proxy-buffer-size: 16k
diff --git a/examples/customization/ssl-dh-param/index.html b/examples/customization/ssl-dh-param/index.html
index 68ebc6372..d422a0c80 100644
--- a/examples/customization/ssl-dh-param/index.html
+++ b/examples/customization/ssl-dh-param/index.html
@@ -1,4 +1,4 @@
- Custom DH parameters for perfect forward secrecy - Ingress-Nginx Controller      

Custom DH parameters for perfect forward secrecy

This example aims to demonstrate the deployment of an Ingress-Nginx Controller and use a ConfigMap to configure a custom Diffie-Hellman parameters file to help with "Perfect Forward Secrecy".

Custom configuration

$ cat configmap.yaml
+ Custom DH parameters for perfect forward secrecy - Ingress-Nginx Controller      

Custom DH parameters for perfect forward secrecy

This example aims to demonstrate the deployment of an Ingress-Nginx Controller and use a ConfigMap to configure a custom Diffie-Hellman parameters file to help with "Perfect Forward Secrecy".

Custom configuration

$ cat configmap.yaml
 apiVersion: v1
 data:
   ssl-dh-param: "ingress-nginx/lb-dhparam"
diff --git a/examples/customization/sysctl/index.html b/examples/customization/sysctl/index.html
index f693d0d9b..60241ef75 100644
--- a/examples/customization/sysctl/index.html
+++ b/examples/customization/sysctl/index.html
@@ -1,3 +1,3 @@
- Sysctl tuning - Ingress-Nginx Controller      

Sysctl tuning

This example aims to demonstrate the use of an Init Container to adjust sysctl default values using kubectl patch.

kubectl patch deployment -n ingress-nginx ingress-nginx-controller \
+ Sysctl tuning - Ingress-Nginx Controller      

Sysctl tuning

This example aims to demonstrate the use of an Init Container to adjust sysctl default values using kubectl patch.

kubectl patch deployment -n ingress-nginx ingress-nginx-controller \
     --patch="$(curl https://raw.githubusercontent.com/kubernetes/ingress-nginx/main/docs/examples/customization/sysctl/patch.json)"
 

Changes:

  • Backlog Queue setting net.core.somaxconn from 128 to 32768
  • Ephemeral Ports setting net.ipv4.ip_local_port_range from 32768 60999 to 1024 65000

In a post from the NGINX blog, it is possible to see an explanation for the changes.

\ No newline at end of file diff --git a/examples/docker-registry/index.html b/examples/docker-registry/index.html index a01ae4845..59e60023a 100644 --- a/examples/docker-registry/index.html +++ b/examples/docker-registry/index.html @@ -1,4 +1,4 @@ - Docker registry - Ingress-Nginx Controller

Docker registry

This example demonstrates how to deploy a docker registry in the cluster and configure Ingress to enable access from the Internet.

Deployment

First we deploy the docker registry in the cluster:

kubectl apply -f https://raw.githubusercontent.com/kubernetes/ingress-nginx/main/docs/examples/docker-registry/deployment.yaml
+ Docker registry - Ingress-Nginx Controller      

Docker registry

This example demonstrates how to deploy a docker registry in the cluster and configure Ingress to enable access from the Internet.

Deployment

First we deploy the docker registry in the cluster:

kubectl apply -f https://raw.githubusercontent.com/kubernetes/ingress-nginx/main/docs/examples/docker-registry/deployment.yaml
 

Important

DO NOT RUN THIS IN PRODUCTION

This deployment uses emptyDir in the volumeMount which means the contents of the registry will be deleted when the pod dies.

The next required step is creation of the ingress rules. To do this we have two options: with and without TLS

Without TLS

Download and edit the yaml deployment replacing registry.<your domain> with a valid DNS name pointing to the ingress controller:

wget https://raw.githubusercontent.com/kubernetes/ingress-nginx/main/docs/examples/docker-registry/ingress-without-tls.yaml
 

Important

Running a docker registry without TLS requires we configure our local docker daemon with the insecure registry flag.

Please check deploy a plain http registry

With TLS

Download and edit the yaml deployment replacing registry.<your domain> with a valid DNS name pointing to the ingress controller:

wget https://raw.githubusercontent.com/kubernetes/ingress-nginx/main/docs/examples/docker-registry/ingress-with-tls.yaml
 

Deploy kube lego use Let's Encrypt certificates or edit the ingress rule to use a secret with an existing SSL certificate.

Testing

To test the registry is working correctly we download a known image from docker hub, create a tag pointing to the new registry and upload the image:

docker pull ubuntu:16.04
diff --git a/examples/grpc/index.html b/examples/grpc/index.html
index c490fdbd5..cf74a18c1 100644
--- a/examples/grpc/index.html
+++ b/examples/grpc/index.html
@@ -1,4 +1,4 @@
- gRPC - Ingress-Nginx Controller      

gRPC

This example demonstrates how to route traffic to a gRPC service through the Ingress-NGINX controller.

Prerequisites

  1. You have a kubernetes cluster running.
  2. You have a domain name such as example.com that is configured to route traffic to the Ingress-NGINX controller.
  3. You have the ingress-nginx-controller installed as per docs.
  4. You have a backend application running a gRPC server listening for TCP traffic. If you want, you can use https://github.com/grpc/grpc-go/blob/91e0aeb192456225adf27966d04ada4cf8599915/examples/features/reflection/server/main.go as an example.
  5. You're also responsible for provisioning an SSL certificate for the ingress. So you need to have a valid SSL certificate, deployed as a Kubernetes secret of type tls, in the same namespace as the gRPC application.
  6. Note: To use gRPC with ingress-nginx, TLS must be terminated by the ingress or gRPC server (using the backend-protocol: "GRPCS" annotation described below).

Step 1: Create a Kubernetes Deployment for gRPC app