Skip to content
This repository has been archived by the owner on Feb 18, 2024. It is now read-only.

Commit

Permalink
chore(crossplane): use an environmentconfig
Browse files Browse the repository at this point in the history
  • Loading branch information
Smana committed Aug 6, 2023
1 parent 7f7fadd commit c963799
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
apiVersion: apiextensions.crossplane.io/v1alpha1
kind: EnvironmentConfig
metadata:
name: irsa-environment
data:
clusterName: ${cluster_name}
oidcUrl: ${oidc_issuer_url}
oidcHost: ${oidc_issuer_host}
oidcArn: ${oidc_provider_arn}
accountId: ${aws_account_id}
region: ${region}
vpcId: ${vpc_id}
14 changes: 12 additions & 2 deletions infrastructure/base/crossplane/configuration/irsa-composition.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,14 @@ spec:
- type: FromCompositeFieldPath
fromFieldPath: spec.deletionPolicy
toFieldPath: spec.deletionPolicy
environment:
environmentConfigs:
- type: Selector
selector:
matchLabels:
- type: FromCompositeFieldPath
key: clusterRef
valueFromFieldPath: spec.parameters.clusterRef.id

resources:
- name: irsa-role
Expand Down Expand Up @@ -71,7 +79,9 @@ spec:
combine:
strategy: string
variables:
- fromFieldPath: oidcArn
- fromFieldPath: condition
- fromFieldPath: oidcHost
- fromFieldPath: serviceAccount.namespace
- fromFieldPath: serviceAccount.name
string:
Expand All @@ -82,12 +92,12 @@ spec:
{
"Effect": "Allow",
"Principal": {
"Federated": "${oidc_provider_arn}"
"Federated": "%s"
},
"Action": "sts:AssumeRoleWithWebIdentity",
"Condition": {
"%s": {
"${oidc_issuer_host}:sub": "system:serviceaccount:%s:%s"
"%s:sub": "system:serviceaccount:%s:%s"
}
}
}
Expand Down
10 changes: 10 additions & 0 deletions infrastructure/base/crossplane/configuration/irsa-definition.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,20 @@ spec:
enum:
- StringEquals
- StringLike
clusterRef:
type: object
description: "A reference to the Cluster object that this IRSA should be connected to."
properties:
id:
type: string
description: ID of the Cluster object this ref points to.
required:
- id
policyDocument:
type: string
description: The JSON policy document that is the content for the policy.
required:
- clusterRef
- condition
- policyDocument
- serviceAccount
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ namespace: crossplane-system

# reference: https://github.com/upbound/platform-ref-aws/tree/main/package/cluster/irsa
resources:
- environmentconfig.yaml
- irsa-composition.yaml
- irsa-definition.yaml
- providerconfig.yaml
1 change: 1 addition & 0 deletions terraform/eks/flux.tf
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ resource "kubernetes_config_map" "flux_clusters_vars" {
data = {
cluster_name = var.cluster_name
oidc_provider_arn = module.eks.oidc_provider_arn
oidc_issuer_url = module.eks.cluster_oidc_issuer_url
oidc_issuer_host = replace(module.eks.cluster_oidc_issuer_url, "https://", "")
aws_account_id = data.aws_caller_identity.this.account_id
region = var.region
Expand Down

0 comments on commit c963799

Please sign in to comment.