Dieser Inhalt ist in der von Ihnen ausgewählten Sprache nicht verfügbar.
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 Link kopierenLink in die Zwischenablage kopiert!
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:
- Accommodate server response speed
-
If your application starts processing requests from clients but the connection closes 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 your application starts processing requests from clients but the connection closes before it can respond, you can set the
- Closing router connections
-
If the router has many connections open because an application running on the node does not close connections properly, you can set the
ingress.tuningOptions.serverTimeoutandspec.tuningOptions.serverFinTimeoutparameters to a lower value, forcing those connections to close sooner.
-
If the router has many connections open because an application running on the node does not close connections properly, you can set the
- Verify client certificates
-
If you need to configure the ingress controller to verify client certificates, you can use the
ingress.clientTLSparameter 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 the ingress controller to verify client certificates, you can use the
- Configure a TLS security profile
-
If you need to configure a TLS security profile for an ingress controller, you can use the
ingress.tlsSecurityProfileparameter 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 configure a TLS security profile for an ingress controller, you can use the
- Create policies for new route claims
-
If you need to define a policy for handling new route claims, you can use the
routeAdmissionparameter to allow or deny claims across namespaces. Set therouteAdmissionparameter to describe how hostname claims across namespaces should be handled and to describe how the ingress controller handles routes with wildcard policies.
-
If you need to define a policy for handling new route claims, you can use the
- Customize error pages
- If you want more than the default error pages, which are usually empty and only return the HTTP status code, configure custom error pages.
- Capture HTTP headers or cookies
- If you want to include the capture of HTTP headers or cookies, configure them in the access logging.
5.2. Configuring ingress control in MicroShift Link kopierenLink in die Zwischenablage kopiert!
To apply detailed ingress control such as timeouts, TLS, and logging in MicroShift, you can update the config.yaml file or add a configuration snippet in the /etc/microshift/config.d/ directory. Replace the default values in the ingress section and restart the service.
-
A
config.yamlconfiguration file takes precedence over built-in settings. Theconfig.yamlfile is read every time the MicroShift service starts. -
Configuration snippet YAMLs take precedence over both built-in settings and the
config.yamlconfiguration 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. -
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.
-
Update the MicroShift
Replace the default values in the
ingresssection 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: accessLogging: destination: container: maxLength: 1024 syslog: address: "" facility: "" maxLength: 1024 port: 0 type: "" httpCaptureCookies: - matchType: "" maxLength: 0 name: "" namePrefix: "" httpCaptureHeaders: request: - maxLength: 0 name: "" response: - maxLength: 0 name: "" httpLogFormat: "" status: Disabled certificateSecret: router-certs-custom clientTLS: allowedSubjectPatterns: [] clientCA: name: "" clientCertificatePolicy: "" defaultHTTPVersion: 1 forwardedHeaderPolicy: Append httpCompression: mimeTypes: - "" httpEmptyRequestsPolicy: Respond httpErrorCodePages: name: "" listenAddress: [] logEmptyRequests: Log ports: http: 80 https: 443 routeAdmissionPolicy: namespaceOwnership: InterNamespaceAllowed wildcardPolicy: WildcardsDisallowed status: Managed tlsSecurityProfile: type: custom: ciphers:[] minTLSVersion:"" intermediate: {} old: {} tuningOptions: clientFinTimeout: 1s clientTimeout: 30s headerBufferBytes: 0 headerBufferMaxRewriteBytes: 0 healthCheckInterval: 5s maxConnections: 0 serverFinTimeout: 1s serverTimeout: 30s threadCount: 4 tlsInspectDelay: 5s tunnelTimeout: 1h # ...See "Ingress controller configuration fields in MicroShift" for more information about each field.
Complete any other configurations you require, then start or restart MicroShift by running one the following commands:
$ sudo systemctl start microshift$ sudo systemctl restart microshift
Verification
After making ingress configuration changes and restarting MicroShift, you can check the age of the router pod to ensure that changes are applied.
To check the status of the router pod, run the following command:
$ oc get pods -n openshift-ingressExample output
NAME READY STATUS RESTARTS AGE router-default-8649b5bf65-w29cn 1/1 Running 0 6m10s
5.2.1. Ingress controller configuration fields in MicroShift Link kopierenLink in die Zwischenablage kopiert!
The following table lists and defines the ingress controller configuration parameters in the MicroShift config.yaml file. You use these parameters when you configure access logging, TLS, timeouts, route admission, and other ingress options.
| Parameter | Description |
|---|---|
|
|
The |
|
|
This
|
|
| A destination for logs. The destination for logs can be a local sidecar container or remote. Default value is null. |
|
|
The type of destination for logs. Valid values are
|
|
|
Describes parameters for the |
|
|
Optional configuration. The default value is |
|
|
Describes parameters for the |
|
|
Required configuration when the |
|
|
Optional configuration when the |
|
|
Optional configuration when the |
|
|
Required configuration when the |
|
|
Specifies HTTP cookies that you want to capture in access logs. If the
|
|
|
Specifies whether the field name of the cookie exactly matches the capture cookie setting or is a prefix of the capture cookie setting. Valid values are
|
|
|
Specifies the maximum length of the cookie that is logged, which includes the cookie name, cookie value, and one-character delimiter. If the log entry exceeds this length, the value is truncated in the log message. The ingress controller might impose a separate bound on the total length of HTTP headers in a request. The minimum value is |
|
|
Specifies the exact name used for a cookie name match as set in the |
|
|
Specifies the prefix for a cookie name match as set in the |
|
|
Defines the HTTP headers that should be captured in the access logs. This field is a list and allows capturing request and response headers independently. When this field is empty, headers are not captured. This option only applies to plain text HTTP connections and to secure HTTP connections for which the ingress controller terminates encryption: for example, edge-terminated or reencrypt connections. Headers cannot be captured for TLS |
|
| Specifies which HTTP request headers to capture. When this field is empty, no request headers are captured. |
|
|
Specifies a maximum length for the header value. When a header value exceeds this length, the value is truncated in the log message. The minimum required value is |
|
|
Specifies a header name. The value must be a valid HTTP header name as defined in RFC 2616 section 4.2. If you configure this value, you must specify |
|
| Specifies which HTTP response headers to capture. If this field is empty, no response headers are captured. |
|
| Specifies a maximum length for the header value. If a header value exceeds this length, the value is truncated in the log message. The ingress controller might impose a separate bound on the total length of HTTP headers in a request. |
|
| Specifies a header name. The value must be a valid HTTP header name as defined in RFC 2616 section 4.2. |
|
| Specifies the format of the log message for an HTTP request. If this field is empty, log messages use the default HTTP log format. For HAProxy default HTTP log format, see the HAProxy documentation. |
|
|
Specifies whether access is logged or not. Valid values are
|
|
|
A reference to a
|
|
|
Authenticates client access to the node and services. As a result, mutual TLS authentication is enabled. If this parameter is not set, then client TLS is not enabled. You must set the |
|
|
Optional subfield that specifies a list of regular expressions that are matched against the distinguished name on a valid client certificate to filter requests. This parameter is useful when you have client authentication. 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. You must set the Important When 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. |
|
|
Specifies a required config map that is in the |
|
|
The |
|
|
|
|
|
Sets the HTTP version for the ingress controller. The default value is |
|
|
Specifies when and how the ingress controller sets the
|
|
| Defines the policy for HTTP traffic compression. |
|
| Defines a list of MIME types to which compression should be applied.
|
|
|
Describes how HTTP connections are handled if the connection times out before a request is received. Allowed values for this field are
|
|
|
Specifies connections for which no request is received and logged.
|
|
|
Describes custom error code pages. To use this setting, you must configure the |
|
|
Specifies custom error code pages. You can only customize errors for |
|
| Defines default router ports. |
|
|
Default router http port. Must be in range 1-65535. Default value is |
|
|
Default router https port. Must be in range 1-65535. Default value is |
|
| Defines a policy for handling new route claims, such as allowing or denying claims across namespaces. |
|
|
Describes how hostname claims across namespaces are handled. The default is
|
|
|
Controls how the ingress controller handles routes with configured wildcard policies.
Important
Changing the wildcard policy from |
|
|
Default router status. |
|
|
Note
The |
|
| User-defined TLS security profile. If you configure this parameter and related parameters, use extreme caution. |
|
| Specifies the cipher algorithms that are negotiated during the TLS handshake. Operators might remove entries their operands do not support. |
|
|
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 |
|
| You can use this TLS profile for a majority of services. Intermediate compatibility (recommended). |
|
| Used for backward compatibility. Old backward compatibility. |
|
|
Valid values are |
|
| Specifies options for tuning the performance of ingress controller pods. |
|
|
Specifies how long the ingress controller holds a connection open while waiting for a client response before the server closes the connection. The default timeout is |
|
|
Specifies how long the ingress controller holds a connection open while waiting for a client response. The default timeout is |
|
|
Specifies how much memory is reserved, in bytes, for ingress controller connection sessions. This value must be at least Important
Setting this field not recommended because |
|
|
Specifies how much memory should be reserved, in bytes, from Important
Setting this field is not recommended because |
|
|
Specifies how long the router waits between health checks, set in seconds. The default is |
|
|
Specifies the maximum number of simultaneous connections that can be established for each
|
|
|
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 |
|
|
Specifies how long a connection is held open while waiting for a server response. The default timeout is |
|
|
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 using more system resources. The HAProxy load balancer supports up to Important
Setting this field is not recommended because increasing the number of |
|
|
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 |
|
|
Specifies how long a tunnel connection, including websockets, remains open while the tunnel is idle. The default timeout is |
5.2.2. Creating a secret for the ingress controller certificateSecret Link kopierenLink in die Zwischenablage kopiert!
To serve a custom default certificate through the ingress controller in MicroShift, you can create a TLS secret containing your certificate chain and private key, then set the certificateSecret value in the configuration file to that secret name.
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> \ --cert=</path/to/cert.crt> \ --key=</path/to/cert.key> \ -n openshift-ingress-
Replace
<secret>with the name of the secret that contains the certificate chain and private key. -
Replace
</path/to/cert.crt>with the path to the certificate chain on your local file system. Replace
</path/to/cert.key>with the path to the private key associated with this certificate.ImportantThe certificate must include the
subjectAltNameextension showing*.apps.<nodename>.<domain>.
-
Replace
-
Update the
certificateSecretparameter 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 restart microshift
5.2.3. Configuring the TLS security profile for the ingress controller Link kopierenLink in die Zwischenablage kopiert!
To configure the TLS security profile for the ingress controller in MicroShift, you can add the spec.tlsSecurityProfile field to the configuration YAML and set a value for the appropriate profile. To apply the changes, restart the service.
Prerequisites
- You have root access to the MicroShift node.
Procedure
Add the
spec.tlsSecurityProfilefield 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 ...where:
spec.tlsSecurityProfile.type-
Specifies the TLS security profile type (
Old,Intermediate, orCustom). The default isIntermediate. spec.tlsSecurityProfile.customSpecifies the appropriate field for the selected type:
-
old: {} -
intermediate: {} -
custom:
-
spec.tlsSecurityProfile.custom.ciphersSpecifies a list of TLS ciphers and minimum accepted TLS version.
WarningIf you choose a
customTLS 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