Chapter 3. Using ingress control for a MicroShift cluster
Use the ingress controller options in the MicroShift configuration file to make pods and services accessible outside the cluster.
3.1. Using ingress control in MicroShift
When you create your MicroShift cluster, each pod and service running on the cluster 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 cluster 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.serverTimeout
parameter 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.serverTimeout
andspec.tuningOptions.serverFinTimeout
parameters to a lower value, forcing those connections to close sooner. -
If you need to configure the ingress controller to verify client certificates, you can use the
ingress.clientTLS
parameter to set a clientCA value, which is a reference to a config map. The config map contains the PEM-encoded CA certificate bundle that is used to verify a client’s certificate. Optionally, you can also configure a list of certificate subject filters. -
If you need to configure a TLS security profile for an ingress controller, you can use the
ingress.tlsSecurityProfile
parameter to specify a default or custom individual TLS security profiles. The TLS security profile defines the minimum TLS version and the TLS ciphers for TLS connections for the ingress controllers. If a TLS security profile is not configured, the default value is based on the TLS security profile set for the API server. -
If you need to define a policy for handling new route claims, you can use the
routeAdmission
parameter to allow or deny claims across namespaces. You set therouteAdmission
parameter to describe how hostname claims across namespaces should be handled and to describe how routes with wildcard policies are handled by the ingress controller.
3.2. Configuring ingress control in MicroShift
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 cluster.
- Your cluster 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.yaml
configuration file by making a copy of the providedconfig.yaml.default
file in the/etc/microshift/
directory, naming itconfig.yaml
and keeping it in the source directory.ImportantAfter you create the
config.yaml
, the configuration file takes precedence over built-in settings. Theconfig.yaml
file is read every time the MicroShift service starts.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.ImportantConfiguration snippet YAMLs take precedence over both built-in settings and the
config.yaml
configuration file.
Replace the default values in the
ingress
section 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
apiServer: # ... ingress: certificateSecret: router-certs-custom clientTLS: allowedSubjectPatterns: [] clientCA: name: "" clientCertificatePolicy: "" defaultHTTPVersion: 1 forwardedHeaderPolicy: Append httpCompression: mimeTypes: - "" httpEmptyRequestsPolicy: Respond listenAddress: [] logEmptyRequests: Log ports: http: 80 https: 443 routeAdmissionPolicy: namespaceOwnership: InterNamespaceAllowed wildcardPolicy: WildcardsDisallowed status: Managed tlsSecurityProfile: type: custom: ciphers:[] minTLSVersion:"" intermediate: {} old: {} type: "" tuningOptions: clientFinTimeout: 1s clientTimeout: 30s headerBufferBytes: 0 headerBufferMaxRewriteBytes: 0 healthCheckInterval: 5s maxConnections: 0 serverFinTimeout: 1s serverTimeout: 30s threadCount: 4 tlsInspectDelay: 5s tunnelTimeout: 1h # ...
apiServer: # ... ingress: certificateSecret: router-certs-custom clientTLS: allowedSubjectPatterns: [] clientCA: name: "" clientCertificatePolicy: "" defaultHTTPVersion: 1 forwardedHeaderPolicy: Append httpCompression: mimeTypes: - "" httpEmptyRequestsPolicy: Respond listenAddress: [] logEmptyRequests: Log ports: http: 80 https: 443 routeAdmissionPolicy: namespaceOwnership: InterNamespaceAllowed wildcardPolicy: WildcardsDisallowed status: Managed tlsSecurityProfile: type: custom: ciphers:[] minTLSVersion:"" intermediate: {} old: {} type: "" tuningOptions: clientFinTimeout: 1s clientTimeout: 30s headerBufferBytes: 0 headerBufferMaxRewriteBytes: 0 healthCheckInterval: 5s maxConnections: 0 serverFinTimeout: 1s serverTimeout: 30s threadCount: 4 tlsInspectDelay: 5s tunnelTimeout: 1h # ...
Copy to Clipboard Copied! Table 3.1. Ingress controller configuration fields definitions table Parameter Description ingress
The
ingress
section of the MicroShiftconfig.yaml
file defines the configurable parameters for the implemented portions of the OpenShift Container Platform Ingress Control Operator. All parameters in the rest of this table are subsections in theingress
section of theconfig.yaml
.certificateSecret
A reference to a
kubernetes.io/tls
type of secret that contains the default certificate that is served by the MicroShift ingress controller. When routes do not specify their own certificate, thecertificateSecret
parameter is used. All secrets used must containtls.key
key file contents andtls.crt
certificate file contents.-
When the
certificateSecret
parameter is not set, a wildcard certificate is automatically generated and used. The wildcard certificate is valid for the ingress controller defaultdomain
and itssubdomains
. The generated certificate authority (CA) is automatically integrated with the truststore of the cluster. - In-use generated and user-specified certificates are automatically integrated with the MicroShift built-in OAuth server.
clientTLS
Authenticates client access to the cluster and services. As a result, mutual TLS authentication is enabled. If not set, then client TLS is not enabled. You must set the
spec.clientTLS.clientCertificatePolicy
andspec.clientTLS.ClientCA
parameters to use client TLS.clientTLS.AllowedSubjectPatterns
Optional subfield that specifies a list of regular expressions that are matched against the distinguished name on a valid client certificate to filter requests. Use this parameter to cause the ingress controller to reject certificates based on the distinguished name. The Perl Compatible Regular Expressions (PCRE) syntax is required.
ImportantWhen configured, this field must contain a valid expression or the MicroShift service fails. At least one pattern must match a client certificate’s distinguished name; otherwise, the ingress controller rejects the certificate and denies the connection.
clientTLS.ClientCA
Specifies a required config map that is in the
openshift-ingress
namespace. Required to enable client TLS. The config map must contain a certificate authority (CA) bundle.clientTLS.ClientCA.name
The
metadata.name
of the config map referenced in theclientTLS.ClientCA
value.clientTLS.ClientCertificatePolicy
Required
orOptional
are valid values. Set toRequired
to enable client TLS. The ingress controller only checks client certificates for edge-terminated and re-encrypted TLS routes. The ingress controller cannot check certificates for plain text HTTP or passthrough TLS routes.defaultHTTPVersion
Sets the HTTP version for the ingress controller. Default value is
1
for HTTP 1.1.forwardedHeaderPolicy
Specifies when and how the ingress controller sets the
Forwarded
,X-Forwarded-For
,X-Forwarded-Host
,X-Forwarded-Port
,X-Forwarded-Proto
, andX-Forwarded-Proto-Version
HTTP headers. The following values are valid:-
Append
preserves any existing headers by specifying that the ingress controller appends them. 'Append` is the default value. -
Replace
removes any existing headers by specifying that the ingress controller sets the headers. -
IfNone
sets 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.
httpCompression
Defines the policy for HTTP traffic compression.
httpCompression.mimeTypes
Defines a list of MIME types to which compression should be applied.
-
For example,
text/css; charset=utf-8
,text/html
,text/*
,image/svg+xml
,application/octet-stream
,X-custom/customsub
, in the,type/subtype; [;attribute=value]
format. -
Valid
types
are: 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).
httpEmptyRequestsPolicy
Describes how HTTP connections are handled if the connection times out before a request is received. Allowed values for this field are
Respond
andIgnore
. The default value isRespond
. Empty requests typically come from load-balancer health probes or preconnects and can often be safely ignored. However, these requests can also be caused by network errors and port scans. Therefore, setting this field toIgnore
can impede detection or diagnosis of network problems and detecting intrusion attempts.-
When the policy is set to
Respond
, the ingress controller sends an HTTP400
or408
response, logs the connection if access logging is enabled, and counts the connection in the appropriate metrics. -
When the policy is set to
Ignore
, thehttp-ignore-probes
parameter is added to theHAproxy
process configuration. After this parameter is added, the ingress controller closes the connection without sending a response, then either logs the connection or incrementing metrics.
logEmptyRequests
Specifies connections for which no request is received and logged.
Log
andIgnore
are valid values. Empty requests typically come from load-balancer health probes or preconnects and can often be safely ignored. However, these requests can also be caused by network errors and port scans. Therefore, setting this field toIgnore
can impede detection or diagnosis of network problems and detecting intrusion attempts. The default value isLog
.-
Setting this value to
Log
indicates that an event should be logged. -
Setting this value to
Ignore
sets thedontlognull
option in theHAproxy
configuration.
ports
Defines default router ports.
ports.http
Default router http port. Must be in range 1-65535. Default value is
80
.ports.https
Default router https port. Must be in range 1-65535. Default value is
443
.routeAdmission
Defines a policy for handling new route claims, such as allowing or denying claims across namespaces.
routeAdmission.namespaceOwnership
Describes how hostname claims across namespaces should be handled. The default is
InterNamespaceAllowed
. The following are valid values:-
Strict
does not allow routes to claim the same hostname across namespaces. -
InterNamespaceAllowed
allows routes to claim different paths of the same hostname across namespaces.
routeAdmission.wildcardPolicy
Controls how routes with configured wildcard policies are handled by the ingress controller.
WildcardsAllowed
andWildcardsDisallowed
are valid values. Default value isWildcardsDisallowed
.-
WildcardPolicyAllowed
means that routes with any wildcard policy are admitted by the ingress controller. -
WildcardPolicyDisallowed
means that only routes with a wildcard policy ofNone
are admitted by the ingress controller.
ImportantChanging the wildcard policy from
WildcardsAllowed
toWildcardsDisallowed
causes admitted routes with a wildcard policy ofsubdomain
to stop working. These routes must be recreated to a wildcard policy ofNone
to be readmitted by the ingress controller.status
Default router status.
Managed
orRemoved
are valid values.tlsSecurityProfile
tlsSecurityProfile
specifies settings for TLS connections for ingress controllers. If not set, the default value is based on theapiservers.config.openshift.io/cluster
resource. The TLS1.0
version of anOld
orCustom
profile is automatically converted to1.1
by the ingress controller.Intermediate
is the default setting.-
The minimum TLS version for ingress controllers is
1.1
. The maximum TLS version is1.3
.
NoteCiphers and the minimum TLS version of the configured security profile are reflected in the
TLSProfile
status. Profiles are intent-based and change over time when new ciphers are developed and existing ciphers are found to be insecure. The usable list can be reduced depending on which ciphers are available to a specific process.tlsSecurityProfile.custom
User-defined TLS security profile. If you configure this parameter and related parameters, use extreme caution.
tlsSecurityProfile.custom.ciphers
Specifies the cipher algorithms that are negotiated during the TLS handshake. Operators might remove entries their operands do not support.
tlsSecurityProfile.custom.minTLSVersion
Specifies the minimal version of the TLS protocol that is negotiated during the TLS handshake. For example, to use TLS versions 1.1, 1.2 and 1.3, set the value to
VersionTLS11
. The highest valid value forminTLSVersion
isVersionTLS12
.tlsSecurityProfile.intermediate
This TLS profile can be used for a majority of services. Intermediate compatibility (recommended).
tlsSecurityProfile.old
Used for backward compatibility. Old backward compatibility.
tlsSecurityProfile.type
Valid values are
Intermediate
,Old
, orCustom
. TheModern
value is not supported.tuningOptions
Specifies options for tuning the performance of ingress controller pods.
tuningOptions.clientFinTimeout
Specifies how long a connection is held open while waiting for the client response to the server closing the connection. The default timeout is
1s
.tuningOptions.clientTimeout
Specifies how long a connection is held open while waiting for a client response. The default timeout is
30s
.tuningOptions.headerBufferBytes
Specifies how much memory is reserved, in bytes, for ingress controller connection sessions. This value must be at least
16384
if HTTP/2 is enabled for the ingress controller. If not set, the default value is32768
bytes.ImportantSetting this field not recommended because
headerBufferMaxRewriteBytes
parameter values that are too small can break the ingress controller. Conversely, values forheaderBufferMaxRewriteBytes
that are too large could cause the ingress controller to use significantly more memory than necessary.tuningOptions.headerBufferMaxRewriteBytes
Specifies how much memory should be reserved, in bytes, from
headerBufferBytes
for HTTP header rewriting and appending for ingress controller connection sessions. The minimum value forheaderBufferMaxRewriteBytes
is4096
.headerBufferBytes
must be greater than theheaderBufferMaxRewriteBytes
value for incoming HTTP requests. If not set, the default value is8192
bytes.ImportantSetting this field is not recommended because
headerBufferMaxRewriteBytes
values that are too small can break the ingress controller andheaderBufferMaxRewriteBytes
that are too large could cause the ingress controller to use significantly more memory than necessary.tuningOptions.healthCheckInterval
Specifies how long the router waits between health checks, set in seconds. The default is
5s
.tuningOptions.maxConnections
Specifies the maximum number of simultaneous connections that can be established for each
HAProxy
process. Increasing this value allows each ingress controller pod to handle more connections at the cost of additional system resources. Permitted values are0
,-1
, any value within the range2000
and2000000
, or the field can be left empty.-
If this field is left empty or has the value
0
, the ingress controller uses the default value of50000
. -
If the field has the value of
-1
, then theHAProxy
process dynamically computes a maximum value based on the availableulimits
in the running container. This process results in a large computed value that incurs significant memory usage compared to the current default value of50000
. -
If the field has a value that is greater than the current operating system limit, the
HAProxy
processes do not start. -
If you choose a discrete value and the router pod is migrated to a new node, it is possible that the new node does not have an identical
ulimit
configured. In such cases, the pod fails to start. -
If you have nodes with different
ulimits
configured, and you choose a discrete value, you can use the value of-1
for this field so that the maximum number of connections is calculated at runtime. -
You can monitor memory usage for router containers with the
container_memory_working_set_bytes{container="router",namespace="openshift-ingress"}
metric. -
You can monitor memory usage of individual
HAProxy
processes in router containers with thecontainer_memory_working_set_bytes{container="router",namespace="openshift-ingress"}/container_processes{container="router",namespace="openshift-ingress"}
metric.
tuningOptions.serverFinTimeout
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 is
1s
.tuningOptions.serverTimeout
Specifies how long a connection is held open while waiting for a server response. The default timeout is
30s
.tuningOptions.threadCount
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. TheHAProxy
load balancer supports up to64
threads. If this field is empty, the ingress controller uses the default value of4
threads.ImportantSetting this field is not recommended because increasing the number of
HAProxy
threads allows ingress controller pods to use more CPU time under load, and prevent other pods from receiving the CPU resources they need to perform. Reducing the number of threads can cause the ingress controller to perform poorly.tuningOptions.tlsInspectDelay
Specifies how long the router can hold data to find a matching route. Setting this value too low 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 is
5s
.tuningOptions.tunnelTimeout
Specifies how long a tunnel connection, including websockets, remains open while the tunnel is idle. The default timeout is
1h
.-
When the
Complete any other configurations you require, then start or restart MicroShift by running one the following commands:
sudo systemctl start microshift
$ sudo systemctl start microshift
Copy to Clipboard Copied! sudo systemctl restart microshift
$ sudo systemctl restart microshift
Copy to Clipboard Copied!
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-ingress
Copy to Clipboard Copied! 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 6m10s
Copy to Clipboard Copied!
3.2.1. Creating a secret for the ingress controller certificateSecret
Use this procedure to create a secret that is referenced by the certificateSecret
parameter value in the MicroShift configuration file. This secret contains the default certificate served by the ingress controller.
Any in-use certificates is automatically integrated with the MicroShift built-in OAuth server.
Prerequisites
- You have root access to MicroShift.
-
You installed the OpenShift CLI (
oc
). - Your private key is not encrypted or you have decrypted it for importing into MicroShift.
Procedure
Create a secret that contains the wildcard certificate chain and key:
oc create secret tls <secret>
$ oc create secret tls <secret>
1 --cert=</path/to/cert.crt>
2 --key=</path/to/cert.key>
3 -n openshift-ingress
Copy to Clipboard Copied! ImportantThe certificate must include the
subjectAltName
extension showing*.apps.<clustername>.<domain>
.-
Update the
certificateSecret
parameter value in the MicroShift configuration YAML with the newly created secret. Complete any other configurations you require, then start or restart MicroShift by running one the following commands:
sudo systemctl start microshift
$ sudo systemctl start microshift
Copy to Clipboard Copied! sudo systemctl restart microshift
$ sudo systemctl restart microshift
Copy to Clipboard Copied!
3.2.2. Configuring the TLS security profile for the ingress controller
You can configure the TLS security profile for the ingress controller to use by setting the type in MicroShift configuration YAML.
Prerequisites
- You have root access to the MicroShift cluster.
Procedure
Add the
spec.tlsSecurityProfile
field to the MicroShift YAML configuration file.... spec: tlsSecurityProfile: type: Custom custom: ciphers: - ECDHE-ECDSA-CHACHA20-POLY1305 - ECDHE-RSA-CHACHA20-POLY1305 - ECDHE-RSA-AES128-GCM-SHA256 - ECDHE-ECDSA-AES128-GCM-SHA256 minTLSVersion: VersionTLS11 ...
... spec: tlsSecurityProfile: type: Custom
1 custom:
2 ciphers:
3 - ECDHE-ECDSA-CHACHA20-POLY1305 - ECDHE-RSA-CHACHA20-POLY1305 - ECDHE-RSA-AES128-GCM-SHA256 - ECDHE-ECDSA-AES128-GCM-SHA256 minTLSVersion: VersionTLS11 ...
Copy to Clipboard Copied! - 1
- Specify the TLS security profile type (
Old
,Intermediate
, orCustom
). The default isIntermediate
. - 2
- Specify the appropriate field for the selected type:
-
old: {}
-
intermediate: {}
-
custom:
-
- 3
- For the
custom
type, specify a list of TLS ciphers and minimum accepted TLS version.WarningIf you choose a
custom
TLS configuration, use extreme caution. Using self-signed TLS certificates can introduce security risks.
- Save the file to apply the changes.
Restart MicroShift by running the following command:
sudo systemctl restart microshift
$ sudo systemctl restart microshift
Copy to Clipboard Copied!