{"id":56941,"date":"2023-03-29T09:30:21","date_gmt":"2023-03-29T04:00:21","guid":{"rendered":"https:\/\/www.tothenew.com\/blog\/?p=56941"},"modified":"2023-04-05T09:36:24","modified_gmt":"2023-04-05T04:06:24","slug":"how-to-access-your-aws-secret-manager-secrets-in-an-eks-cluster","status":"publish","type":"post","link":"https:\/\/www.tothenew.com\/blog\/how-to-access-your-aws-secret-manager-secrets-in-an-eks-cluster\/","title":{"rendered":"How to access your AWS Secret Manager secrets in an EKS cluster"},"content":{"rendered":"<h1>How to access your AWS Secret Manager secrets in an EKS cluster<\/h1>\n<p><span style=\"font-weight: 400;\">This blog will show how we can use AWS secret manager inside AWS EKS pods.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">You all know that almost every application has sensitive data like usernames and passwords. To secure such sensitive data, AWS provides two ways to store and manage application configuration data:<\/span><\/p>\n<ol>\n<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">Secret Manager<\/span><\/li>\n<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">Parameter Store<\/span><\/li>\n<\/ol>\n<p><span style=\"font-weight: 400;\">Both services allow encryption, CloudFormation, and versioning, But Parameter Store is not useful if secrets are centrally managed from another AWS account. If you want encryption, key rotation, and cross-account access of secrets, then you can go with AWS Secret Manager.<\/span><span style=\"font-weight: 400;\">\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0\u00a0<\/span><\/p>\n<p><b>Flow Diagram\u00a0<\/b><\/p>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-full wp-image-56950\" src=\"\/blog\/wp-ttn-blog\/uploads\/2023\/03\/1.1.png\" alt=\"\" width=\"802\" height=\"457\" srcset=\"\/blog\/wp-ttn-blog\/uploads\/2023\/03\/1.1.png 802w, \/blog\/wp-ttn-blog\/uploads\/2023\/03\/1.1-300x171.png 300w, \/blog\/wp-ttn-blog\/uploads\/2023\/03\/1.1-768x438.png 768w, \/blog\/wp-ttn-blog\/uploads\/2023\/03\/1.1-624x356.png 624w\" sizes=\"(max-width: 802px) 100vw, 802px\" \/><\/p>\n<ol>\n<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">The user makes a pod creation request to API server\u00a0<\/span><\/li>\n<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">API Server requests Pod Scheduler in Control Plan to Schedule Pod to Node<\/span><\/li>\n<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">Kubelet running on the node gets the request to create a pod. Kubelet scans the pod manifest file and finds the volume to be mounted using the CSI driver and calls the Secret CSI driver to mount the volume in the pod.<\/span><\/li>\n<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">Then CSI Driver invokes the ASCP (AWS Secrets and Config Providers) to call Secrets Managers to get the secrets by API Call and ACSP uses the SecretProviderClass manifest file to find which secrets to be loaded and create the secrets files in the mounted volume.<\/span><\/li>\n<\/ol>\n<p><b>Prerequisites\u00a0<\/b><\/p>\n<ul>\n<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">Existing EKS Cluster\u00a0<\/span><\/li>\n<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">Your secret is stored in the secret manager<\/span><\/li>\n<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">AWS CLI, eksctl, helm, and kubectl installed<\/span><\/li>\n<\/ul>\n<p><b>Setup Guide<\/b><\/p>\n<ul>\n<li><b>Install CSI Driver\u00a0\u00a0<\/b><\/li>\n<\/ul>\n<table style=\"height: 252px;\" width=\"846\">\n<tbody>\n<tr>\n<td><b> helm repo add secrets-store-csi-driver \\<\/b><\/p>\n<p><b>\u00a0\u00a0https:\/\/kubernetes-sigs.github.io\/secrets-store-csi-driver\/charts<\/b><\/p>\n<p><b>helm install -n kube-system csi-secrets-store \\<\/b><\/p>\n<p><b>\u00a0\u00a0&#8211;set syncSecret.enabled=true \\<\/b><\/p>\n<p><b>\u00a0\u00a0&#8211;set enableSecretRotation=true \\<\/b><\/p>\n<p><b>\u00a0\u00a0secrets-store-csi-driver\/secrets-store-csi-driverAA<\/b><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>&nbsp;<\/p>\n<ul>\n<li><b>Install ASCP Plugin<\/b><\/li>\n<\/ul>\n<table style=\"height: 42px;\" width=\"958\">\n<tbody>\n<tr>\n<td><b>kubectl apply -f https:\/\/raw.githubusercontent.com\/aws\/secrets-store-csi-driver-provider-aws\/main\/deployment\/aws-provider-installer.yaml<\/b><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>&nbsp;<\/p>\n<ul>\n<li><b>Check the DaemonSet for ASCP and CSI Driver in Kube-system Namespace<\/b><\/li>\n<\/ul>\n<p><b>\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0Note<\/b><b>: <\/b><span style=\"font-weight: 400;\">Above two steps will deploy the daemon set for ASCP and CSI Driver<\/span><\/p>\n<p><span style=\"font-weight: 400;\">\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 To check the ASCP daemon set:<\/span><\/p>\n<table style=\"height: 22px;\" width=\"827\">\n<tbody>\n<tr>\n<td><b>kubectl get daemonsets -n kube-system -l app=csi-secrets-store-provider-aws<\/b><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p><span style=\"font-weight: 400;\">\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 To check the CSI Driver daemon set:<\/span><\/p>\n<table style=\"height: 15px;\" width=\"827\">\n<tbody>\n<tr>\n<td><b>kubectl get daemonsets -n kube-system -l app.kubernetes.io\/instance=csi-secrets-Astore<\/b><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>&nbsp;<\/p>\n<ul>\n<li><b>Create an AWS Secret Manager and Note down Secret arn<\/b><\/li>\n<\/ul>\n<table style=\"height: 129px;\" width=\"835\">\n<tbody>\n<tr>\n<td><b>aws &#8211;region &#8220;us-east-1&#8221; secretsmanager \\<\/b><\/p>\n<p><b>\u00a0\u00a0create-secret &#8211;name test-ritika \\Create an AWS Secret Manager and Note down Secret arn<\/b><\/p>\n<p><b>\u00a0\u00a0&#8211;secret-string &#8216;{&#8220;username&#8221;:&#8221;foo&#8221;, &#8220;url&#8221;:&#8221;hello.com&#8221;}&#8217;<\/b><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>&nbsp;<\/p>\n<ul>\n<li><b>Create an IAM policy\u00a0<\/b><\/li>\n<\/ul>\n<p><span style=\"font-weight: 400;\">This policy will be attached to Kubernetes Service Account to allow access to Secret Manager. In place of the red highlighted part below, give the Secret ARN that we have just created.<\/span><\/p>\n<table style=\"height: 586px;\" width=\"843\">\n<tbody>\n<tr>\n<td><b>{Create an IAM policy\u00a0<\/b><\/p>\n<p><b>\u00a0\u00a0\u00a0\u00a0&#8220;Version&#8221;: &#8220;2012-10-17&#8221;,<\/b><\/p>\n<p><b>\u00a0\u00a0\u00a0\u00a0&#8220;Statement&#8221;: [<\/b><\/p>\n<p><b>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0{<\/b><\/p>\n<p><b>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0&#8220;Sid&#8221;: &#8220;&#8221;,<\/b><\/p>\n<p><b>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0&#8220;Effect&#8221;: &#8220;Allow&#8221;,<\/b><\/p>\n<p><b>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0&#8220;Action&#8221;: [<\/b><\/p>\n<p><b>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0&#8220;secretsmanager:GetSecretValue&#8221;,<\/b><\/p>\n<p><b>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0&#8220;secretsmanager:DescribeSecret&#8221;<\/b><\/p>\n<p><b>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0],<\/b><\/p>\n<p><b>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0&#8220;Resource&#8221;: &#8220;<\/b><b>SECRET_ARN<\/b><b>&#8221;\u00a0<\/b><\/p>\n<p><b>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0}<\/b><\/p>\n<p><b>\u00a0\u00a0\u00a0\u00a0]<\/b><\/p>\n<p><b>}<\/b><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>&nbsp;<\/p>\n<ul>\n<li><b>Create a Service Account and attach the above policy\u00a0<\/b><\/li>\n<\/ul>\n<p><span style=\"font-weight: 400;\">This Service Account gives your pods access to the Secret Manager with the previously created policy. Provide any name for your service account and add your policy arn in place of \u201cIAM_POLICY_ARN_SECRET\u201d.\u00a0<\/span><\/p>\n<table style=\"height: 231px;\" width=\"876\">\n<tbody>\n<tr>\n<td><span style=\"font-weight: 400;\">eksctl create iamserviceaccount \\<\/span><\/p>\n<p><span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0&#8211;region=&#8221;$AWS_REGION&#8221; &#8211;name &#8220;<\/span><span style=\"font-weight: 400;\">$ServiceAccountName<\/span><span style=\"font-weight: 400;\">&#8221;\u00a0 \\<\/span><\/p>\n<p><span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0&#8211;cluster &#8220;$EKS_CLUSTERNAME&#8221; \\<\/span><\/p>\n<p><span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0&#8211;attach-policy-arn &#8220;<\/span><span style=\"font-weight: 400;\">$IAM_POLICY_ARN_SECRET<\/span><span style=\"font-weight: 400;\">&#8221; &#8211;approve \\<\/span><\/p>\n<p><span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0&#8211;override-existing-serviceaccounts<\/span><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p><b>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<\/b><b>OR<\/b><\/p>\n<table style=\"height: 275px;\" width=\"881\">\n<tbody>\n<tr>\n<td><span style=\"font-weight: 400;\">apiVersion: v1Create an IAM policy\u00a0<\/span><\/p>\n<p><span style=\"font-weight: 400;\">kind: ServiceAccount<\/span><\/p>\n<p><span style=\"font-weight: 400;\">metadata:<\/span><\/p>\n<p><span style=\"font-weight: 400;\">\u00a0\u00a0name:<\/span> <span style=\"font-weight: 400;\">$ServiceAccountName<\/span><\/p>\n<p><span style=\"font-weight: 400;\">\u00a0\u00a0annotations:<\/span><\/p>\n<p><span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0eks.amazonaws.com\/role-arn:<\/span> <span style=\"font-weight: 400;\">$IAM_POLICY_ARN_SECRET<\/span><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"alignnone wp-image-56953\" src=\"\/blog\/wp-ttn-blog\/uploads\/2023\/03\/1.2.2.png\" alt=\"\" width=\"738\" height=\"122\" srcset=\"\/blog\/wp-ttn-blog\/uploads\/2023\/03\/1.2.2.png 647w, \/blog\/wp-ttn-blog\/uploads\/2023\/03\/1.2.2-300x50.png 300w, \/blog\/wp-ttn-blog\/uploads\/2023\/03\/1.2.2-624x103.png 624w\" sizes=\"(max-width: 738px) 100vw, 738px\" \/><\/p>\n<ul>\n<li><b>Create SecretProviderClass\u00a0<\/b><\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<p><span style=\"font-weight: 400;\">ASCP uses the below SecretProviderClass manifest file to find which secrets to be loaded and creates the secrets files in the mounted volume. <\/span><span style=\"font-weight: 400;\">To use ASCP, we create Secret Provider Class to provide a few more details of how we will retrieve the secrets from AWS Secret Manager or Parameter Store.\u00a0<\/span><\/p>\n<p><span style=\"font-weight: 400;\"><strong>Note:<\/strong> The Secret Provider Class must be in the same namespace as the pod referencing it. You can pass the namespace under the metadata block.<\/span><\/p>\n<p><b>SecretProviderClass.yaml<\/b><span style=\"font-weight: 400;\">:<\/span><\/p>\n<p><span style=\"font-weight: 400;\">[Note: Follow the below indentation as shown in the image.]<\/span><img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-full wp-image-56954\" src=\"\/blog\/wp-ttn-blog\/uploads\/2023\/03\/1.3.png\" alt=\"\" width=\"702\" height=\"436\" srcset=\"\/blog\/wp-ttn-blog\/uploads\/2023\/03\/1.3.png 702w, \/blog\/wp-ttn-blog\/uploads\/2023\/03\/1.3-300x186.png 300w, \/blog\/wp-ttn-blog\/uploads\/2023\/03\/1.3-624x388.png 624w\" sizes=\"(max-width: 702px) 100vw, 702px\" \/><\/p>\n<p><span style=\"font-weight: 400;\">Apply the below command to create secretproviderclass.<\/span><\/p>\n<table style=\"height: 21px;\" width=\"822\">\n<tbody>\n<tr>\n<td><span style=\"font-weight: 400;\">kubectl apply -f <\/span><span style=\"font-weight: 400;\">SecretProviderClass.yaml<\/span><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p><span style=\"font-weight: 400;\">The output indicates the resource (spa) was created successfully.<\/span><\/p>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-full wp-image-56955\" src=\"\/blog\/wp-ttn-blog\/uploads\/2023\/03\/1.4.png\" alt=\"\" width=\"660\" height=\"206\" srcset=\"\/blog\/wp-ttn-blog\/uploads\/2023\/03\/1.4.png 660w, \/blog\/wp-ttn-blog\/uploads\/2023\/03\/1.4-300x94.png 300w, \/blog\/wp-ttn-blog\/uploads\/2023\/03\/1.4-624x195.png 624w\" sizes=\"(max-width: 660px) 100vw, 660px\" \/><\/p>\n<table style=\"height: 1020px;\" width=\"825\">\n<tbody>\n<tr>\n<td><span style=\"font-weight: 400;\">apiVersion: secrets-store.csi.x-k8s.io\/v1<\/span><\/p>\n<p><span style=\"font-weight: 400;\">kind: SecretProviderClass<\/span><\/p>\n<p><span style=\"font-weight: 400;\">metadata:<\/span><\/p>\n<p><span style=\"font-weight: 400;\">\u00a0\u00a0name: spc<\/span><\/p>\n<p><span style=\"font-weight: 400;\">spec:<\/span><\/p>\n<p><span style=\"font-weight: 400;\">\u00a0\u00a0provider: aws<\/span><\/p>\n<p><span style=\"font-weight: 400;\">\u00a0\u00a0parameters:<\/span><\/p>\n<p><span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0objects: |<\/span><\/p>\n<p><span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0&#8211; objectName: &#8220;test-ritika&#8221;<\/span><\/p>\n<p><span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0objectType: &#8220;secretsmanager&#8221;<\/span><\/p>\n<p><span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0jmesPath:<\/span><\/p>\n<p><span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0&#8211; path: username<\/span><\/p>\n<p><span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0objectAlias: <\/span><b>dbusername<\/b><\/p>\n<p><span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0&#8211; path: url<\/span><\/p>\n<p><span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0objectAlias: <\/span><b>db_url<\/b><\/p>\n<p><span style=\"font-weight: 400;\">\u00a0\u00a0# Create k8s secret. It requires volume mount first in the pod and then sync.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">\u00a0\u00a0secretObjects:<\/span><\/p>\n<p><span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0&#8211; secretName: secrets<\/span><\/p>\n<p><span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0type: Opaque<\/span><\/p>\n<p><span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0data:<\/span><\/p>\n<p><span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0#- objectName: &lt;objectName&gt; or &lt;objectAlias&gt;<\/span><\/p>\n<p><span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0&#8211; objectName: <\/span><b>dbusername<\/b><\/p>\n<p><span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0key: username<\/span><\/p>\n<p><span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0&#8211; objectName: <\/span><b>db_url<\/b><\/p>\n<p><span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0Key: password<\/span><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>&nbsp;<\/p>\n<ul>\n<li><b>spc<\/b><b>: <\/b><span style=\"font-weight: 400;\">name for a secret provider class\u00a0<\/span><\/li>\n<li><b>aws: <\/b><span style=\"font-weight: 400;\">name of cloud provider\u00a0<\/span><\/li>\n<li><b>test-ritika<\/b><b>: <\/b><span style=\"font-weight: 400;\">name of aws secret manager\u00a0<\/span><\/li>\n<li><b>secretsmanager: <\/b><span style=\"font-weight: 400;\">name of secret store aws service\u00a0<\/span><\/li>\n<li><b>username,url: <\/b><span style=\"font-weight: 400;\">name of secret manager variables which you want to store in a pod as an env variable<\/span><\/li>\n<li><b>dbusername,db_url: <\/b><span style=\"font-weight: 400;\">alias name for secret manager variable through which we can call env variable in pod.\u00a0<\/span><\/li>\n<li><b>secrets: <\/b><span style=\"font-weight: 400;\">name of k8s secrets, this will CSI driver automatically create after applying deployment.yaml<\/span><\/li>\n<li><span style=\"font-weight: 400;\">Under data block: <\/span><b>dbusername: <\/b>Alias name\u00a0 and\u00a0\u00a0<b>username: <\/b>key name of secrets<b>Create Deployment manifest :<\/b><\/li>\n<\/ul>\n<table style=\"height: 2372px;\" width=\"847\">\n<tbody>\n<tr>\n<td><span style=\"font-weight: 400;\">kind: Service<\/span><\/p>\n<p><span style=\"font-weight: 400;\">apiVersion: v1Create Deployment manifest :<\/span><\/p>\n<p><span style=\"font-weight: 400;\">metadata:<\/span><\/p>\n<p><span style=\"font-weight: 400;\">\u00a0\u00a0name: nginx-deployment<\/span><\/p>\n<p><span style=\"font-weight: 400;\">\u00a0\u00a0labels:<\/span><\/p>\n<p><span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0app: nginx<\/span><\/p>\n<p><span style=\"font-weight: 400;\">spec:<\/span><\/p>\n<p><span style=\"font-weight: 400;\">\u00a0\u00a0selector:<\/span><\/p>\n<p><span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0app: nginx<\/span><\/p>\n<p><span style=\"font-weight: 400;\">\u00a0\u00a0ports:<\/span><\/p>\n<p><span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0&#8211; protocol: TCP<\/span><\/p>\n<p><span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0port: 80<\/span><\/p>\n<p><span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0targetPort: 80<\/span><\/p>\n<p><span style=\"font-weight: 400;\">&#8212;<\/span><\/p>\n<p><span style=\"font-weight: 400;\">apiVersion: apps\/v1<\/span><\/p>\n<p><span style=\"font-weight: 400;\">kind: Deployment<\/span><\/p>\n<p><span style=\"font-weight: 400;\">metadata:<\/span><\/p>\n<p><span style=\"font-weight: 400;\">\u00a0\u00a0name: nginx-deployment<\/span><\/p>\n<p><span style=\"font-weight: 400;\">\u00a0\u00a0labels:<\/span><\/p>\n<p><span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0app: nginx<\/span><\/p>\n<p><span style=\"font-weight: 400;\">spec:<\/span><\/p>\n<p><span style=\"font-weight: 400;\">\u00a0\u00a0replicas: 1<\/span><\/p>\n<p><span style=\"font-weight: 400;\">\u00a0\u00a0selector:<\/span><\/p>\n<p><span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0matchLabels:<\/span><\/p>\n<p><span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0app: nginx<\/span><\/p>\n<p><span style=\"font-weight: 400;\">\u00a0\u00a0template:<\/span><\/p>\n<p><span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0metadata:<\/span><\/p>\n<p><span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0labels:<\/span><\/p>\n<p><span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0app: nginx<\/span><\/p>\n<p><span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0spec:<\/span><\/p>\n<p><span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0serviceAccountName: <\/span><span style=\"font-weight: 400;\">$ServiceAccountName<\/span><\/p>\n<p><span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0volumes:<\/span><\/p>\n<p><span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0&#8211; name: secrets-store-inline<\/span><\/p>\n<p><span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0csi:<\/span><\/p>\n<p><span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0driver: secrets-store.csi.k8s.io<\/span><\/p>\n<p><span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0readOnly: true<\/span><\/p>\n<p><span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0volumeAttributes:<\/span><\/p>\n<p><span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0secretProviderClass: &#8220;spc&#8221;<\/span><\/p>\n<p><span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0containers:<\/span><\/p>\n<p><span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0&#8211; name: nginx-deployment<\/span><\/p>\n<p><span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0image: nginx<\/span><\/p>\n<p><span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0ports:<\/span><\/p>\n<p><span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0&#8211; containerPort: 80<\/span><\/p>\n<p><span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0volumeMounts:<\/span><\/p>\n<p><span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0&#8211; name: secrets-store-inline<\/span><\/p>\n<p><span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0mountPath: &#8220;\/mnt\/secrets-store&#8221;<\/span><\/p>\n<p><span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0readOnly: true<\/span><\/p>\n<p><span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0env:<\/span><\/p>\n<p><span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0&#8211; name: rds_user<\/span><\/p>\n<p><span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0valueFrom:<\/span><\/p>\n<p><span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0secretKeyRef:<\/span><\/p>\n<p><span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0name: secrets<\/span><\/p>\n<p><span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0key: username<\/span><\/p>\n<p><span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0&#8211; name: rds_url<\/span><\/p>\n<p><span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0valueFrom:<\/span><\/p>\n<p><span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0secretKeyRef:<\/span><\/p>\n<p><span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0name: secrets<\/span><\/p>\n<p><span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0key: password<\/span><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p><span style=\"font-weight: 400;\">Create a pod with the below command\u00a0<\/span><\/p>\n<table style=\"height: 135px;\" width=\"822\">\n<tbody>\n<tr>\n<td><span style=\"font-weight: 400;\">kubectl apply -f <\/span><span style=\"font-weight: 400;\">deployment.yaml<\/span><\/p>\n<p><span style=\"font-weight: 400;\">kubectl get pods<\/span><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-full wp-image-56956\" src=\"\/blog\/wp-ttn-blog\/uploads\/2023\/03\/1.5.png\" alt=\"\" width=\"684\" height=\"83\" srcset=\"\/blog\/wp-ttn-blog\/uploads\/2023\/03\/1.5.png 684w, \/blog\/wp-ttn-blog\/uploads\/2023\/03\/1.5-300x36.png 300w, \/blog\/wp-ttn-blog\/uploads\/2023\/03\/1.5-624x76.png 624w\" sizes=\"(max-width: 684px) 100vw, 684px\" \/><\/p>\n<ul>\n<li><b>After applying the above manifest, we should be able to get our AWS Secrets\u2019 content directly from env var rds_username and rds_url:<\/b><\/li>\n<\/ul>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-full wp-image-56957\" src=\"\/blog\/wp-ttn-blog\/uploads\/2023\/03\/1.7.png\" alt=\"\" width=\"691\" height=\"113\" srcset=\"\/blog\/wp-ttn-blog\/uploads\/2023\/03\/1.7.png 691w, \/blog\/wp-ttn-blog\/uploads\/2023\/03\/1.7-300x49.png 300w, \/blog\/wp-ttn-blog\/uploads\/2023\/03\/1.7-624x102.png 624w\" sizes=\"(max-width: 691px) 100vw, 691px\" \/><\/p>\n<table style=\"height: 89px;\" width=\"847\">\n<tbody>\n<tr>\n<td><span style=\"font-weight: 400;\">kubectl exec -it &lt;NAME OF THE POD&gt; &#8212; env | grep rds_username<\/span><\/p>\n<p><span style=\"font-weight: 400;\">kubectl exec -it &lt;NAME OF THE POD&gt; &#8212; env | grep rds_url<\/span><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>&nbsp;<\/p>\n<div class=\"ap-custom-wrapper\"><\/div><!--ap-custom-wrapper-->","protected":false},"excerpt":{"rendered":"<p>How to access your AWS Secret Manager secrets in an EKS cluster This blog will show how we can use AWS secret manager inside AWS EKS pods. You all know that almost every application has sensitive data like usernames and passwords. To secure such sensitive data, AWS provides two ways to store and manage application [&hellip;]<\/p>\n","protected":false},"author":1435,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"iawp_total_views":165},"categories":[4308,2348],"tags":[],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/posts\/56941"}],"collection":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/users\/1435"}],"replies":[{"embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/comments?post=56941"}],"version-history":[{"count":8,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/posts\/56941\/revisions"}],"predecessor-version":[{"id":57050,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/posts\/56941\/revisions\/57050"}],"wp:attachment":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/media?parent=56941"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/categories?post=56941"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/tags?post=56941"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}