mirror of
https://github.com/openshift/openshift-docs.git
synced 2026-02-05 12:46:18 +01:00
171 lines
4.8 KiB
Plaintext
171 lines
4.8 KiB
Plaintext
// Module included in the following assemblies:
|
|
//
|
|
// * networking/networking_operators/aws_load_balancer_operator/create-instance-aws-load-balancer-controller.adoc
|
|
|
|
:_mod-docs-content-type: PROCEDURE
|
|
[id="nw-creating-instance-aws-load-balancer-controller_{context}"]
|
|
= Creating the AWS Load Balancer Controller
|
|
|
|
[role="_abstract"]
|
|
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.
|
|
|
|
.Prerequisites
|
|
|
|
* You have created the `echoserver` namespace.
|
|
* You have access to the {oc-first}.
|
|
|
|
.Procedure
|
|
|
|
. Create a YAML file that defines the `AWSLoadBalancerController` object:
|
|
+
|
|
.Example `sample-aws-lb.yaml` file
|
|
[source,yaml]
|
|
----
|
|
apiVersion: networking.olm.openshift.io/v1
|
|
kind: AWSLoadBalancerController
|
|
metadata:
|
|
name: cluster
|
|
spec:
|
|
subnetTagging: Auto
|
|
additionalResourceTags:
|
|
- key: example.org/security-scope
|
|
value: staging
|
|
ingressClass: alb
|
|
config:
|
|
replicas: 2
|
|
enabledAddons:
|
|
- AWSWAFv2
|
|
----
|
|
+
|
|
where:
|
|
+
|
|
`kind`:: Specifies the `AWSLoadBalancerController` object.
|
|
`metadata.name`:: Specifies the AWS Load Balancer Controller name. The Operator adds this instance name as a suffix to all related resources.
|
|
`spec.subnetTagging`:: Specifies 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.
|
|
`spec.additionalResourceTags`:: Specifies the tags used by the AWS Load Balancer Controller when it provisions AWS resources.
|
|
`ingressClass`:: Specifies the ingress class name. The default value is `alb`.
|
|
`config.replicas`:: Specifies the number of replicas of the AWS Load Balancer Controller.
|
|
`enabledAddons`:: Specifies annotations as an add-on for the AWS Load Balancer Controller.
|
|
`AWSWAFv2`:: Specifies that enablement of the `alb.ingress.kubernetes.io/wafv2-acl-arn` annotation.
|
|
|
|
. Create the `AWSLoadBalancerController` object by running the following command:
|
|
+
|
|
[source,terminal]
|
|
----
|
|
$ oc create -f sample-aws-lb.yaml
|
|
----
|
|
|
|
. Create a YAML file that defines the `Deployment` resource:
|
|
+
|
|
.Example `sample-aws-lb.yaml` file
|
|
[source,yaml]
|
|
----
|
|
apiVersion: apps/v1
|
|
kind: Deployment
|
|
metadata:
|
|
name: <echoserver>
|
|
namespace: echoserver
|
|
spec:
|
|
selector:
|
|
matchLabels:
|
|
app: echoserver
|
|
replicas: 3
|
|
template:
|
|
metadata:
|
|
labels:
|
|
app: echoserver
|
|
spec:
|
|
containers:
|
|
- image: openshift/origin-node
|
|
command:
|
|
- "/bin/socat"
|
|
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
|
|
----
|
|
+
|
|
where:
|
|
+
|
|
`kind`:: Specifies the deployment resource.
|
|
`metadata.name`:: Specifies the deployment name.
|
|
`spec.replicas`:: Specifies the number of replicas of the deployment.
|
|
|
|
. Create a YAML file that defines the `Service` resource:
|
|
+
|
|
.Example `service-albo.yaml` file
|
|
[source,yaml]
|
|
----
|
|
apiVersion: v1
|
|
kind: Service
|
|
metadata:
|
|
name: <echoserver>
|
|
namespace: echoserver
|
|
spec:
|
|
ports:
|
|
- port: 80
|
|
targetPort: 8080
|
|
protocol: TCP
|
|
type: NodePort
|
|
selector:
|
|
app: echoserver
|
|
----
|
|
+
|
|
where:
|
|
+
|
|
`apiVersion`:: Specifies the service resource.
|
|
`metadata.name`:: Specifies the service name.
|
|
|
|
. Create a YAML file that defines the `Ingress` resource:
|
|
+
|
|
.Example `ingress-albo.yaml` file
|
|
[source,yaml]
|
|
----
|
|
apiVersion: networking.k8s.io/v1
|
|
kind: Ingress
|
|
metadata:
|
|
name: <name>
|
|
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>
|
|
port:
|
|
number: 80
|
|
----
|
|
+
|
|
where:
|
|
+
|
|
`metadata.name`:: Specifies a name for the `Ingress` resource.
|
|
`service.name`:: Specifies the service name.
|
|
|
|
.Verification
|
|
|
|
* Save the status of the `Ingress` resource in the `HOST` variable by running the following command:
|
|
+
|
|
[source,terminal]
|
|
----
|
|
$ HOST=$(oc get ingress -n echoserver echoserver --template='{{(index .status.loadBalancer.ingress 0).hostname}}')
|
|
----
|
|
|
|
* Verify the status of the `Ingress` resource by running the following command:
|
|
+
|
|
[source,terminal]
|
|
----
|
|
$ curl $HOST
|
|
----
|