Chapter 5. Using ingress control for a MicroShift node
Use the ingress controller options in the MicroShift configuration file to make pods and services accessible outside the node.
5.1. Using ingress control in MicroShift Copy linkLink copied to clipboard!
When you create your MicroShift node, each pod and service running on the node is allocated an IP address. These IP addresses are accessible to other pods and services running nearby by default, but are not accessible to external clients. MicroShift uses a minimal implementation of the OpenShift Container Platform IngressController API to enable external access to node services.
With more configuration options, you can fine-tune ingress to meet your specific needs. To use enhanced ingress control, update the parameters in the MicroShift configuration file and restart the service. Ingress configuration is useful in a variety of ways, for example:
-
If your application starts processing requests from clients but the connection is closed before it can respond, you can set the
ingress.tuningOptions.serverTimeoutparameter in the configuration file to a higher value to accommodate the speed of the response from the server. -
If the router has many connections open because an application running on the cluster does not close connections properly, you can set the
ingress.tuningOptions.serverTimeoutandspec.tuningOptions.serverFinTimeoutparameters to a lower value, forcing those connections to close sooner.
5.2. Configuring ingress control in MicroShift Copy linkLink copied to clipboard!
You can use detailed ingress control settings by updating the MicroShift service configuration file.
Prerequisites
-
You installed the OpenShift CLI (
oc). - You have root access to the node.
- Your node uses the OVN-Kubernetes Container Network Interface (CNI) plugin.
Procedure
Apply ingress control settings in one of the two following ways:
Update the MicroShift
config.yamlconfiguration file by making a copy of the providedconfig.yaml.defaultfile in the/etc/microshift/directory, naming itconfig.yamland keeping it in the source directory.-
After you create it, the
config.yamlfile takes precedence over built-in settings. The configuration file is read every time the MicroShift service starts.
-
After you create it, the
Use a configuration snippet to apply the ingress control settings you want. To do this, create a configuration snippet YAML file and put it in the
/etc/microshift/config.d/configuration directory.-
Configuration snippet YAMLs take precedence over both built-in settings and a
config.yamlconfiguration file. See the Additional resources links for more information.
-
Configuration snippet YAMLs take precedence over both built-in settings and a
Replace the default values in the
networksection of the MicroShift YAML with your valid values, or create a configuration snippet file with the sections you need.Ingress controller configuration fields with default values
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Expand Table 5.1. Ingress controller configuration fields definitions table Parameter Description defaultHTTPVersionSets the HTTP version for the ingress controller. Default value is
1for HTTP 1.1.forwardedHeaderPolicySpecifies when and how the ingress controller sets the
Forwarded,X-Forwarded-For,X-Forwarded-Host,X-Forwarded-Port,X-Forwarded-Proto, andX-Forwarded-Proto-VersionHTTP headers. The following values are valid:-
Append, preserves any existing headers by specifying that the ingress controller appends them. -
Replace, removes any existing headers by specifying that the ingress controller sets the headers. -
IfNonesets the headers set by specifying that the ingress controller sets the headers if they are not already set. -
Never, preserves any existing headers by specifying that the ingress controller never sets the headers.
httpCompressionDefines the policy for HTTP traffic compression.
-
httpCompression.mimeTypesdefines a list of or a single MIME type to which compression is applied. For example,text/css; charset=utf-8,text/html,text/*,image/svg+xml,application/octet-stream,X-custom/customsub, using the format pattern,type/subtype; [;attribute=value]. Thetypesare: application, image, message, multipart, text, video, or a custom type prefaced byX-. To see the full notation for MIME types and subtypes, see RFC1341 (IETF Datatracker documentation).
httpEmptyRequestsPolicyDescribes how HTTP connections are handled if the connection times out before a request is received. Allowed values for this field are
RespondandIgnore. The default value isRespond. The following are valid values:-
Respond, causes the ingress controller to send an HTTP400or408response, logs the connection if access logging is enabled, and counts the connection in the appropriate metrics. -
Ignore, adds thehttp-ignore-probesparameter in theHAproxyconfiguration. If the field is set toIgnore, the ingress controller closes the connection without sending a response, then logs the connection or incrementing metrics.
Usually, empty request connections come from load balancer health probes or web browser preconnects and can be safely ignored. However, network errors and port scans can also create these empty requests, so setting this field to
Ignorecan impede detecting or diagnosing problems and also impede the detection of intrusion attempts.logEmptyRequestsSpecifies connections for which no request is received and logged. Usually, these empty requests come from load balancer health probes or web browser speculative connections such as preconnects. Logging these types of empty requests can be undesirable. However, network errors and port scans can also create empty requests, so setting this field to
Ignorecan impede detecting or diagnosing problems and also impede the detection of intrusion attempts.The following are valid values:
-
Log, which indicates that an event should be logged. -
Ignore, which sets thedontlognulloption in theHAproxyconfiguration.
tuningOptionsSpecifies options for tuning the performance of ingress controller pods.
-
The
tuningOptions.clientFinTimeoutparameter specifies how long a connection is held open while waiting for the client response to the server closing the connection. The default timeout is1s. -
The
tuningOptions.clientTimeoutparameter specifies how long a connection is held open while waiting for a client response. The default timeout is30s. The
tuningOptions.headerBufferBytesparameter specifies how much memory is reserved, in bytes, for Ingress Controller connection sessions. This value must be at least16384if HTTP/2 is enabled for the Ingress Controller. If not set, the default value is32768bytes.ImportantSetting this field not recommended because
headerBufferMaxRewriteBytesparameter values that are too small can break the ingress controller. Conversely, values forheaderBufferMaxRewriteBytesthat are too large could cause the ingress controller to use significantly more memory than necessary.-
The
tuningOptions.headerBufferMaxRewriteBytesparameter specifies how much memory should be reserved, in bytes, fromheaderBufferBytesfor HTTP header rewriting and appending for Ingress Controller connection sessions. The minimum value forheaderBufferMaxRewriteBytesis4096. TheheaderBufferBytesvalue must be greater than theheaderBufferMaxRewriteBytesvalue for incoming HTTP requests. If not set, the default value is
8192bytes.ImportantSetting this field is not recommended because
headerBufferMaxRewriteBytesparameter values that are too small can break the ingress controller. Conversely, values forheaderBufferMaxRewriteBytesthat are too large could cause the ingress controller to use significantly more memory than necessary.-
The
tuningOptions.healthCheckIntervalparameter specifies how long the router waits between health checks. The default is5s. -
The
tuningOptions.serverFinTimeoutparameter specifies how long a connection is held open while waiting for the server response to the client that is closing the connection. The default timeout is1s. -
The
tuningOptions.serverTimeoutparameter specifies how long a connection is held open while waiting for a server response. The default timeout is30s. The
tuningOptions.threadCountparameter specifies the number of threads to create per HAProxy process. Creating more threads allows each ingress controller pod to handle more connections, at the cost of more system resources being used.HAProxysupports up to64threads. If this field is empty, default value is4threads.ImportantSetting this field is not recommended because increasing the number of
HAProxythreads allows ingress controller pods to use more CPU time under load, and prevent other pods from receiving the CPU resources they need to perform.-
The
tuningOptions.tlsInspectDelayparameter specifies how long the router can hold data to find a matching route. Setting this value too short can cause the router to fall back to the default certificate for edge-terminated, re-encrypted, or passthrough routes, even when using a better-matched certificate. The default inspect delay is5s. -
The
tuningOptions.tunnelTimeoutparameter specifies how long a tunnel connection, including websockets, remains open while the tunnel is idle. The default timeout is1h.
-
Complete any other configurations you require, then start or restart MicroShift by running one the following commands:
sudo systemctl start microshift
$ sudo systemctl start microshiftCopy to Clipboard Copied! Toggle word wrap Toggle overflow sudo systemctl restart microshift
$ sudo systemctl restart microshiftCopy to Clipboard Copied! Toggle word wrap Toggle overflow
Verification
After making ingress configuration changes and restarting MicroShift, you can check the age of the router pod to ensure that changes have been applied.
To check the status of the router pod, run the following command:
oc get pods -n openshift-ingress
$ oc get pods -n openshift-ingressCopy to Clipboard Copied! Toggle word wrap Toggle overflow Example output
NAME READY STATUS RESTARTS AGE router-default-8649b5bf65-w29cn 1/1 Running 0 6m10s
NAME READY STATUS RESTARTS AGE router-default-8649b5bf65-w29cn 1/1 Running 0 6m10sCopy to Clipboard Copied! Toggle word wrap Toggle overflow