This is a cache of https://docs.openshift.com/container-platform/4.5/networking/enable-cluster-wide-proxy.html. It is a snapshot of the page at 2024-11-15T23:57:41.455+0000.
Configuring the cluster-wide <strong>proxy</strong> | Networking | OpenShift Container Platform 4.5
×

Production environments can deny direct access to the Internet and instead have an HTTP or HTTPS proxy available. You can configure OpenShift Container Platform to use a proxy by modifying the proxy object for existing clusters or by configuring the proxy settings in the install-config.yaml file for new clusters.

The cluster-wide proxy is only supported if you used a user-provisioned infrastructure installation or provide your own networking, such as a virtual private cloud or virual network, for a supported provider.

Prerequisites

  • Review the sites that your cluster requires access to and determine whether any of them must bypass the proxy. By default, all cluster system egress traffic is proxied, including calls to the cloud provider API for the cloud that hosts your cluster. System-wide proxy affects system components only, not user workloads. Add sites to the proxy object’s spec.noproxy field to bypass the proxy if necessary.

    The proxy object status.noproxy field is populated with the values of the networking.machineNetwork[].cidr, networking.clusterNetwork[].cidr, and networking.serviceNetwork[] fields from your installation configuration.

    For installations on Amazon Web Services (AWS), Google Cloud Platform (GCP), Microsoft Azure, and Red Hat OpenStack Platform (RHOSP), the proxy object status.noproxy field is also populated with the instance metadata endpoint (169.254.169.254).

Enabling the cluster-wide proxy

The proxy object is used to manage the cluster-wide egress proxy. When a cluster is installed or upgraded without the proxy configured, a proxy object is still generated but it will have a nil spec. For example:

apiVersion: config.openshift.io/v1
kind: proxy
metadata:
  name: cluster
spec:
  trustedCA:
    name: ""
status:

A cluster administrator can configure the proxy for OpenShift Container Platform by modifying this cluster proxy object.

Only the proxy object named cluster is supported, and no additional proxies can be created.

Prerequisites
  • Cluster administrator permissions

  • OpenShift Container Platform oc CLI tool installed

Procedure
  1. Create a ConfigMap that contains any additional CA certificates required for proxying HTTPS connections.

    You can skip this step if the proxy’s identity certificate is signed by an authority from the RHCOS trust bundle.

    1. Create a file called user-ca-bundle.yaml with the following contents, and provide the values of your PEM-encoded certificates:

      apiVersion: v1
      data:
        ca-bundle.crt: | (1)
          <MY_PEM_ENCODED_CERTS> (2)
      kind: ConfigMap
      metadata:
        name: user-ca-bundle (3)
        namespace: openshift-config (4)
      1 This data key must be named ca-bundle.crt.
      2 One or more PEM-encoded X.509 certificates used to sign the proxy’s identity certificate.
      3 The ConfigMap name that will be referenced from the proxy object.
      4 The ConfigMap must be in the openshift-config namespace.
    2. Create the ConfigMap from this file:

      $ oc create -f user-ca-bundle.yaml
  2. Use the oc edit command to modify the proxy object:

    $ oc edit proxy/cluster
  3. Configure the necessary fields for the proxy:

    apiVersion: config.openshift.io/v1
    kind: proxy
    metadata:
      name: cluster
    spec:
      httpproxy: http://<username>:<pswd>@<ip>:<port> (1)
      httpsproxy: http://<username>:<pswd>@<ip>:<port> (2)
      noproxy: example.com (3)
      readinessEndpoints:
      - http://www.google.com (4)
      - https://www.google.com
      trustedCA:
        name: user-ca-bundle (5)
    1 A proxy URL to use for creating HTTP connections outside the cluster. The URL scheme must be http.
    2 A proxy URL to use for creating HTTPS connections outside the cluster. If this is not specified, then httpproxy is used for both HTTP and HTTPS connections.
    3 A comma-separated list of destination domain names, domains, IP addresses or other network CIDRs to exclude proxying.

    Preface a domain with . to match subdomains only. For example, .y.com matches x.y.com, but not y.com. Use * to bypass proxy for all destinations. If you scale up workers that are not included in the network defined by the networking.machineNetwork[].cidr field from the installation configuration, you must add them to this list to prevent connection issues.

    This field is ignored if neither the httpproxy or httpsproxy fields are set.

    4 One or more URLs external to the cluster to use to perform a readiness check before writing the httpproxy and httpsproxy values to status.
    5 A reference to the ConfigMap in the openshift-config namespace that contains additional CA certificates required for proxying HTTPS connections. Note that the ConfigMap must already exist before referencing it here. This field is required unless the proxy’s identity certificate is signed by an authority from the RHCOS trust bundle.
  4. Save the file to apply the changes.

The URL scheme must be http. The https scheme is currently not supported.

Removing the cluster-wide proxy

The cluster proxy object cannot be deleted. To remove the proxy from a cluster, remove all spec fields from the proxy object.

Prerequisites
  • Cluster administrator permissions

  • OpenShift Container Platform oc CLI tool installed

Procedure
  1. Use the oc edit command to modify the proxy:

    $ oc edit proxy/cluster
  2. Remove all spec fields from the proxy object. For example:

    apiVersion: config.openshift.io/v1
    kind: proxy
    metadata:
      name: cluster
    spec: {}
    status: {}
  3. Save the file to apply the changes.