Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 1 addition & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,6 @@ Future work includes:
- If not using ARO you must either provide your own CA signed certs, or use let's encrypt.
- Must be on 4.16.14 or later.

> [!IMPORTANT]
> Users must provide a NAT Gateway attached to the worker node subnet when using Azure.

## Major versions

### `2.*`
Expand Down Expand Up @@ -90,11 +87,6 @@ This only has to be done once.
> [!NOTE]
> Once generated this script will not override secrets. Be careful when doing multiple tests.

#### Check your cluster on Azure has a NAT gateway attached
OpenShift does not require a NAT gateway by default, however, peer-pods do require a NAT gateway attached to the worker node subnet.

> [!NOTE]
>
#### Configuring let's encrypt.

> [!IMPORTANT]
Expand Down Expand Up @@ -148,6 +140,7 @@ Red Hat a demo platform. This allows easy access for Red Hat associates and part
2. Get access to an [Azure Subscription Based Blank Open Environment](https://catalog.demo.redhat.com/catalog?category=Open_Environments&search=azure&item=babylon-catalog-prod%2Fazure-gpte.open-environment-azure-subscription.prod).
3. Import the required azure environmental variables (see coded block):
```
export GUID=
export CLIENT_ID=
export PASSWORD=
export TENANT=
Expand Down
89 changes: 89 additions & 0 deletions ansible/azure-nat-gateway.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
---

- name: Configure Azure NAT Gateway
become: false
connection: local
hosts: localhost
gather_facts: false
vars:
kubeconfig: "{{ lookup('env', 'KUBECONFIG') }}"
resource_prefix: "coco"
tasks:
- name: Get Azure credentials
kubernetes.core.k8s_info:
kind: Secret
namespace: openshift-cloud-controller-manager
name: azure-cloud-credentials
register: azure_credentials
retries: 20
delay: 5
Comment on lines +12 to +19
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we just make this a safe exit? if we are not on azure in the future a clean exit would be nice.

Copy link
Copy Markdown
Collaborator Author

@sabre1041 sabre1041 May 15, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had been thinking about it, but we should holistically do it across the board

such as: https://github.com/sabre1041/coco-pattern/blob/main/ansible/configure-issuer.yaml

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually I agree. I'll raise an issue to chart the development of the feature as we discussed offline.


- name: Get Azure credentials
kubernetes.core.k8s_info:
kind: ConfigMap
namespace: openshift-cloud-controller-manager
name: cloud-conf
register: azure_cloud_conf
retries: 20
delay: 5

- name: Set facts
ansible.builtin.set_fact:
azure_subscription_id: "{{ (azure_cloud_conf.resources[0]['data']['cloud.conf'] | from_json)['subscriptionId'] }}"
azure_tenant_id: "{{ (azure_cloud_conf.resources[0]['data']['cloud.conf'] | from_json)['tenantId'] }}"
azure_resource_group: "{{ (azure_cloud_conf.resources[0]['data']['cloud.conf'] | from_json)['vnetResourceGroup'] }}"
azure_client_id: "{{ azure_credentials.resources[0]['data']['azure_client_id'] | b64decode }}"
azure_client_secret: "{{ azure_credentials.resources[0]['data']['azure_client_secret'] | b64decode }}"
azure_vnet: "{{ (azure_cloud_conf.resources[0]['data']['cloud.conf'] | from_json)['vnetName'] }}"
azure_subnet: "{{ (azure_cloud_conf.resources[0]['data']['cloud.conf'] | from_json)['subnetName'] }}"
coco_public_ip_name: "{{ resource_prefix }}-pip"
coco_nat_gateway_name: "{{ resource_prefix }}-nat-gateway"
no_log: true

- name: Create Public IP for NAT Gateway
azure_rm_publicipaddress:
subscription_id: "{{ azure_subscription_id }}"
tenant: "{{ azure_tenant_id }}"
client_id: "{{ azure_client_id }}"
secret: "{{ azure_client_secret }}"
resource_group: "{{ azure_resource_group }}"
name: "{{ coco_public_ip_name }}"
sku: "standard"
allocation_method: "static"

- name: Retrieve Public IP for NAT Gateway
azure_rm_publicipaddress_info:
subscription_id: "{{ azure_subscription_id }}"
tenant: "{{ azure_tenant_id }}"
client_id: "{{ azure_client_id }}"
secret: "{{ azure_client_secret }}"
resource_group: "{{ azure_resource_group }}"
name: "{{ coco_public_ip_name }}"
register: coco_gw_public_ip

- name: Create NAT Gateway
azure.azcollection.azure_rm_natgateway:
subscription_id: "{{ azure_subscription_id }}"
tenant: "{{ azure_tenant_id }}"
client_id: "{{ azure_client_id }}"
secret: "{{ azure_client_secret }}"
resource_group: "{{ azure_resource_group }}"
name: "{{ coco_nat_gateway_name }}"
idle_timeout_in_minutes: 10
sku:
name: standard
public_ip_addresses:
- "{{ coco_gw_public_ip.publicipaddresses[0].id }}"
register: coco_natgw

- name: Update the worker subnet to associate NAT gateway
azure.azcollection.azure_rm_subnet:
subscription_id: "{{ azure_subscription_id }}"
tenant: "{{ azure_tenant_id }}"
client_id: "{{ azure_client_id }}"
secret: "{{ azure_client_secret }}"
resource_group: "{{ azure_resource_group }}"
name: "{{ azure_subnet }}"
virtual_network_name: "{{ azure_vnet }}"
nat_gateway: "{{ coco_nat_gateway_name }}"
...
4 changes: 4 additions & 0 deletions values-simple.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,10 @@ clusterGroup:
#image: quay.io/hybridcloudpatterns/ansible-edge-gitops-ee:latest
verbosity: -vvv
timeout: 3600
- name: configure-azure-nat-gateway
playbook: ansible/azure-nat-gateway.yaml
verbosity: -vvv
timeout: 3600
managedClusterGroups:
exampleRegion:
name: group-one
Expand Down
Loading