Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(pc): add providerconfig example for aws eks pod identity feature #1254

Closed
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
54 changes: 54 additions & 0 deletions examples/providerconfig/v1beta1/pod-identity.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
# SPDX-FileCopyrightText: 2024 The Crossplane Authors <https://crossplane.io>
#
# SPDX-License-Identifier: CC0-1.0

apiVersion: aws.upbound.io/v1beta1
kind: ProviderConfig
metadata:
name: pod-identity
spec:
credentials:
source: WebIdentity
webIdentity:
roleARN: arn:aws:iam::123456789012:role/pod-identity-role
tokenConfig:
fs:
path: /var/run/secrets/pods.eks.amazonaws.com/serviceaccount/eks-pod-identity-token
Copy link
Contributor

Choose a reason for hiding this comment

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

maybe this is a future improvement in crossplane but it would be nice if we could have this be easier to implement without having to hard code path 🤔

Copy link
Collaborator

Choose a reason for hiding this comment

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

I'm surprised that it's necessary to set this explicitly, and that the SDK doesn't "Just Work" when instantiated in a pod that's assigned a PodIdentity. Maybe what we really need is to add an explicit PodIdentity to the list of supported auth types?

Copy link
Member Author

Choose a reason for hiding this comment

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

today we need to set it explicit - because our GO SDK is not up2date with this feature

Copy link
Contributor

Choose a reason for hiding this comment

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

Is there an issue to track that?

Copy link

@danielloader danielloader May 13, 2024

Choose a reason for hiding this comment

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

Quick question, if not a clarification:

IRSAv1 had a huge pain point in needing to include the roleARN that you're going to annotate service accounts with, so that the OIDC trust loop worked.

With IRSAv2 (Pod Identity Controller) I can configure all the AWS IAM/EKS components out of cluster, and as long as a pod starts up in the nominated namespace, and with the service account I picked, it should inherit the permissions at start via the injected token provided by the pod access controller.

Given this; if I have to mangle my helm to be coupled to the IAM ARN, I'm not sure I'm saving any hassle here - I want to just add a pod identity out of band (outside EKS, not involving Crossplane, since the host cluster is managed with terraform) and have Crossplane start up and use the IAM permissions granted to it.

Am I misunderstanding things here?

It's a relatively new concept but I've had success with this decoupled model with External Secrets controller for example.

Additionally as pointed out by @mbbush if we need to configure this, rather than letting it fall through the SDK default authentication methods a lot of the benefit of "it just works". Namely that; the pod identity controller, the associated admission mutation webhook and the tokens just being in the expected on the filsystem... start to lose some value.

source: Filesystem
---
apiVersion: iam.aws.upbound.io/v1beta1
kind: OpenIDConnectProvider
metadata:
name: pod-identity
spec:
forProvider:
clientIdList:
- pods.eks.amazonaws.com
thumbprintList:
- 9e99a48a9960b14926bb7f3b02e22da2b0ab7280
url: oidc.eks.<REGION>.amazonaws.com/id/<UNIQUE_ID>
---
apiVersion: iam.aws.upbound.io/v1beta1
kind: Role
metadata:
name: pod-identity-role
labels:
testing.upbound.io/example-name: pod-identity
spec:
forProvider:
assumeRolePolicy: |
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Principal": {
"Service": "pods.eks.amazonaws.com"
},
"Action": [
"sts:AssumeRole",
"sts:TagSession"
]
Comment on lines +44 to +51
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why are there no conditions in the trust policy? If we're creating an example for others to follow, we should demonstrate best practices, like ensuring that only the specified pods can assume the role. As I read it, this trust policy allows any pod in any EKS cluster in this aws account to assume the role.

Copy link
Member Author

Choose a reason for hiding this comment

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

we don't need any other conditions because you have a pod-identity-association which doing the association between pod identity and this role

Copy link
Member Author

Choose a reason for hiding this comment

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

apiVersion: eks.aws.upbound.io/v1beta1
kind: PodIdentityAssociation
metadata:
  name: example
spec:
  forProvider:
    clusterNameSelector:
      matchLabels:
        testing.upbound.io/example-name: example-cluster
    namespace: crossplane-system
    region: eu-central-1
    roleArnSelector:
      matchLabels:
        testing.upbound.io/example-name: pod-identity
    serviceAccount: provider-aws-xxxxxxxx

}
]
}
Loading