Handling ingress in a hosted cluster on bare metal
Every OpenShift Container Platform cluster has a default application Ingress Controller that typically has an external DNS record associated with it.
For example, if you create a hosted cluster named example with the base domain krnl.es, you can expect the wildcard domain *.apps.example.krnl.es to be routable.
To set up a load balancer and wildcard DNS record for the *.apps domain, perform the following actions on your hosted cluster.
-
Deploy MetalLB by creating a YAML file that has the configuration for the MetalLB Operator:
apiVersion: v1 kind: Namespace metadata: name: metallb labels: openshift.io/cluster-monitoring: "true" annotations: workload.openshift.io/allowed: management --- apiVersion: operators.coreos.com/v1 kind: OperatorGroup metadata: name: metallb-operator-operatorgroup namespace: metallb --- apiVersion: operators.coreos.com/v1alpha1 kind: Subscription metadata: name: metallb-operator namespace: metallb spec: channel: "stable" name: metallb-operator source: redhat-operators sourceNamespace: openshift-marketplace -
Save the file as
metallb-operator-config.yaml. -
Enter the following command to apply the configuration:
$ oc apply -f metallb-operator-config.yaml -
After the Operator is running, create the MetalLB instance:
-
Create a YAML file that has the configuration for the MetalLB instance:
apiVersion: metallb.io/v1beta1 kind: MetalLB metadata: name: metallb namespace: metallb -
Save the file as
metallb-instance-config.yaml. -
Create the MetalLB instance by entering this command:
$ oc apply -f metallb-instance-config.yaml
-
-
Create an
IPAddressPoolresource with a single IP address. This IP address must be on the same subnet as the network that the cluster nodes use.-
Create a file, such as
ipaddresspool.yaml, with content similar to the following example:apiVersion: metallb.io/v1beta1 kind: IPAddressPool metadata: namespace: metallb name: <ip_address_pool_name> spec: addresses: - <ingress_ip>-<ingress_ip> autoAssign: false-
metadata.namespecifies theIPAddressPoolresource name. -
spec.addressesspecifies the IP address for your environment. For example,192.168.122.23.
-
-
Apply the configuration for the IP address pool by entering the following command:
$ oc apply -f ipaddresspool.yaml
-
-
Create a L2 advertisement.
-
Create a file, such as
l2advertisement.yaml, with content similar to the following example:apiVersion: metallb.io/v1beta1 kind: L2Advertisement metadata: name: <l2_advertisement_name> namespace: metallb spec: ipAddressPools: - <ip_address_pool_name>-
metadata.namespecifies theL2Advertisementresource name. -
spec.ipAddressPoolsspecifies theIPAddressPoolresource name.
-
-
Apply the configuration by entering the following command:
$ oc apply -f l2advertisement.yaml
-
-
After creating a service of the
LoadBalancertype, MetalLB adds an external IP address for the service.-
Configure a new load balancer service that routes ingress traffic to the ingress deployment by creating a YAML file named
metallb-loadbalancer-service.yaml:kind: Service apiVersion: v1 metadata: annotations: metallb.io/address-pool: ingress-public-ip name: metallb-ingress namespace: openshift-ingress spec: ports: - name: http protocol: TCP port: 80 targetPort: 80 - name: https protocol: TCP port: 443 targetPort: 443 selector: ingresscontroller.operator.openshift.io/deployment-ingresscontroller: default type: LoadBalancer -
Save the
metallb-loadbalancer-service.yamlfile. -
Enter the following command to apply the YAML configuration:
$ oc apply -f metallb-loadbalancer-service.yaml -
Enter the following command to reach the OpenShift Container Platform console:
$ curl -kI https://console-openshift-console.apps.example.krnl.esExample outputHTTP/1.1 200 OK -
Check the
clusterversionandclusteroperatorvalues to verify that everything is running. Enter the following command:$ oc --kubeconfig <hosted_cluster_name>.kubeconfig get clusterversion,coExample outputNAME VERSION AVAILABLE PROGRESSING SINCE STATUS clusterversion.config.openshift.io/version 4.x.y True False 3m32s Cluster version is 4.x.y NAME VERSION AVAILABLE PROGRESSING DEGRADED SINCE MESSAGE clusteroperator.config.openshift.io/console 4.x.y True False False 3m50s clusteroperator.config.openshift.io/ingress 4.x.y True False False 53mReplace
<4.x.y>with the supported OpenShift Container Platform version that you want to use, for example,4.22.0-multi.
-