From 7dfefe74baa5418ec2507216ff4366e6fc249d96 Mon Sep 17 00:00:00 2001 From: Alberto Diaz Date: Tue, 19 Sep 2023 16:57:57 -0400 Subject: [PATCH] adding tutorial to ROSA docs from mobb ninja site --- _topic_maps/_topic_map_rosa.yml | 4 +- .../cloud-experts-consistent-egress-ip.adoc | 416 ++++++++++++++++++ 2 files changed, 419 insertions(+), 1 deletion(-) create mode 100644 cloud_experts_tutorials/cloud-experts-consistent-egress-ip.adoc diff --git a/_topic_maps/_topic_map_rosa.yml b/_topic_maps/_topic_map_rosa.yml index 3c90a001fb..7cfb0f90fb 100644 --- a/_topic_maps/_topic_map_rosa.yml +++ b/_topic_maps/_topic_map_rosa.yml @@ -107,7 +107,9 @@ Topics: - Name: Deploying the External DNS Operator on ROSA File: cloud-experts-external-dns - Name: Dynamically issuing certificates using the cert-manager Operator on ROSA - File: cloud-experts-dynamic-certificate-custom-domain + File: cloud-experts-dynamic-certificate-custom-domain +- Name: Assigning consistent egress IP for external traffic + File: cloud-experts-consistent-egress-ip --- Name: Getting started Dir: rosa_getting_started diff --git a/cloud_experts_tutorials/cloud-experts-consistent-egress-ip.adoc b/cloud_experts_tutorials/cloud-experts-consistent-egress-ip.adoc new file mode 100644 index 0000000000..cfc2f36151 --- /dev/null +++ b/cloud_experts_tutorials/cloud-experts-consistent-egress-ip.adoc @@ -0,0 +1,416 @@ +:_content-type: ASSEMBLY +[id="cloud-experts-consistent-egress-ip"] += Tutorial: Assigning consistent egress IP for external traffic +include::_attributes/attributes-openshift-dedicated.adoc[] +:context: cloud-experts-consistent-egress-ip + +toc::[] + +// Mobb content metadata +// Brought into ROSA product docs 2023-09-19 +// --- +// date: '2023-02-28' +// title: Assign Consistent Egress IP for External Traffic +// tags: ["OSD", "ROSA", "ARO"] +// authors: +// - 'Dustin Scott' +// --- + +It might be desirable to assign a consistent IP address for traffic that leaves the cluster when configuring items such as security groups or other sorts of security controls which require an IP-based configuration. By default, {product-title} (ROSA) (using the OVN-Kubernetes CNI) assigns random IP addresses from a pool which makes configuring security lockdowns unpredictable or unnecessarily open. This guide shows you how to configure a set of predictable IP addresses for egress cluster traffic to meet common security standards and guidance and other potential use cases. + +See the link:https://docs.openshift.com/container-platform/latest/networking/ovn_kubernetes_network_provider/configuring-egress-ips-ovn.html[OpenShift documentation on this topic] for more information. + +== Prerequisites + +* ROSA cluster deployed with OVN-Kubernetes +* OpenShift CLI (`oc`) +* ROSA CLI (`rosa`) +* `jq` + +=== Environment + +This sets environment variables for the tutorial so that you do not need to copy/paste in your own. Be sure to replace the `ROSA_MACHINE_POOL_NAME` variable if you wish to target a different Machine Pool.: + +[source,terminal] +---- +$ export ROSA_CLUSTER_NAME=$(oc get infrastructure cluster -o=jsonpath="{.status.infrastructureName}" | sed 's/-[a-z0-9]\{5\}$//') +$ export ROSA_MACHINE_POOL_NAME=Default +---- + +== Ensure capacity + +For each public cloud provider, there is a limit on the number of IP addresses that may be assigned per node. This can affect the ability to assign an egress IP address. To verify sufficient capacity, you can run the following command to print out the currently assigned IP addresses versus the total capacity in order to identify any nodes which may affected: + +[source,terminal] +---- +$ oc get node -o json | \ + jq '.items[] | + { + "name": .metadata.name, + "ips": (.status.addresses | map(select(.type == "InternalIP") | .address)), + "capacity": (.metadata.annotations."cloud.network.openshift.io/egress-ipconfig" | fromjson[] | .capacity.ipv4) + }' +---- + +.Example output +[source,terminal] +--- +{ + "name": "ip-10-10-145-88.ec2.internal", + "ips": [ + "10.10.145.88" + ], + "capacity": 14 +} +{ + "name": "ip-10-10-154-175.ec2.internal", + "ips": [ + "10.10.154.175" + ], + "capacity": 14 +} +--- + +[NOTE] +==== +The above example uses `jq` as a friendly filter. If you do not have `jq` installed, you can review the `metadata.annotations['cloud.network.openshift.io/egress-ipconfig']` field of each node manually to verify node capacity. +==== + +== Create the egress IP rule(s) + +[NOTE] +==== +Generally speaking, it would be ideal to label the nodes prior to assigning the egress IP addresses, however there is a bug that exists which needs to be fixed first. Once this is fixed, the process and documentation will be re-ordered to address this. See link:https://issues.redhat.com/browse/OCPBUGS-4969[OCPBUGS-4969]. +==== + +=== Identify the egress IPs + +Before creating the rules, we should identify which egress IPs that we will use. It should be noted that the egress IPs that you select should exist as a part of the subnets in which the worker nodes are provisioned into. + +=== Reserve the egress IPs + +It is recommended, but not required, to reserve the egress IPs that you have requested to avoid conflicts with the AWS VPC DHCP service. To do so, you can request explicit IP reservations by link:https://docs.aws.amazon.com/vpc/latest/userguide/subnet-cidr-reservation.html[following the AWS documentation for CIDR reservations]. + +== Deploy an egress IP to a namespace + +Create a project to demonstrate assigning egress IP addresses based on a namespace selection: + +[source,terminal] +---- +$ oc new-project demo-egress-ns +---- + +Create the egress rule. This rule will ensure that egress traffic will be applied to all pods within the namespace that we just created using the `spec.namespaceSelector` field: + +[source,terminal] +---- +$ cat <