|
| 1 | +apiVersion: kro.run/v1alpha1 |
| 2 | +kind: ResourceGroup |
| 3 | +metadata: |
| 4 | + name: ecrcontrollers.kro.run |
| 5 | + namespace: kro |
| 6 | +spec: |
| 7 | + schema: |
| 8 | + apiVersion: v1alpha1 |
| 9 | + kind: ECRController |
| 10 | + spec: |
| 11 | + name: string | default=ecr-controller |
| 12 | + namespace: string | default=default |
| 13 | + values: |
| 14 | + aws: |
| 15 | + accountID: string | required=true |
| 16 | + region: string | default=us-west-2 |
| 17 | + deployment: |
| 18 | + containerPort: integer | default=8080 |
| 19 | + replicas: integer | default=1 |
| 20 | + iamRole: |
| 21 | + maxSessionDuration: integer | default=3600 |
| 22 | + oidcProvider: string | required=true |
| 23 | + roleDescription: string | default=IRSA role for ACK ECR controller deployment on EKS cluster using kro Resource group |
| 24 | + iamPolicy: |
| 25 | + description: string | default="policy for ecr controller" |
| 26 | + image: |
| 27 | + deletePolicy: string | default=delete |
| 28 | + repository: string | default=public.ecr.aws/aws-controllers-k8s/ecr-controller |
| 29 | + tag: string | default=1.0.19 |
| 30 | + resources: |
| 31 | + requests: |
| 32 | + memory: string | default=64Mi |
| 33 | + cpu: string | default=50m |
| 34 | + limits: |
| 35 | + memory: string | default=128Mi |
| 36 | + cpu: string | default=100m |
| 37 | + log: |
| 38 | + enabled: boolean | default=false |
| 39 | + level: string | default=info |
| 40 | + serviceAccount: |
| 41 | + name: string | default=ecr-controller-sa |
| 42 | + resources: |
| 43 | + - id: ecrCRDGroup |
| 44 | + template: |
| 45 | + apiVersion: kro.run/v1alpha1 |
| 46 | + kind: ECRCRDGroup |
| 47 | + metadata: |
| 48 | + name: ${schema.spec.name}-crd-group |
| 49 | + spec: |
| 50 | + name: ${schema.spec.name}-crd-group |
| 51 | + - id: ecrControllerIamPolicy |
| 52 | + template: |
| 53 | + apiVersion: iam.services.k8s.aws/v1alpha1 |
| 54 | + kind: Policy |
| 55 | + metadata: |
| 56 | + name: ${schema.spec.name}-iam-policy |
| 57 | + spec: |
| 58 | + name: ${schema.spec.name}-iam-policy |
| 59 | + description: ${schema.spec.values.iamPolicy.description} |
| 60 | + policyDocument: > |
| 61 | + { |
| 62 | + "Version": "2012-10-17", |
| 63 | + "Statement": [ |
| 64 | + { |
| 65 | + "Effect": "Allow", |
| 66 | + "Action": [ |
| 67 | + "ecr:*", |
| 68 | + "cloudtrail:LookupEvents" |
| 69 | + ], |
| 70 | + "Resource": "*" |
| 71 | + }, |
| 72 | + { |
| 73 | + "Effect": "Allow", |
| 74 | + "Action": [ |
| 75 | + "iam:CreateServiceLinkedRole" |
| 76 | + ], |
| 77 | + "Resource": "*", |
| 78 | + "Condition": { |
| 79 | + "StringEquals": { |
| 80 | + "iam:AWSServiceName": [ |
| 81 | + "replication.ecr.amazonaws.com" |
| 82 | + ] |
| 83 | + } |
| 84 | + } |
| 85 | + } |
| 86 | + ] |
| 87 | + } |
| 88 | + - id: ecrControllerIamRole |
| 89 | + template: |
| 90 | + apiVersion: iam.services.k8s.aws/v1alpha1 |
| 91 | + kind: Role |
| 92 | + metadata: |
| 93 | + name: ${schema.spec.name}-iam-role |
| 94 | + namespace: ${schema.spec.namespace} |
| 95 | + spec: |
| 96 | + name: ${schema.spec.name}-iam-role |
| 97 | + description: ${schema.spec.values.iamRole.roleDescription} |
| 98 | + maxSessionDuration: ${schema.spec.values.iamRole.maxSessionDuration} |
| 99 | + policies: |
| 100 | + - ${ecrControllerIamPolicy.status.ackResourceMetadata.arn} |
| 101 | + assumeRolePolicyDocument: > |
| 102 | + { |
| 103 | + "Version":"2012-10-17", |
| 104 | + "Statement": [{ |
| 105 | + "Effect":"Allow", |
| 106 | + "Principal": {"Federated": "arn:aws:iam::${schema.spec.values.aws.accountID}:oidc-provider/${schema.spec.values.iamRole.oidcProvider}"}, |
| 107 | + "Action": ["sts:AssumeRoleWithWebIdentity"], |
| 108 | + "Condition": { |
| 109 | + "StringEquals": {"${schema.spec.values.iamRole.oidcProvider}:sub": "system:serviceaccount:${schema.spec.namespace}:${schema.spec.values.serviceAccount.name}"} |
| 110 | + } |
| 111 | + }] |
| 112 | + } |
| 113 | + - id: serviceAccount |
| 114 | + template: |
| 115 | + apiVersion: v1 |
| 116 | + kind: ServiceAccount |
| 117 | + metadata: |
| 118 | + name: ${schema.spec.values.serviceAccount.name} |
| 119 | + namespace: ${schema.spec.namespace} |
| 120 | + annotations: |
| 121 | + eks.amazonaws.com/role-arn : ${ecrControllerIamRole.status.ackResourceMetadata.arn} |
| 122 | + - id: deployment |
| 123 | + template: |
| 124 | + apiVersion: apps/v1 |
| 125 | + kind: Deployment |
| 126 | + metadata: |
| 127 | + name: ${schema.spec.name}-deployment |
| 128 | + namespace: ${schema.spec.namespace} |
| 129 | + labels: |
| 130 | + app.kubernetes.io/name: ${schema.spec.name}-deployment |
| 131 | + app.kubernetes.io/instance: ${schema.spec.name} |
| 132 | + spec: |
| 133 | + replicas: ${schema.spec.values.deployment.replicas} |
| 134 | + selector: |
| 135 | + matchLabels: |
| 136 | + app.kubernetes.io/name: ${schema.spec.name}-deployment |
| 137 | + app.kubernetes.io/instance: ${schema.spec.name} |
| 138 | + template: |
| 139 | + metadata: |
| 140 | + labels: |
| 141 | + app.kubernetes.io/name: ${schema.spec.name}-deployment |
| 142 | + app.kubernetes.io/instance: ${schema.spec.name} |
| 143 | + spec: |
| 144 | + serviceAccountName: ${serviceAccount.metadata.name} |
| 145 | + containers: |
| 146 | + - command: |
| 147 | + - ./bin/controller |
| 148 | + args: |
| 149 | + - --aws-region |
| 150 | + - ${schema.spec.values.aws.region} |
| 151 | + - --enable-development-logging=${schema.spec.values.log.enabled} |
| 152 | + - --log-level |
| 153 | + - ${schema.spec.values.log.level} |
| 154 | + - --deletion-policy |
| 155 | + - ${schema.spec.values.image.deletePolicy} |
| 156 | + - --watch-namespace |
| 157 | + - ${schema.spec.namespace} |
| 158 | + image: ${schema.spec.values.image.repository}:${schema.spec.values.image.tag} |
| 159 | + name: controller |
| 160 | + ports: |
| 161 | + - name: http |
| 162 | + containerPort: ${schema.spec.values.deployment.containerPort} |
| 163 | + resources: |
| 164 | + requests: |
| 165 | + memory: ${schema.spec.values.image.resources.requests.memory} |
| 166 | + cpu: ${schema.spec.values.image.resources.requests.cpu} |
| 167 | + limits: |
| 168 | + memory: ${schema.spec.values.image.resources.limits.memory} |
| 169 | + cpu: ${schema.spec.values.image.resources.limits.cpu} |
| 170 | + env: |
| 171 | + - name: ACK_SYSTEM_NAMESPACE |
| 172 | + value: ${schema.spec.namespace} |
| 173 | + - name: AWS_REGION |
| 174 | + value: ${schema.spec.values.aws.region} |
| 175 | + - name: DELETE_POLICY |
| 176 | + value: ${schema.spec.values.image.deletePolicy} |
| 177 | + - name: ACK_LOG_LEVEL |
| 178 | + value: ${schema.spec.values.log.level} |
| 179 | + - id: clusterRoleBinding |
| 180 | + template: |
| 181 | + apiVersion: rbac.authorization.k8s.io/v1 |
| 182 | + kind: ClusterRoleBinding |
| 183 | + metadata: |
| 184 | + name: ${schema.spec.name}-clusterrolebinding |
| 185 | + roleRef: |
| 186 | + kind: ClusterRole |
| 187 | + apiGroup: rbac.authorization.k8s.io |
| 188 | + name: ${clusterRole.metadata.name} |
| 189 | + subjects: |
| 190 | + - kind: ServiceAccount |
| 191 | + name: ${serviceAccount.metadata.name} |
| 192 | + namespace: ${serviceAccount.metadata.namespace} |
| 193 | + - id: clusterRole |
| 194 | + template: |
| 195 | + apiVersion: rbac.authorization.k8s.io/v1 |
| 196 | + kind: ClusterRole |
| 197 | + metadata: |
| 198 | + name: ${schema.spec.name}-clusterrole |
| 199 | + rules: |
| 200 | + - apiGroups: |
| 201 | + - "" |
| 202 | + resources: |
| 203 | + - configmaps |
| 204 | + - secrets |
| 205 | + verbs: |
| 206 | + - get |
| 207 | + - list |
| 208 | + - patch |
| 209 | + - watch |
| 210 | + - apiGroups: |
| 211 | + - "" |
| 212 | + resources: |
| 213 | + - namespaces |
| 214 | + verbs: |
| 215 | + - get |
| 216 | + - list |
| 217 | + - watch |
| 218 | + - apiGroups: |
| 219 | + - ecr.services.k8s.aws |
| 220 | + resources: |
| 221 | + - pullthroughcacherules |
| 222 | + - repositories |
| 223 | + verbs: |
| 224 | + - create |
| 225 | + - delete |
| 226 | + - get |
| 227 | + - list |
| 228 | + - patch |
| 229 | + - update |
| 230 | + - watch |
| 231 | + - apiGroups: |
| 232 | + - ecr.services.k8s.aws |
| 233 | + resources: |
| 234 | + - pullthroughcacherules/status |
| 235 | + - repositories/status |
| 236 | + verbs: |
| 237 | + - get |
| 238 | + - patch |
| 239 | + - update |
| 240 | + - apiGroups: |
| 241 | + - services.k8s.aws |
| 242 | + resources: |
| 243 | + - adoptedresources |
| 244 | + - fieldexports |
| 245 | + verbs: |
| 246 | + - create |
| 247 | + - delete |
| 248 | + - get |
| 249 | + - list |
| 250 | + - patch |
| 251 | + - update |
| 252 | + - watch |
| 253 | + - apiGroups: |
| 254 | + - services.k8s.aws |
| 255 | + resources: |
| 256 | + - adoptedresources/status |
| 257 | + - fieldexports/status |
| 258 | + verbs: |
| 259 | + - get |
| 260 | + - patch |
| 261 | + - update |
0 commit comments