1
0
mirror of https://github.com/openshift/openshift-docs.git synced 2026-02-07 09:46:53 +01:00
Files
openshift-docs/modules/creating-instance-aws-load-balancer-controller.adoc

158 lines
4.5 KiB
Plaintext
Raw Normal View History

2022-05-09 13:46:05 +05:30
// Module included in the following assemblies:
//
// * networking/aws_load_balancer_operator/create-instance-aws-load-balancer-controller.adoc
:_mod-docs-content-type: PROCEDURE
2022-05-09 13:46:05 +05:30
[id="nw-creating-instance-aws-load-balancer-controller_{context}"]
= Creating the AWS Load Balancer Controller
2022-05-09 13:46:05 +05:30
You can install only a single instance of the `AWSLoadBalancerController` object in a cluster. You can create the AWS Load Balancer Controller by using CLI. The AWS Load Balancer Operator reconciles only the `cluster` named resource.
2022-05-09 13:46:05 +05:30
.Prerequisites
* You have created the `echoserver` namespace.
* You have access to the OpenShift CLI (`oc`).
.Procedure
. Create a YAML file that defines the `AWSLoadBalancerController` object:
2022-05-09 13:46:05 +05:30
+
.Example `sample-aws-lb.yaml` file
2022-05-09 13:46:05 +05:30
[source,yaml]
----
apiVersion: networking.olm.openshift.io/v1
2022-05-09 13:46:05 +05:30
kind: AWSLoadBalancerController <1>
metadata:
name: cluster <2>
spec:
subnetTagging: Auto <3>
additionalResourceTags: <4>
- key: example.org/security-scope
value: staging
ingressClass: alb <5>
2022-05-09 13:46:05 +05:30
config:
replicas: 2 <6>
enabledAddons: <7>
- AWSWAFv2 <8>
----
<1> Defines the `AWSLoadBalancerController` object.
<2> Defines the AWS Load Balancer Controller name. This instance name gets added as a suffix to all related resources.
<3> Configures the subnet tagging method for the AWS Load Balancer Controller. The following values are valid:
* `Auto`: The AWS Load Balancer Operator determines the subnets that belong to the cluster and tags them appropriately. The Operator cannot determine the role correctly if the internal subnet tags are not present on internal subnet.
* `Manual`: You manually tag the subnets that belong to the cluster with the appropriate role tags. Use this option if you installed your cluster on user-provided infrastructure.
<4> Defines the tags used by the AWS Load Balancer Controller when it provisions AWS resources.
<5> Defines the ingress class name. The default value is `alb`.
<6> Specifies the number of replicas of the AWS Load Balancer Controller.
<7> Specifies annotations as an add-on for the AWS Load Balancer Controller.
2022-05-09 13:46:05 +05:30
<8> Enables the `alb.ingress.kubernetes.io/wafv2-acl-arn` annotation.
. Create the `AWSLoadBalancerController` object by running the following command:
2022-05-09 13:46:05 +05:30
+
[source,terminal]
----
$ oc create -f sample-aws-lb.yaml
----
. Create a YAML file that defines the `Deployment` resource:
2022-05-09 13:46:05 +05:30
+
.Example `sample-aws-lb.yaml` file
2022-05-09 13:46:05 +05:30
[source,yaml]
----
apiVersion: apps/v1
kind: Deployment <1>
metadata:
name: <echoserver> <2>
namespace: echoserver
spec:
selector:
matchLabels:
app: echoserver
replicas: 3 <3>
template:
metadata:
labels:
app: echoserver
spec:
containers:
- image: openshift/origin-node
2023-01-13 17:41:22 +05:30
command:
- "/bin/socat"
2022-05-09 13:46:05 +05:30
args:
- TCP4-LISTEN:8080,reuseaddr,fork
- EXEC:'/bin/bash -c \"printf \\\"HTTP/1.0 200 OK\r\n\r\n\\\"; sed -e \\\"/^\r/q\\\"\"'
imagePullPolicy: Always
name: echoserver
ports:
- containerPort: 8080
----
<1> Defines the deployment resource.
<2> Specifies the deployment name.
<3> Specifies the number of replicas of the deployment.
. Create a YAML file that defines the `Service` resource:
2022-05-09 13:46:05 +05:30
+
.Example `service-albo.yaml` file:
2022-05-09 13:46:05 +05:30
[source,yaml]
----
apiVersion: v1
kind: Service <1>
metadata:
name: <echoserver> <2>
namespace: echoserver
spec:
ports:
- port: 80
targetPort: 8080
protocol: TCP
type: NodePort
selector:
app: echoserver
----
<1> Defines the service resource.
<2> Specifies the service name.
2022-05-09 13:46:05 +05:30
. Create a YAML file that defines the `Ingress` resource:
2022-05-09 13:46:05 +05:30
+
.Example `ingress-albo.yaml` file:
2022-05-09 13:46:05 +05:30
[source,yaml]
----
apiVersion: networking.k8s.io/v1
kind: Ingress
2022-05-09 13:46:05 +05:30
metadata:
name: <name> <1>
2022-05-09 13:46:05 +05:30
namespace: echoserver
annotations:
alb.ingress.kubernetes.io/scheme: internet-facing
alb.ingress.kubernetes.io/target-type: instance
spec:
ingressClassName: alb
rules:
- http:
paths:
- path: /
pathType: Exact
backend:
service:
name: <echoserver> <2>
2022-05-09 13:46:05 +05:30
port:
number: 80
----
<1> Specify a name for the `Ingress` resource.
<2> Specifies the service name.
2022-05-09 13:46:05 +05:30
.Verification
* Save the status of the `Ingress` resource in the `HOST` variable by running the following command:
2022-05-09 13:46:05 +05:30
+
[source,terminal]
----
2023-01-13 17:41:22 +05:30
$ HOST=$(oc get ingress -n echoserver echoserver --template='{{(index .status.loadBalancer.ingress 0).hostname}}')
2022-05-09 13:46:05 +05:30
----
* Verify the status of the `Ingress` resource by running the following command:
2022-05-09 13:46:05 +05:30
+
[source,terminal]
----
$ curl $HOST
----