KOP Recipes - AWS Secrets Manager Configure - Rafay Product Documentation

Configure

In this part, you will


Step 1: Create Secret

In the example below, we have created a secret called "MySecret" in the "us-west-1" AWS region.

You could also create a secret using the AWS CLI.

REGION=us-west-1
CLUSTERNAME=aws-sm-demo

aws --region "$REGION" secretsmanager  create-secret --name MySecret --secret-string '{"username":"rafay", "password":"Rafay$2021"}'

Step 2: IRSA

In this step, you will create an IRSA so that the Nginx pods on the EKS cluster will have the necessary permissions to pull the secret created in Step 1. In AWS, it is a recommended best practice to use IAM roles for service accounts (IRSA) to access AWS services outside the EKS cluster because of the following benefits:

Benefit Description
Least Privilege No longer need to provide extended permissions to the node IAM role so that pods on that node can call AWS APIs. You can scope IAM permissions to a service account, and only pods that use that service account have access to those permissions. This feature also eliminates the need for third-party solutions such as kiam or kube2iam.
Credential Isolation A container can only retrieve credentials for the IAM role that is associated with the service account to which it belongs. A container never has access to credentials that are intended for another container that belongs to another pod.
Auditability Access and event logging is available through CloudTrail to help ensure retrospective auditing.

Create Namespace

We will deploy the Secrets Store CSI Driver and ASCP addon to the "kube-system" namespace. In addition we will deploy our Nginx application to the nginx namespace.


Create IRSA

To create the IRSA we will define a policy that will allow AWS get and describe actions to the secret resource. The AWS secret's ARN will need to be applied to the policy and configured in the Console.

{
    "Version": "2012-10-17",
    "Statement": [ {
        "Effect": "Allow",
        "Action": ["secretsmanager:GetSecretValue", "secretsmanager:DescribeSecret"],
        "Resource": ["arn:aws:secretsmanager:us-west-1:123456789:secret:MySecret-OhnaRe"]
    } ]
}

Verify IRSA

Creation of the IRSA can take a few minutes. You can verify the status of the IRSA by doing the following:

You can also verify that the k8s service account was created in the EKS cluster in the "nginx" namespace.

kubectl get sa -n nginx

NAME                  SECRETS   AGE
default               1         4h1m
nginx-deployment-sa   1         39s

As you can see in this example, the "nginx-deployment-sa" service account was successfully created in the "nginx" namespace.


Next Steps

You are now ready to move on to the next part of the recipe where you will create a workload and access the secrets.