This is a cache of https://docs.openshift.com/container-platform/4.3/networking/ingress-operator.html. It is a snapshot of the page at 2024-11-21T01:32:48.950+0000.
Understanding the <strong>ingress</strong> Operator | Networking | OpenShift Container Platform 4.3
×

The ingress configuration asset

The installation program generates an asset with an ingress resource in the config.openshift.io API group, cluster-ingress-02-config.yml.

YAML Definition of the ingress resource
apiVersion: config.openshift.io/v1
kind: ingress
metadata:
  name: cluster
spec:
  domain: apps.openshiftdemos.com

The installation program stores this asset in the cluster-ingress-02-config.yml file in the manifests/ directory. This ingress resource defines the cluster-wide configuration for ingress. This ingress configuration is used as follows:

  • The ingress Operator uses the domain from the cluster ingress configuration as the domain for the default ingress Controller.

  • The OpenShift API server operator uses the domain from the cluster ingress configuration as the domain used when generating a default host for a Route resource that does not specify an explicit host.

ingress controller configuration parameters

The ingresscontrollers.operator.openshift.io resource offers the following configuration parameters.

Parameter Description

domain

domain is a DNS name serviced by the ingress controller and is used to configure multiple features:

  • For the LoadBalancerService endpoint publishing strategy, domain is used to configure DNS records. See endpointPublishingStrategy.

  • When using a generated default certificate, the certificate is valid for domain and its subdomains. See defaultCertificate.

  • The value is published to individual Route statuses so that users know where to target external DNS records.

The domain value must be unique among all ingress controllers and cannot be updated.

If empty, the default value is ingress.config.openshift.io/cluster .spec.domain.

replicas

replicas is the desired number of ingress controller replicas. If not set, the default value is 2.

endpointPublishingStrategy

endpointPublishingStrategy is used to publish the ingress controller endpoints to other networks, enable load balancer integrations, and provide access to other systems.

If not set, the default value is based on infrastructure.config.openshift.io/cluster .status.platform:

  • AWS: LoadBalancerService (with external scope)

  • Azure: LoadBalancerService (with external scope)

  • GCP: LoadBalancerService (with external scope)

  • Other: HostNetwork.

The endpointPublishingStrategy value cannot be updated.

defaultCertificate

The defaultCertificate value is a reference to a secret that contains the default certificate that is served by the ingress controller. When Routes do not specify their own certificate, defaultCertificate is used.

The secret must contain the following keys and data: * tls.crt: certificate file contents * tls.key: key file contents

If not set, a wildcard certificate is automatically generated and used. The certificate is valid for the ingress controller domain and subdomains, and the generated certificate’s CA is automatically integrated with the cluster’s trust store.

The in-use certificate, whether generated or user-specified, is automatically integrated with OpenShift Container Platform built-in OAuth server.

namespaceSelector

namespaceSelector is used to filter the set of namespaces serviced by the ingress controller. This is useful for implementing shards.

routeSelector

routeSelector is used to filter the set of Routes serviced by the ingress controller. This is useful for implementing shards.

nodePlacement

nodePlacement enables explicit control over the scheduling of the ingress controller.

If not set, the defaults values are used.

The nodePlacement parameter includes two parts, nodeSelector and tolerations. For example:

nodePlacement:
 nodeSelector:
   matchLabels:
     beta.kubernetes.io/os: linux
 tolerations:
 - effect: NoSchedule
   operator: Exists

tlsSecurityProfile

tlsSecurityProfile specifies settings for TLS connections for ingress controllers.

If not set, the default value is based on the apiservers.config.openshift.io/cluster resource.

When using the Old, Intermediate, and Modern profile types, the effective profile configuration is subject to change between releases. For example, given a specification to use the Intermediate profile deployed on release X.Y.Z, an upgrade to release X.Y.Z+1 may cause a new profile configuration to be applied to the ingress controller, resulting in a rollout.

The minimum TLS version for ingress controllers is 1.1, and the maximum TLS version is 1.2.

The HAProxy ingress controller image does not support TLS 1.3 and because the Modern profile requires TLS 1.3, it is not supported. The ingress Operator converts the Modern profile to Intermediate.

The ingress Operator also converts the TLS 1.0 of an Old or Custom profile to 1.1, and TLS 1.3 of a Custom profile to 1.2.

Ciphers and the minimum TLS version of the configured security profile are reflected in the TLSProfile status.

All parameters are optional.

ingress controller TLS profiles

The tlsSecurityProfile parameter defines the schema for a TLS security profile. This object is used by operators to apply TLS security settings to operands.

There are four TLS security profile types:

  • Old

  • Intermediate

  • Modern

  • Custom

The Old, Intermediate, and Modern profiles are based on recommended configurations. The Custom profile provides the ability to specify individual TLS security profile parameters.

Sample Old profile configuration
spec:
  tlsSecurityProfile:
    type: Old
Sample Intermediate profile configuration
spec:
  tlsSecurityProfile:
    type: Intermediate
Sample Modern profile configuration
spec:
  tlsSecurityProfile:
    type: Modern

The Custom profile is a user-defined TLS security profile.

You must be careful using a Custom profile, because invalid configurations can cause problems.

Sample Custom profile
spec:
  tlsSecurityProfile:
    type: Custom
    custom:
      ciphers:
        - ECDHE-ECDSA-AES128-GCM-SHA256
        - ECDHE-RSA-AES128-GCM-SHA256
      minTLSVersion: VersionTLS11

ingress controller endpoint publishing strategy

An ingress controller with the HostNetwork endpoint publishing strategy can have only one Pod replica per node. If you want n replicas, you must use at least n nodes where those replicas can be scheduled. Because each Pod replica requests ports 80 and 443 on the node host where it is scheduled, a replica cannot be scheduled to a node if another Pod on the same node is using those ports.

View the default ingress Controller

The ingress Operator is a core feature of OpenShift Container Platform and is enabled out of the box.

Every new OpenShift Container Platform installation has an ingresscontroller named default. It can be supplemented with additional ingress Controllers. If the default ingresscontroller is deleted, the ingress Operator will automatically recreate it within a minute.

Procedure
  • View the default ingress Controller:

    $ oc describe --namespace=openshift-ingress-operator ingresscontroller/default

View ingress Operator status

You can view and inspect the status of your ingress Operator.

Procedure
  • View your ingress Operator status:

    $ oc describe clusteroperators/ingress

View ingress Controller logs

You can view your ingress Controller logs.

Procedure
  • View your ingress Controller logs:

    $ oc logs --namespace=openshift-ingress-operator deployments/ingress-operator

View ingress Controller status

Your can view the status of a particular ingress Controller.

Procedure
  • View the status of an ingress Controller:

    $ oc describe --namespace=openshift-ingress-operator ingresscontroller/<name>

Setting a custom default certificate

As an administrator, you can configure an ingress Controller to use a custom certificate by creating a Secret resource and editing the ingressController custom resource (CR).

Prerequisites
  • You must have a certificate/key pair in PEM-encoded files, where the certificate is signed by a trusted certificate authority or by a private trusted certificate authority that you configured in a custom PKI.

  • Your certificate is valid for the ingress domain.

  • You must have an ingressController CR. You may use the default one:

    $ oc --namespace openshift-ingress-operator get ingresscontrollers
    Example output
    NAME      AGE
    default   10m

If you have intermediate certificates, they must be included in the tls.crt file of the secret containing a custom default certificate. Order matters when specifying a certificate; list your intermediate certificate(s) after any server certificate(s).

Procedure

The following assumes that the custom certificate and key pair are in the tls.crt and tls.key files in the current working directory. Substitute the actual path names for tls.crt and tls.key. You also may substitute another name for custom-certs-default when creating the Secret resource and referencing it in the ingressController CR.

This action will cause the ingress Controller to be redeployed, using a rolling deployment strategy.

  1. Create a Secret resource containing the custom certificate in the openshift-ingress namespace using the tls.crt and tls.key files.

    $ oc --namespace openshift-ingress create secret tls custom-certs-default --cert=tls.crt --key=tls.key
  2. Update the ingressController CR to reference the new certificate secret:

    $ oc patch --type=merge --namespace openshift-ingress-operator ingresscontrollers/default \
      --patch '{"spec":{"defaultCertificate":{"name":"custom-certs-default"}}}'
  3. Verify the update was effective:

    $ oc get --namespace openshift-ingress-operator ingresscontrollers/default \
      --output jsonpath='{.spec.defaultCertificate}'
    Example output
    map[name:custom-certs-default]

    The certificate secret name should match the value used to update the CR.

Once the ingressController CR has been modified, the ingress Operator updates the ingress Controller’s deployment to use the custom certificate.

Scaling an ingress Controller

Manually scale an ingress Controller to meeting routing performance or availability requirements such as the requirement to increase throughput. oc commands are used to scale the ingressController resource. The following procedure provides an example for scaling up the default ingressController.

Procedure
  1. View the current number of available replicas for the default ingressController:

    $ oc get -n openshift-ingress-operator ingresscontrollers/default -o jsonpath='{$.status.availableReplicas}'
    Example output
    2
  2. Scale the default ingressController to the desired number of replicas using the oc patch command. The following example scales the default ingressController to 3 replicas:

    $ oc patch -n openshift-ingress-operator ingresscontroller/default --patch '{"spec":{"replicas": 3}}' --type=merge
    Example output
    ingresscontroller.operator.openshift.io/default patched
  3. Verify that the default ingressController scaled to the number of replicas that you specified:

    $ oc get -n openshift-ingress-operator ingresscontrollers/default -o jsonpath='{$.status.availableReplicas}'
    Example output
    3

Scaling is not an immediate action, as it takes time to create the desired number of replicas.

Configuring ingress Controller sharding by using route labels

ingress Controller sharding by using route labels means that the ingress Controller serves any route in any namespace that is selected by the route selector.

ingress Controller sharding is useful when balancing incoming traffic load among a set of ingress Controllers and when isolating traffic to a specific ingress Controller. For example, company A goes to one ingress Controller and company B to another.

Procedure
  1. Edit the router-internal.yaml file:

    # cat router-internal.yaml
    apiVersion: v1
    items:
    - apiVersion: operator.openshift.io/v1
      kind: ingressController
      metadata:
        name: sharded
        namespace: openshift-ingress-operator
      spec:
        domain: <apps-sharded.basedomain.example.net>
        nodePlacement:
          nodeSelector:
            matchLabels:
              node-role.kubernetes.io/worker: ""
        routeSelector:
          matchLabels:
            type: sharded
      status: {}
    kind: List
    metadata:
      resourceVersion: ""
      selfLink: ""
  2. Apply the ingress Controller router-internal.yaml file:

    # oc apply -f router-internal.yaml

    The ingress Controller selects routes in any namespace that have the label type: sharded.

Configuring ingress Controller sharding by using namespace labels

ingress Controller sharding by using namespace labels means that the ingress Controller serves any route in any namespace that is selected by the namespace selector.

ingress Controller sharding is useful when balancing incoming traffic load among a set of ingress Controllers and when isolating traffic to a specific ingress Controller. For example, company A goes to one ingress Controller and company B to another.

Procedure
  1. Edit the router-internal.yaml file:

    # cat router-internal.yaml
    Example output
    apiVersion: v1
    items:
    - apiVersion: operator.openshift.io/v1
      kind: ingressController
      metadata:
        name: sharded
        namespace: openshift-ingress-operator
      spec:
        domain: <apps-sharded.basedomain.example.net>
        nodePlacement:
          nodeSelector:
            matchLabels:
              node-role.kubernetes.io/worker: ""
        namespaceSelector:
          matchLabels:
            type: sharded
      status: {}
    kind: List
    metadata:
      resourceVersion: ""
      selfLink: ""
  2. Apply the ingress Controller router-internal.yaml file:

    # oc apply -f router-internal.yaml

    The ingress Controller selects routes in any namespace that is selected by the namespace selector that have the label type: sharded.

Configuring an ingress Controller to use an internal load balancer

When creating an ingress Controller on cloud platforms, the ingress Controller is published by a public cloud load balancer by default. As an administrator, you can create an ingress Controller that uses an internal cloud load balancer.

If your cloud provider is Microsoft Azure, you must have at least one public load balancer that points to your nodes. If you do not, all of your nodes will lose egress connectivity to the internet.

If you want to change the scope for an ingressController object, you must delete and then recreate that ingressController object. You cannot change the .spec.endpointPublishingStrategy.loadBalancer.scope parameter after the Custom Resource (CR) is created.

See the Kubernetes Services documentation for implementation details.

Prerequisites
  • Install the OpenShift CLI (oc).

  • Log in as a user with cluster-admin privileges.

Procedure
  1. Create an ingressController Custom Resource (CR) in a file named <name>-ingress-controller.yaml, such as in the following example:

    apiVersion: operator.openshift.io/v1
    kind: ingressController
    metadata:
      namespace: openshift-ingress-operator
      name: <name> (1)
    spec:
      domain: <domain> (2)
      endpointPublishingStrategy:
        type: LoadBalancerService
        loadBalancer:
          scope: Internal (3)
    1 Replace <name> with a name for the ingressController object.
    2 Specify the domain for the application published by the controller.
    3 Specify a value of Internal to use an internal load balancer.
  2. Create the ingress Controller defined in the previous step by running the following command:

    $ oc create -f <name>-ingress-controller.yaml (1)
    1 Replace <name> with the name of the ingressController object.
  3. Optional: Confirm that the ingress Controller was created by running the following command:

    $ oc --all-namespaces=true get ingresscontrollers

Configuring the default ingress Controller for your cluster to be internal

You can configure the default ingress Controller for your cluster to be internal by deleting and recreating it.

If your cloud provider is Microsoft Azure, you must have at least one public load balancer that points to your nodes. If you do not, all of your nodes will lose egress connectivity to the internet.

If you want to change the scope for an ingressController object, you must delete and then recreate that ingressController object. You cannot change the .spec.endpointPublishingStrategy.loadBalancer.scope parameter after the Custom Resource (CR) is created.

Prerequisites
  • Install the OpenShift CLI (oc).

  • Log in as a user with cluster-admin privileges.

Procedure
  1. Configure the default ingress Controller for your cluster to be internal by deleting and recreating it.

    $ oc replace --force --wait --filename - <<EOF
    apiVersion: operator.openshift.io/v1
    kind: ingressController
    metadata:
      namespace: openshift-ingress-operator
      name: default
    spec:
      endpointPublishingStrategy:
        type: LoadBalancerService
        loadBalancer:
          scope: Internal
    EOF

Additional resources