How to use IAM trusted profiles with your Kubernetes service accounts.

Kubernetes service accounts can now apply the trusted profile identity type, similar to federated users. Any pod that uses a Kubernetes service account can get an IAM token for a trusted profile and apply its permissions. This way, applications running inside pods in IBM Cloud containers can access IAM-enabled IBM Cloud services and classic infrastructure resources.

Advantages compared to other methods

Before the ability to get IAM tokens for trusted profiles, pods running on the IBM Cloud Kubernetes Service typically leveraged service IDs and their related API keys to access IBM Cloud services. IAM trusted profiles are offering the following advantages:

  • No credential deployment: To get an IAM token for a service ID, the pod needs to have access to an API key for that service ID. This API key is typically deployed into a Kubernetes secret, which requires a sophisticated and security-sensitive deployment process.
  • No credential rotation: Without the need to deploy a credential, there is also no need to rotate a credential.
  • Auditing: Each retrieval of an IAM token for an IAM trusted profile based on a Kubernetes service account is audited in IBM Cloud Activity Tracker. This gives you a more fine-grained insight into the IAM token retrieval than if you were to use a service ID with an API key. The fields Initiator.id and Initiatior.name hold the details of the profile that is applied. For compute resources, the authnID fields hold the CRN that uniquely identifies the resource that applies a profile.
  • Least privilege: Mapping a Kubernetes service account to an IAM trusted profile gives you the ability to assign the exact level of access to IAM-enabled IBM Cloud services that the pod is required. If another pod requires another level of access, this can be achieved by using a different Kubernetes service account and a different IAM trusted profile.

How to enable your Kubernetes service account for IAM tokens

Step 1: Create a Kubernetes service account

Each Kubernetes pod is using a service account. Any pod that has no specific service account configuration will use the default service account for the Kubernetes namespace. To have better control over the usage of service accounts and how they access IAM trusted profiles, it is recommended to create an explicit service account for your pod. For more information, see Use the Default Service Account to access the API server

$ kubectl create serviceaccount my-sa -n my-namespace

Step 2: Prepare the pod to use the Kubernetes service account

The pod configuration must be updated to explicitly use the service account. To be able to leverage Kubernetes service accounts to get IAM tokens, you must also use the feature Service Account Token Volume Projection. IBM Cloud Kubernetes Service is already enabled for this feature, but you also have to provide additional information for the service account token into your deployment.

Complete Step 1 to correctly mount the service account token into your pod’s file system

The value for expirationSeconds must be not greater than 3600, otherwise IAM will refuse the service account token.

Step 3: Prepare your pod to get an IAM token

There are two methods that, together, generate an IAM token for a service account token. One is a curl command, and the other embeds this curl command into a Kubernetes job. Complete the steps in Configure your application pods to authenticate with IBM Cloud services to successfully get and test an IAM token.

Ready to get started? 

Begin exploring the trusted profiles UI page and the related documentation. In no time, you’ll be ready to create a trusted profile and automatically grant users access to your account with conditions based on SAML attributes from your corporate directory. 

Check out the following tutorial series to help you set up trusted profiles:  

You can also select from the following options to create trusted profiles: 

Was this article helpful?
YesNo

More from Cloud

IBM Tech Now: April 8, 2024

< 1 min read - ​Welcome IBM Tech Now, our video web series featuring the latest and greatest news and announcements in the world of technology. Make sure you subscribe to our YouTube channel to be notified every time a new IBM Tech Now video is published. IBM Tech Now: Episode 96 On this episode, we're covering the following topics: IBM Cloud Logs A collaboration with IBM watsonx.ai and Anaconda IBM offerings in the G2 Spring Reports Stay plugged in You can check out the…

The advantages and disadvantages of private cloud 

6 min read - The popularity of private cloud is growing, primarily driven by the need for greater data security. Across industries like education, retail and government, organizations are choosing private cloud settings to conduct business use cases involving workloads with sensitive information and to comply with data privacy and compliance needs. In a report from Technavio (link resides outside ibm.com), the private cloud services market size is estimated to grow at a CAGR of 26.71% between 2023 and 2028, and it is forecast to increase by…

Optimize observability with IBM Cloud Logs to help improve infrastructure and app performance

5 min read - There is a dilemma facing infrastructure and app performance—as workloads generate an expanding amount of observability data, it puts increased pressure on collection tool abilities to process it all. The resulting data stress becomes expensive to manage and makes it harder to obtain actionable insights from the data itself, making it harder to have fast, effective, and cost-efficient performance management. A recent IDC study found that 57% of large enterprises are either collecting too much or too little observability data.…

IBM Newsletters

Get our newsletters and topic updates that deliver the latest thought leadership and insights on emerging trends.
Subscribe now More newsletters