Skip to content

Commit 0199ab6

Browse files
authored
Merge pull request #95 from philipwu08/image-mirrors
OCM-18302 | feat: Support for image registry mirrors
2 parents 74d67da + 4a1340e commit 0199ab6

File tree

11 files changed

+158
-0
lines changed

11 files changed

+158
-0
lines changed

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ Sub-modules included in this module:
3434

3535
- account-iam-resource: Handles the provisioning of Identity and Access Management (IAM) resources required for managing access and permissions in the AWS account associated with the ROSA HCP cluster.
3636
- idp: Responsible for configuring Identity Providers (IDPs) within the ROSA HCP cluster, faciliting seamless integration with external authentication system such as Github (GH), GitLab, Google, HTPasswd, LDAP and OpenID Connect (OIDC).
37+
- image-mirrors: Manages the configuration of image digest mirror sets for ROSA HCP clusters, enabling container image mirroring to redirect image pulls from source registries to mirror registries for zero-egress networking and improved performance.
3738
- machine-pool: Facilitates the management of machine pools within the ROSA HCP cluster, enabling users to scale resources and adjust specifications based on workload demands.
3839
- oidc-config-and-provider: Manages the configuration of OpenID Connect (OIDC) hosted files and providers for ROSA HCP clusters, enabling secure authentication and access control mechanisms for operator roles.
3940
- operator-roles: Oversees the management of roles assigned to operators within the ROSA HCP cluster, enabling to perform required actions with appropriate permissions on the lifecyle of a cluster.
@@ -80,6 +81,7 @@ We recommend you install the following CLI tools:
8081
| <a name="module_account_iam_resources"></a> [account\_iam\_resources](#module\_account\_iam\_resources) | ./modules/account-iam-resources | n/a |
8182
| <a name="module_oidc_config_and_provider"></a> [oidc\_config\_and\_provider](#module\_oidc\_config\_and\_provider) | ./modules/oidc-config-and-provider | n/a |
8283
| <a name="module_operator_roles"></a> [operator\_roles](#module\_operator\_roles) | ./modules/operator-roles | n/a |
84+
| <a name="module_rhcs_hcp_image_mirrors"></a> [rhcs\_hcp\_image\_mirrors](#module\_rhcs\_hcp\_image\_mirrors) | ./modules/image-mirrors | n/a |
8385
| <a name="module_rhcs_hcp_kubelet_configs"></a> [rhcs\_hcp\_kubelet\_configs](#module\_rhcs\_hcp\_kubelet\_configs) | ./modules/kubelet-configs | n/a |
8486
| <a name="module_rhcs_hcp_machine_pool"></a> [rhcs\_hcp\_machine\_pool](#module\_rhcs\_hcp\_machine\_pool) | ./modules/machine-pool | n/a |
8587
| <a name="module_rhcs_identity_provider"></a> [rhcs\_identity\_provider](#module\_rhcs\_identity\_provider) | ./modules/idp | n/a |
@@ -131,6 +133,7 @@ We recommend you install the following CLI tools:
131133
| <a name="input_https_proxy"></a> [https\_proxy](#input\_https\_proxy) | A proxy URL to use for creating HTTPS connections outside the cluster. | `string` | `null` | no |
132134
| <a name="input_identity_providers"></a> [identity\_providers](#input\_identity\_providers) | Provides a generic approach to add multiple identity providers after the creation of the cluster. This variable allows users to specify configurations for multiple identity providers in a flexible and customizable manner, facilitating the management of resources post-cluster deployment. For additional details regarding the variables utilized, refer to the [idp sub-module](./modules/idp). For non-primitive variables (such as maps, lists, and objects), supply the JSON-encoded string. | `map(any)` | `{}` | no |
133135
| <a name="input_ignore_machine_pools_deletion_error"></a> [ignore\_machine\_pools\_deletion\_error](#input\_ignore\_machine\_pools\_deletion\_error) | Ignore machine pool deletion error. Assists when cluster resource is managed within the same file for the destroy use case | `bool` | `false` | no |
136+
| <a name="input_image_mirrors"></a> [image\_mirrors](#input\_image\_mirrors) | Provides a generic approach to add multiple image mirrors after the creation of the cluster. This variable allows users to specify configurations for multiple image mirrors in a flexible and customizable manner, facilitating the management of resources post-cluster deployment. For additional details regarding the variables utilized, refer to the [image-mirrors sub-module](./modules/image-mirrors). For non-primitive variables (such as maps, lists, and objects), supply the JSON-encoded string. | `map(any)` | `{}` | no |
134137
| <a name="input_kms_key_arn"></a> [kms\_key\_arn](#input\_kms\_key\_arn) | The key ARN is the Amazon Resource Name (ARN) of a CMK. It is a unique, fully qualified identifier for the CMK. A key ARN includes the AWS account, Region, and the key ID. | `string` | `null` | no |
135138
| <a name="input_kubelet_configs"></a> [kubelet\_configs](#input\_kubelet\_configs) | Provides a generic approach to add multiple kubelet configs after the creation of the cluster. This variable allows users to specify configurations for multiple kubelet configs in a flexible and customizable manner, facilitating the management of resources post-cluster deployment. For additional details regarding the variables utilized, refer to the [idp sub-module](./modules/kubelet-configs). For non-primitive variables (such as maps, lists, and objects), supply the JSON-encoded string. | `map(any)` | `{}` | no |
136139
| <a name="input_machine_cidr"></a> [machine\_cidr](#input\_machine\_cidr) | Block of IP addresses used by OpenShift while installing the cluster, for example "10.0.0.0/16". | `string` | `null` | no |
@@ -168,6 +171,7 @@ We recommend you install the following CLI tools:
168171
| <a name="output_cluster_domain"></a> [cluster\_domain](#output\_cluster\_domain) | The DNS domain of cluster. |
169172
| <a name="output_cluster_id"></a> [cluster\_id](#output\_cluster\_id) | Unique identifier of the cluster. |
170173
| <a name="output_cluster_state"></a> [cluster\_state](#output\_cluster\_state) | The state of the cluster. |
174+
| <a name="output_image_mirror_ids"></a> [image\_mirror\_ids](#output\_image\_mirror\_ids) | A map of image mirror names to their unique identifiers. |
171175
| <a name="output_oidc_config_id"></a> [oidc\_config\_id](#output\_oidc\_config\_id) | The unique identifier associated with users authenticated through OpenID Connect (OIDC) generated by this OIDC config. |
172176
| <a name="output_oidc_endpoint_url"></a> [oidc\_endpoint\_url](#output\_oidc\_endpoint\_url) | Registered OIDC configuration issuer URL, generated by this OIDC config. |
173177
| <a name="output_operator_role_prefix"></a> [operator\_role\_prefix](#output\_operator\_role\_prefix) | Prefix used for generated AWS operator policies. |

examples/rosa-hcp-public-with-multiple-machinepools-and-idps/README.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ This example includes:
99
- All AWS resources (IAM and networking) that are created as part of the ROSA cluster module execution
1010
- "Day 2" Machine pool resources - created as part of the root module execution - map of multiple resources is provided.
1111
- "Day 2" Identity provider resource - created as part of the root module execution - map of multiple resources is provided.
12+
- "Day 2" Image mirror resources - created as part of the root module execution - map of multiple resources is provided.
1213

1314
Note: This example involves the creation of various identity providers using placeholder values for illustrative purposes. These providers will not grant access to the cluster with the exception of the HTPasswd identity provider. You must supply your own pre-configured values for authentic identity providers.
1415

@@ -57,6 +58,18 @@ module "hcp" {
5758
pod_pids_limit = 16384
5859
}
5960
}
61+
image_mirrors = {
62+
mirror1 = {
63+
type = "digest"
64+
source = "registry.redhat.io"
65+
mirrors = ["mirror.example.com", "backup-mirror.example.com"]
66+
},
67+
mirror2 = {
68+
type = "digest"
69+
source = "quay.io"
70+
mirrors = ["internal-quay.corp.example.com"]
71+
}
72+
}
6073
machine_pools = {
6174
pool1 = {
6275
name = "pool1"

examples/rosa-hcp-public-with-multiple-machinepools-and-idps/main.tf

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,18 @@ module "hcp" {
2929
pod_pids_limit = 16384
3030
}
3131
}
32+
image_mirrors = {
33+
mirror1 = {
34+
type = "digest"
35+
source = "registry.redhat.io"
36+
mirrors = ["mirror.example.com", "backup-mirror.example.com"]
37+
},
38+
mirror2 = {
39+
type = "digest"
40+
source = "quay.io"
41+
mirrors = ["internal-quay.corp.example.com"]
42+
}
43+
}
3244
machine_pools = {
3345
pool1 = {
3446
name = "pool1"

main.tf

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,19 @@ module "rhcs_hcp_kubelet_configs" {
223223
pod_pids_limit = each.value.pod_pids_limit
224224
}
225225

226+
######################################
227+
# Multiple Image Mirrors block
228+
######################################
229+
module "rhcs_hcp_image_mirrors" {
230+
source = "./modules/image-mirrors"
231+
for_each = var.image_mirrors
232+
233+
cluster_id = module.rosa_cluster_hcp.cluster_id
234+
type = each.value.type
235+
source_registry = each.value.source
236+
mirrors = each.value.mirrors
237+
}
238+
226239
resource "null_resource" "validations" {
227240
lifecycle {
228241
precondition {

modules/image-mirrors/README.md

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
# image-mirrors
2+
3+
## Introduction
4+
5+
This Terraform sub-module manages the image mirrors for ROSA HCP clusters. It enables you to efficiently configure image digest mirror sets after cluster deployment. With this module, you can easily set up container image mirroring to redirect image pulls from source registries to mirror registries, enabling zero-egress networking and improved performance.
6+
7+
## Example Usage
8+
9+
```
10+
module "imagemirror" {
11+
source = "terraform-redhat/rosa-hcp/rhcs//modules/image-mirrors"
12+
13+
cluster_id = "cluster-id-123"
14+
type = "digest"
15+
source_registry = "registry.redhat.io"
16+
mirrors = ["mirror.example.com"]
17+
}
18+
```
19+
20+
<!-- BEGIN_AUTOMATED_TF_DOCS_BLOCK -->
21+
## Requirements
22+
23+
| Name | Version |
24+
|------|---------|
25+
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 1.0 |
26+
| <a name="requirement_rhcs"></a> [rhcs](#requirement\_rhcs) | >= 1.7.2 |
27+
28+
## Providers
29+
30+
| Name | Version |
31+
|------|---------|
32+
| <a name="provider_rhcs"></a> [rhcs](#provider\_rhcs) | >= 1.7.2 |
33+
34+
## Modules
35+
36+
No modules.
37+
38+
## Resources
39+
40+
| Name | Type |
41+
|------|------|
42+
| [rhcs_image_mirror.image_mirror](https://registry.terraform.io/providers/terraform-redhat/rhcs/latest/docs/resources/image_mirror) | resource |
43+
44+
## Inputs
45+
46+
| Name | Description | Type | Default | Required |
47+
|------|-------------|------|---------|:--------:|
48+
| <a name="input_cluster_id"></a> [cluster\_id](#input\_cluster\_id) | Identifier of the cluster. | `string` | n/a | yes |
49+
| <a name="input_mirrors"></a> [mirrors](#input\_mirrors) | List of mirror registry hostnames. | `list(string)` | n/a | yes |
50+
| <a name="input_source_registry"></a> [source\_registry](#input\_source\_registry) | The source registry hostname. | `string` | n/a | yes |
51+
| <a name="input_type"></a> [type](#input\_type) | The type of the image digest mirror set. | `string` | n/a | yes |
52+
53+
## Outputs
54+
55+
| Name | Description |
56+
|------|-------------|
57+
| <a name="output_image_mirror_id"></a> [image\_mirror\_id](#output\_image\_mirror\_id) | The unique identifier of the image mirror. |
58+
<!-- END_AUTOMATED_TF_DOCS_BLOCK -->

modules/image-mirrors/main.tf

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
resource "rhcs_image_mirror" "image_mirror" {
2+
cluster_id = var.cluster_id
3+
type = var.type
4+
source = var.source_registry
5+
mirrors = var.mirrors
6+
}

modules/image-mirrors/outputs.tf

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
output "image_mirror_id" {
2+
description = "The unique identifier of the image mirror."
3+
value = rhcs_image_mirror.image_mirror.id
4+
}

modules/image-mirrors/variables.tf

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
// Required
2+
variable "cluster_id" {
3+
description = "Identifier of the cluster."
4+
type = string
5+
}
6+
7+
// Required
8+
variable "type" {
9+
description = "The type of the image digest mirror set."
10+
type = string
11+
}
12+
13+
// Required
14+
variable "source_registry" {
15+
description = "The source registry hostname."
16+
type = string
17+
}
18+
19+
// Required
20+
variable "mirrors" {
21+
description = "List of mirror registry hostnames."
22+
type = list(string)
23+
}

modules/image-mirrors/versions.tf

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
terraform {
2+
required_version = ">= 1.0"
3+
4+
required_providers {
5+
rhcs = {
6+
version = ">= 1.7.2"
7+
source = "terraform-redhat/rhcs"
8+
}
9+
}
10+
}

outputs.tf

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,3 +81,12 @@ output "operator_roles_arn" {
8181
value = var.create_operator_roles ? module.operator_roles[0].operator_roles_arn : null
8282
description = "List of Amazon Resource Names (ARNs) for all operator roles created."
8383
}
84+
85+
## Image Mirrors Module Outputs
86+
87+
output "image_mirror_ids" {
88+
value = {
89+
for k, v in module.rhcs_hcp_image_mirrors : k => v.image_mirror_id
90+
}
91+
description = "A map of image mirror names to their unique identifiers."
92+
}

0 commit comments

Comments
 (0)