|
| 1 | +# Propose ROSA HCP IAM Account Roles, IAM Operator Roles, and OIDC Configuration as CRD in CAPA |
| 2 | + |
| 3 | +## Table of Contents |
| 4 | +- [Summary](#summary) |
| 5 | +- [Motivation](#motivation) |
| 6 | + - [Problem Statement](#problem-statement) |
| 7 | + - [Goals](#goals) |
| 8 | + - [Non-Goals](#non-goals) |
| 9 | +- [Proposal](#proposal) |
| 10 | + - [User Stories](#user-stories) |
| 11 | + - [Implementation Details](#implementation-details) |
| 12 | + - [Risks and Mitigations](#risks-and-mitigations) |
| 13 | +- [Alternatives](#alternatives) |
| 14 | +- [Implementation Plan](#implementation-plan) |
| 15 | +- [Resources](#resources) |
| 16 | + |
| 17 | +## Summary |
| 18 | +The ROSA HCP in CAPA (Cluster API Provider AWS) project currently lacks built-in support for managing IAM account roles, IAM operator roles, and OIDC configuration as Custom Resource Definitions (CRDs). This proposal suggests integrating the [ROSA library](https://github.com/openshift/rosa) to extend ROSA-HCP's functionality, enabling declarative IAM and OIDC management. |
| 19 | + |
| 20 | +## Motivation |
| 21 | +### Problem Statement |
| 22 | +Managing ROSA HCP IAM roles and OIDC configurations manually can be complex and error-prone. ROSA-HCP in CAPA lacks an automated mechanism to provision and reconcile these IAM resources, making it challenging for OpenShift ROSA HCP clusters deployed via CAPA to comply with security best practices and AWS integration requirements. |
| 23 | + |
| 24 | +### Goals |
| 25 | +- Introduce ROSARoleConfig CRD for ROSA HCP IAM account roles, IAM operator roles, and OIDC configuration in CAPA. |
| 26 | +- Enable automated reconciliation of these resources using the ROSA library. |
| 27 | +- Simplify cluster lifecycle management by aligning IAM/OIDC management with Kubernetes declarative paradigms. |
| 28 | +- Reduce operational overhead for users deploying OpenShift ROSA HCP clusters on AWS via CAPA. |
| 29 | + |
| 30 | +### Non-Goals |
| 31 | +- Intorducing new IAM management workflows out of CAPA. |
| 32 | +- Introducing non-AWS IAM solutions. |
| 33 | + |
| 34 | +## Proposal |
| 35 | +### User Stories |
| 36 | +#### 1. Declarative ROSA-HCP IAM Role Management |
| 37 | +As a ROSA-HCP CAPA user, I want to define IAM account roles, operator roles and OIDC configurations using Kubernetes CRDs so that they are automatically created, seamlessly integrate with identity providers and reconciled by CAPA. |
| 38 | + |
| 39 | +### Implementation Details |
| 40 | +1. **Define CRDs for ROSA-HCP IAM roles and OIDC resources** |
| 41 | + ROSARoleConfig is a cluster scope CRD defines the required IAM account roles, operator roles and OIDC configurations to create ROSA HCP cluster. Creating the Roles and OIDC config should be in order as follows; |
| 42 | + 1. Create ROSA HCP account roles. |
| 43 | + 1. Create ROSA HCP OIDC config & OIDC provider. |
| 44 | + 1. Create ROSA HCP operator roles. |
| 45 | + |
| 46 | + It’s important to follow the specified order, as the account roles are required to create the OIDC configuration, and the OIDC config ID is required for setting up the operator roles. The oidcConfig contains the externalAuthProviders configurations, which can be utilized by the RosaControlPlane. The ROSA lib will serve as the reference for creating the IAM roles and OIDC provider. Below is an example of a ROSARoleConfig CR with detailed descriptions. |
| 47 | + |
| 48 | + ```yaml |
| 49 | + apiVersion: infrastructure.cluster.x-k8s.io/v1beta2 |
| 50 | + kind: ROSARoleConfig |
| 51 | + metadata: |
| 52 | + name: rosa-role-config |
| 53 | + spec: |
| 54 | + accountRoleConfig: |
| 55 | + # User-defined prefix for the generated AWS IAM roles. |
| 56 | + # required |
| 57 | + prefix: capa |
| 58 | + |
| 59 | + # The ARN of the policy that is used to set the permissions boundary for the account roles. |
| 60 | + # optional |
| 61 | + permissionsBoundaryARN: "" |
| 62 | + |
| 63 | + # The arn path for the account/operator roles as well as their policies. |
| 64 | + # optional |
| 65 | + path: "" |
| 66 | + |
| 67 | + # Version of OpenShift that will be used to setup policy tag, for example "4.18" |
| 68 | + # required |
| 69 | + version: "4.18" |
| 70 | + |
| 71 | + sharedVPCConfig: |
| 72 | + # Role ARN associated with the private hosted zone used for Hosted Control Plane cluster shared VPC, this role contains policies to be used with Route 53 |
| 73 | + # optional |
| 74 | + routeRoleARN: "" |
| 75 | + |
| 76 | + # Role ARN associated with the shared VPC used for Hosted Control Plane clusters, this role contains policies to be used with the VPC endpoint. |
| 77 | + # optional |
| 78 | + vpcEndpointRoleArn: "" |
| 79 | + operatorRoleConfig: |
| 80 | + # User-defined prefix for generated AWS operator policies. |
| 81 | + # required |
| 82 | + prefix: capa |
| 83 | + |
| 84 | + # The ARN of the policy that is used to set the permissions boundary for the operator roles. |
| 85 | + # optional |
| 86 | + permissionsBoundaryARN: "" |
| 87 | + |
| 88 | + # oidcConfigId is registered OIDC configuration ID to add its issuer URL as the trusted relationship to the operator roles. |
| 89 | + # Cannot be used while oidcConfig->createManagedOIDC is enabled |
| 90 | + # optional |
| 91 | + oidcConfigId: "" |
| 92 | + |
| 93 | + sharedVPCConfig: |
| 94 | + # AWS IAM Role Arn with policy attached, associated with shared VPC. Grants permission necessary to handle route53 operations associated with a cross-account VPC. |
| 95 | + # optional |
| 96 | + routeRoleARN: "" |
| 97 | + |
| 98 | + # AWS IAM Role ARN with policy attached, associated with the shared VPC. Grants permissions necessary to communicate with and handle a Hosted Control Plane cross-account VPC. |
| 99 | + # optional |
| 100 | + vpcEndpointRoleArn: "" |
| 101 | + oidcConfig: |
| 102 | + # CreateManagedOIDC flag, default is enabled to create a managed oidc-config and oidc-provider. The created oidc-config-id wil be used to create the operator roles. |
| 103 | + createManagedOIDC: enabled |
| 104 | + # example of externalAuthProviders similar to RosaControlPlane->externalAuthProviders. |
| 105 | + externalAuthProviders: |
| 106 | + - name: my-oidc-provider |
| 107 | + issuer: |
| 108 | + issuerURL: https://login.myoidc.com/<tenant-id>/v2.0 |
| 109 | + audiences: # audiences that will be trusted by the kube-apiserver |
| 110 | + - "audience1" |
| 111 | + claimMappings: |
| 112 | + username: |
| 113 | + claim: email |
| 114 | + prefixPolicy: "" |
| 115 | + groups: |
| 116 | + claim: groups |
| 117 | + oidcClients: |
| 118 | + - componentName: console |
| 119 | + componentNamespace: openshift-console |
| 120 | + clientID: <console-client-id> |
| 121 | + clientSecret: |
| 122 | + name: console-client-secret |
| 123 | + status: |
| 124 | + conditions: |
| 125 | + - type: Ready |
| 126 | + status: "True" |
| 127 | + message: "ROSA HCP Roles & OIDC created" |
| 128 | + reason: "Created" |
| 129 | + # Created oidc config and provider. |
| 130 | + oidcID: "123456789123456789abcdefgh" |
| 131 | + oidcProviderARN: arn:aws:iam::12345678910:oidc-provider/oidc.ocp.dev.org/123456789123456789abcdefgh |
| 132 | + |
| 133 | + # Created ROSA-HCP managed account roles |
| 134 | + accountRolesRef: |
| 135 | + installerRoleARN: "arn:aws:iam::12345678910:role/capa-HCP-ROSA-Installer-Role" |
| 136 | + supportRoleARN: "arn:aws:iam::12345678910:role/capa-HCP-ROSA-Support-Role" |
| 137 | + workerRoleARN: "arn:aws:iam::12345678910:role/capa-HCP-ROSA-Worker-Role" |
| 138 | + |
| 139 | + # Created ROSA-HCP managed operator roles |
| 140 | + operatorRolesRef: |
| 141 | + ingressARN: "arn:aws:iam::12345678910:role/capa-openshift-ingress-operator-cloud-credentials" |
| 142 | + imageRegistryARN: "arn:aws:iam::12345678910:role/capa-openshift-image-registry-installer-cloud-credentials" |
| 143 | + storageARN: "arn:aws:iam::12345678910:role/capa-openshift-cluster-csi-drivers-ebs-cloud-credentials" |
| 144 | + networkARN: "arn:aws:iam::12345678910:role/capa-openshift-cloud-network-config-controller-cloud-credent" |
| 145 | + kubeCloudControllerARN: "arn:aws:iam::12345678910:role/capa-kube-system-kube-controller-manager" |
| 146 | + nodePoolManagementARN: "arn:aws:iam::12345678910:role/capa-kube-system-capa-controller-manager" |
| 147 | + controlPlaneOperatorARN: "arn:aws:iam::12345678910:role/capa-kube-system-control-plane-operator" |
| 148 | + kmsProviderARN: "arn:aws:iam::12345678910:role/capa-kube-system-kms-provider" |
| 149 | + ``` |
| 150 | +
|
| 151 | + The ROSARoleConfig status conditions should present the roles creation order and failed status. Below are examples of condition state. |
| 152 | +
|
| 153 | + ```yaml |
| 154 | + status: |
| 155 | + conditions: |
| 156 | + - type: Ready |
| 157 | + status: "False" |
| 158 | + message: "Creating OIDC provider" |
| 159 | + reason: "Creating" |
| 160 | + ``` |
| 161 | +
|
| 162 | + ```yaml |
| 163 | + status: |
| 164 | + conditions: |
| 165 | + - type: Ready |
| 166 | + status: "True" |
| 167 | + message: "ROSA HCP Roles & OIDC created" |
| 168 | + reason: "Created" |
| 169 | + ``` |
| 170 | +
|
| 171 | + ```yaml |
| 172 | + status: |
| 173 | + conditions: |
| 174 | + - type: Ready |
| 175 | + status: "False" |
| 176 | + message: "Failed to create IAM operator roles oidc-config not exist." |
| 177 | + reason: "Failed" |
| 178 | + ``` |
| 179 | +
|
| 180 | +2. **Implement a CAPA controller leveraging the ROSA library** |
| 181 | + - Manage CRUD operations for ROSA HCP IAM roles and OIDC configurations. |
| 182 | + - Ensure proper IAM permissions and security best practices. |
| 183 | +
|
| 184 | +3. **Validate and test integration** |
| 185 | + - Develop unit tests for ROSA HCP IAM and OIDC CRD reconciliation. |
| 186 | + - Conduct integration tests in AWS environments. |
| 187 | + - Introduce CI job that cover the ROSARoleConfig creation and validation. |
| 188 | +
|
| 189 | +4. **RosaControlPlane reference** |
| 190 | + - The `ROSAControlPlane` custom resource (CR) will include a reference to the `ROSARoleConfig`, allowing the end user to reference the ROSA IAM roles and OIDC configuration across multiple ROSA-HCP clusters. Ex; |
| 191 | + ```yaml |
| 192 | + kind: ROSAControlPlane |
| 193 | + metadata: |
| 194 | + name: rosa-hcp-stage |
| 195 | + namespace: default |
| 196 | + spec: |
| 197 | + rosaRoleConfigRef: |
| 198 | + name: stage-rosaRoleConfig |
| 199 | + ``` |
| 200 | + |
| 201 | + - The `ROSAControlPlane` should be able to use the IAM role ARN and OIDC config ID from the `ROSARoleConfig` CR status, and it will validate the status of the `ROSARoleConfig` through the conditions outlined above. |
| 202 | + |
| 203 | + - A validation should be implemented in the ROSAControlPlane to prevent the end user from setting both `rosaRoleConfigRef` and the `rolesRef` and `oidcID` in the ROSAControlPlane at the same time. |
| 204 | + |
| 205 | +5. **Deleting ROSARoleConfig** |
| 206 | + - During the deletion of a ROSARoleConfig, a validation should be performed to check if any `ROSAControlPlane` CR references the deleted `ROSARoleConfig` CR. |
| 207 | + |
| 208 | +### Risks and Mitigations |
| 209 | +- **Complexity of IAM management** Address through clear documentation and best practices. |
| 210 | +- **Dependency on ROSA library** Maintain compatibility by tracking upstream changes. |
| 211 | + |
| 212 | +## Alternatives |
| 213 | +- Using Terraform or manual IAM configurations (not scalable or Kubernetes-native). |
| 214 | +- Developing a custom IAM management solution for CAPA (reinventing existing functionality in ROSA HCP). |
| 215 | + |
| 216 | +## Implementation Plan |
| 217 | +1. Research ROSA library capabilities. |
| 218 | +2. Develop and integrate the new controller for ROSARoleConfig CRD. |
| 219 | +3. Validate with unit and integration tests. |
| 220 | +4. Document usage and best practices. |
| 221 | +5. Engage the CAPA and OpenShift ROSA HCP community for feedback. |
| 222 | + |
| 223 | +## Resources |
| 224 | +- [ROSA Library](https://github.com/openshift/rosa) |
| 225 | +- [Cluster API Provider AWS (CAPA)](https://github.com/kubernetes-sigs/cluster-api-provider-aws) |
| 226 | +- [ROSA HCP External Auth Providers](https://cluster-api-aws.sigs.k8s.io/topics/rosa/external-auth) |
| 227 | +- [AWS IAM Best Practices](https://docs.aws.amazon.com/IAM/latest/UserGuide/best-practices.html) |
0 commit comments