{"id":73253,"date":"2025-08-27T12:54:32","date_gmt":"2025-08-27T07:24:32","guid":{"rendered":"https:\/\/www.tothenew.com\/blog\/?p=73253"},"modified":"2025-08-27T15:47:06","modified_gmt":"2025-08-27T10:17:06","slug":"guide-to-using-secret-manager-with-gke-csi-driver","status":"publish","type":"post","link":"https:\/\/www.tothenew.com\/blog\/guide-to-using-secret-manager-with-gke-csi-driver\/","title":{"rendered":"A Step-by-Step Guide to Using Secret Manager with GKE and CSI Driver"},"content":{"rendered":"<p><span style=\"text-decoration: underline;\"><strong>Introduction<\/strong><\/span><strong>\u00a0<\/strong><\/p>\n<p>Management of sensitive information such as API keys, credentials and configuration secrets are an important part of developing safe and reliable Skylands applications. In Google Cloud Ecosystem, Secret Manager provides a centralized and safe way to save, access and manage these secrets.When running applications on Google Kubernetes Engine (GKE), including Secret Manager guarantees that your workloads are able to access secrets securely without having to hard-code them into your containers or codebase.<\/p>\n<p><strong><span style=\"text-decoration: underline;\">Objective<\/span> :-<\/strong><\/p>\n<p>The objective of this blog is to provide a comprehensive guide on implementing the secret manager using the GCP Key Vault Provider for Secrets Store Container Storage Interface (CSI) Driver within an Google Kubernetes Engine (GKE) cluster. Through this blog we will understand the integration of secret managers in Google Kubernetes Engine by securely managing and accessing the sensitive information , such as secret and credentials in GKE.<\/p>\n<p>&nbsp;<\/p>\n<div id=\"attachment_73783\" style=\"width: 635px\" class=\"wp-caption aligncenter\"><img aria-describedby=\"caption-attachment-73783\" decoding=\"async\" loading=\"lazy\" class=\"size-large wp-image-73783\" src=\"https:\/\/www.tothenew.com\/blog\/wp-ttn-blog\/uploads\/2025\/07\/Screenshot-2025-07-31-at-3.08.27\u202fPM-1024x367.png\" alt=\"Managing secrets through secret manager\" width=\"625\" height=\"224\" srcset=\"\/blog\/wp-ttn-blog\/uploads\/2025\/07\/Screenshot-2025-07-31-at-3.08.27\u202fPM-1024x367.png 1024w, \/blog\/wp-ttn-blog\/uploads\/2025\/07\/Screenshot-2025-07-31-at-3.08.27\u202fPM-300x108.png 300w, \/blog\/wp-ttn-blog\/uploads\/2025\/07\/Screenshot-2025-07-31-at-3.08.27\u202fPM-768x275.png 768w, \/blog\/wp-ttn-blog\/uploads\/2025\/07\/Screenshot-2025-07-31-at-3.08.27\u202fPM-1536x551.png 1536w, \/blog\/wp-ttn-blog\/uploads\/2025\/07\/Screenshot-2025-07-31-at-3.08.27\u202fPM-624x224.png 624w, \/blog\/wp-ttn-blog\/uploads\/2025\/07\/Screenshot-2025-07-31-at-3.08.27\u202fPM.png 1958w\" sizes=\"(max-width: 625px) 100vw, 625px\" \/><p id=\"caption-attachment-73783\" class=\"wp-caption-text\">Managing secrets through secret manager<\/p><\/div>\n<p>&nbsp;<\/p>\n<p><span style=\"text-decoration: underline;\"><strong>What is Secret Manager ?<\/strong><\/span><\/p>\n<p>Secret Manager is a secure and centralized service on Google Cloud designed to store sensitive information such as API keys, passwords, and certificates. It simplifies the management, access, and auditing of secrets across your cloud environment, helping you keep critical data safe and organized.<\/p>\n<p><span style=\"text-decoration: underline;\"><strong>Why to use secret manager ?<\/strong><\/span><\/p>\n<p><strong>1. Security :<\/strong> Secrets are encrypted at rest using Google-managed or customer-managed keys (CMEK).<br \/>\n<strong>2. Centralised Secret Management :<\/strong> Google Cloud Secret Manager securely and centrally stores secrets.<br \/>\n<strong>3. Workload Identity-Based Access Control :<\/strong> GKE workloads can access secrets securely without service account keys using Workload Identity.<br \/>\n<strong>4. Versioning &amp; Rotation :<\/strong> It has versioning, so you are able to update and roll back securely.<br \/>\n<strong>5. Integration with CI\/CD Pipelines :<\/strong> Seamlessly integrates with Cloud Build, GitHub Actions, or other CI\/CD to inject secrets during deployment or build.<\/p>\n<p><span style=\"text-decoration: underline;\"><strong>Secret manager Setup<\/strong><\/span><strong> :-<\/strong><\/p>\n<p><strong>1. Create a gke cluster :-<\/strong> Create gke cluster either via console , terraform or by cli.<\/p>\n<div id=\"attachment_72660\" style=\"width: 635px\" class=\"wp-caption alignnone\"><img aria-describedby=\"caption-attachment-72660\" decoding=\"async\" loading=\"lazy\" class=\"size-large wp-image-72660\" src=\"https:\/\/www.tothenew.com\/blog\/wp-ttn-blog\/uploads\/2025\/06\/Screenshot-from-2025-06-09-12-11-05-1024x571.png\" alt=\"Cluster creation\" width=\"625\" height=\"349\" srcset=\"\/blog\/wp-ttn-blog\/uploads\/2025\/06\/Screenshot-from-2025-06-09-12-11-05-1024x571.png 1024w, \/blog\/wp-ttn-blog\/uploads\/2025\/06\/Screenshot-from-2025-06-09-12-11-05-300x167.png 300w, \/blog\/wp-ttn-blog\/uploads\/2025\/06\/Screenshot-from-2025-06-09-12-11-05-768x428.png 768w, \/blog\/wp-ttn-blog\/uploads\/2025\/06\/Screenshot-from-2025-06-09-12-11-05-1536x856.png 1536w, \/blog\/wp-ttn-blog\/uploads\/2025\/06\/Screenshot-from-2025-06-09-12-11-05-624x348.png 624w, \/blog\/wp-ttn-blog\/uploads\/2025\/06\/Screenshot-from-2025-06-09-12-11-05.png 1726w\" sizes=\"(max-width: 625px) 100vw, 625px\" \/><p id=\"caption-attachment-72660\" class=\"wp-caption-text\">GKE Cluster<\/p><\/div>\n<p>&nbsp;<\/p>\n<p><strong>2. Turn on the secret manager add-on :- <\/strong>Be sure to activate the secret manager add-on when setting up a GKE cluster.Access the secrets kept in Secret Manager as volumes are mounted in Kubernetes pods by using the Secret Manager add-on.<\/p>\n<div id=\"attachment_72671\" style=\"width: 635px\" class=\"wp-caption alignnone\"><img aria-describedby=\"caption-attachment-72671\" decoding=\"async\" loading=\"lazy\" class=\"size-large wp-image-72671\" src=\"https:\/\/www.tothenew.com\/blog\/wp-ttn-blog\/uploads\/2025\/06\/Screenshot-from-2025-05-28-16-14-27-1-1024x571.png\" alt=\"GKE Cluster add-on\" width=\"625\" height=\"349\" srcset=\"\/blog\/wp-ttn-blog\/uploads\/2025\/06\/Screenshot-from-2025-05-28-16-14-27-1-1024x571.png 1024w, \/blog\/wp-ttn-blog\/uploads\/2025\/06\/Screenshot-from-2025-05-28-16-14-27-1-300x167.png 300w, \/blog\/wp-ttn-blog\/uploads\/2025\/06\/Screenshot-from-2025-05-28-16-14-27-1-768x428.png 768w, \/blog\/wp-ttn-blog\/uploads\/2025\/06\/Screenshot-from-2025-05-28-16-14-27-1-1536x856.png 1536w, \/blog\/wp-ttn-blog\/uploads\/2025\/06\/Screenshot-from-2025-05-28-16-14-27-1-624x348.png 624w, \/blog\/wp-ttn-blog\/uploads\/2025\/06\/Screenshot-from-2025-05-28-16-14-27-1.png 1845w\" sizes=\"(max-width: 625px) 100vw, 625px\" \/><p id=\"caption-attachment-72671\" class=\"wp-caption-text\">GKE Cluster add-ons<\/p><\/div>\n<p><strong>3. Verify that after enabling the secret manager add-on Secrets Store CSI Driver installation :-<\/strong> Verify the installation is finished using the kubectl get pods command, which lists all pods with the csi-\u00a0 secrets-store-gke and csi-secrets-store-provider-gke labels in the kube-system\u00a0 namespace.<\/p>\n<div id=\"attachment_72665\" style=\"width: 896px\" class=\"wp-caption alignnone\"><img aria-describedby=\"caption-attachment-72665\" decoding=\"async\" loading=\"lazy\" class=\"size-full wp-image-72665\" src=\"https:\/\/www.tothenew.com\/blog\/wp-ttn-blog\/uploads\/2025\/06\/Screenshot-from-2025-05-28-16-27-40.png\" alt=\"CSI Secret Pods\" width=\"886\" height=\"108\" srcset=\"\/blog\/wp-ttn-blog\/uploads\/2025\/06\/Screenshot-from-2025-05-28-16-27-40.png 886w, \/blog\/wp-ttn-blog\/uploads\/2025\/06\/Screenshot-from-2025-05-28-16-27-40-300x37.png 300w, \/blog\/wp-ttn-blog\/uploads\/2025\/06\/Screenshot-from-2025-05-28-16-27-40-768x94.png 768w, \/blog\/wp-ttn-blog\/uploads\/2025\/06\/Screenshot-from-2025-05-28-16-27-40-624x76.png 624w\" sizes=\"(max-width: 886px) 100vw, 886px\" \/><p id=\"caption-attachment-72665\" class=\"wp-caption-text\">CSI Secret Pods<\/p><\/div>\n<p><strong>4. Create secrets in a secret manager :-<\/strong> A Secret Manager was created using the GCP Console to guard against unwanted access and safely store private information like passwords and API keys. To effectively handle updates and preserve a safe history of modifications, secret versions are made.<\/p>\n<div id=\"attachment_73760\" style=\"width: 978px\" class=\"wp-caption alignnone\"><img aria-describedby=\"caption-attachment-73760\" decoding=\"async\" loading=\"lazy\" class=\"size-full wp-image-73760\" src=\"https:\/\/www.tothenew.com\/blog\/wp-ttn-blog\/uploads\/2025\/07\/Screenshot-2025-07-31-at-12.14.05\u202fPM.png\" alt=\"Secrets in secret manager\" width=\"968\" height=\"398\" srcset=\"\/blog\/wp-ttn-blog\/uploads\/2025\/07\/Screenshot-2025-07-31-at-12.14.05\u202fPM.png 968w, \/blog\/wp-ttn-blog\/uploads\/2025\/07\/Screenshot-2025-07-31-at-12.14.05\u202fPM-300x123.png 300w, \/blog\/wp-ttn-blog\/uploads\/2025\/07\/Screenshot-2025-07-31-at-12.14.05\u202fPM-768x316.png 768w, \/blog\/wp-ttn-blog\/uploads\/2025\/07\/Screenshot-2025-07-31-at-12.14.05\u202fPM-624x257.png 624w\" sizes=\"(max-width: 968px) 100vw, 968px\" \/><p id=\"caption-attachment-73760\" class=\"wp-caption-text\">Secrets in secret manager<\/p><\/div>\n<div id=\"attachment_73763\" style=\"width: 986px\" class=\"wp-caption alignnone\"><img aria-describedby=\"caption-attachment-73763\" decoding=\"async\" loading=\"lazy\" class=\"size-full wp-image-73763\" src=\"https:\/\/www.tothenew.com\/blog\/wp-ttn-blog\/uploads\/2025\/07\/Screenshot-2025-07-31-at-12.18.28\u202fPM.png\" alt=\"Secret Version\" width=\"976\" height=\"376\" srcset=\"\/blog\/wp-ttn-blog\/uploads\/2025\/07\/Screenshot-2025-07-31-at-12.18.28\u202fPM.png 976w, \/blog\/wp-ttn-blog\/uploads\/2025\/07\/Screenshot-2025-07-31-at-12.18.28\u202fPM-300x116.png 300w, \/blog\/wp-ttn-blog\/uploads\/2025\/07\/Screenshot-2025-07-31-at-12.18.28\u202fPM-768x296.png 768w, \/blog\/wp-ttn-blog\/uploads\/2025\/07\/Screenshot-2025-07-31-at-12.18.28\u202fPM-624x240.png 624w\" sizes=\"(max-width: 976px) 100vw, 976px\" \/><p id=\"caption-attachment-73763\" class=\"wp-caption-text\">Secret Version<\/p><\/div>\n<p><strong>5.Create a Secret Provider Class :-<\/strong> To specify how secrets from the secret manager are accessed and mounted into your Kubernetes pods, create a SecretProviderClass using the YAML below.<\/p>\n<pre><strong>Secretproviderclass.yaml :-<\/strong>\r\n\r\napiVersion: secrets-store.csi.x-k8s.io\/v1\r\nkind: SecretProviderClass\r\nmetadata:\r\nname: dev-secret-provider\r\nnamespace: dev\r\nspec:\r\nprovider: gke\r\nparameters:\r\nsecrets: |\r\n- resourceName: \"projects\/954514138689\/secrets\/DB_USER\/versions\/1\"\r\nfileName: \"DB_USER\"\r\n- resourceName: \"projects\/954514138689\/secrets\/DB_PASSWORD\/versions\/1\"\r\nfileName: \"DB_PASSWORD\"\r\n\r\nsecretObjects:\r\n- secretName: dev-secrets\r\ntype: Opaque\r\ndata:\r\n- objectName: \"DB_USER\"\r\nkey: \"DB_USER\"\r\n- objectName: \"DB_PASSWORD\"\r\nkey: \"DB_PASSWORD\"<\/pre>\n<p><strong>6. Apply the SecretProviderClass YAML : &#8211;<\/strong> Apply the SecretProviderClass YAML using the following command in GKE.<\/p>\n<pre>kubectl apply -f secretproviderclass.yaml<\/pre>\n<p><strong><em>Note :- <\/em><\/strong><br \/>\n<em> 1.No need to create k8s secret object separately. It will be created automatically when you create a pod with CSI driver volume. <\/em><br \/>\n<em>2.The secretObjects block in the above YAML is optional and is only needed if you need to synchronize mounted content with a Kubernetes secret. You will still get the secret manager object mounted to the pod if you do not use this block.<\/em><\/p>\n<p><strong>6. Give permission to the CSI driver : &#8211; <\/strong>Give permission to CSI driver secret store to use cluster roles and cluster role binding to generate GKE secrets.<\/p>\n<pre><strong>Secret-store-rbac.yaml:-<\/strong>\r\n\r\napiVersion: rbac.authorization.k8s.io\/v1\r\nkind: ClusterRole\r\nmetadata:\r\nname: secrets-store-csi-secrets-access\r\nrules:\r\n- apiGroups: [\"\"]\r\n\u00a0 resources: [\"secrets\"]\r\n\u00a0 verbs: [\"get\", \"list\", \"watch\", \"create\", \"patch\"]\r\n\r\n---\r\napiVersion: rbac.authorization.k8s.io\/v1\r\nkind: ClusterRoleBinding\r\nmetadata:\r\nname: secrets-store-csi-secrets-access-binding\r\nsubjects:\r\n- kind: ServiceAccount\r\n\u00a0 name: secrets-store-csi-driver-gke\r\n\u00a0 namespace: kube-system\r\nroleRef:\r\nkind: ClusterRole\r\nname: secrets-store-csi-secrets-access\r\napiGroup: rbac.authorization.k8s.io\r\n\r\n<\/pre>\n<p><strong>7. Set an environment variable to reference Kubernetes secrets :- <\/strong>Create a deployment.yaml for gke and pass the reference of gke secrets and mount volume on the deployment.yaml.<br \/>\nBelow is an example of the deployment.<\/p>\n<div id=\"attachment_73770\" style=\"width: 954px\" class=\"wp-caption alignnone\"><img aria-describedby=\"caption-attachment-73770\" decoding=\"async\" loading=\"lazy\" class=\"size-full wp-image-73770\" src=\"https:\/\/www.tothenew.com\/blog\/wp-ttn-blog\/uploads\/2025\/07\/Screenshot-2025-07-31-at-2.08.47\u202fPM.png\" alt=\"Example of Gke deployment.yaml \" width=\"944\" height=\"932\" srcset=\"\/blog\/wp-ttn-blog\/uploads\/2025\/07\/Screenshot-2025-07-31-at-2.08.47\u202fPM.png 944w, \/blog\/wp-ttn-blog\/uploads\/2025\/07\/Screenshot-2025-07-31-at-2.08.47\u202fPM-300x296.png 300w, \/blog\/wp-ttn-blog\/uploads\/2025\/07\/Screenshot-2025-07-31-at-2.08.47\u202fPM-768x758.png 768w, \/blog\/wp-ttn-blog\/uploads\/2025\/07\/Screenshot-2025-07-31-at-2.08.47\u202fPM-624x616.png 624w, \/blog\/wp-ttn-blog\/uploads\/2025\/07\/Screenshot-2025-07-31-at-2.08.47\u202fPM-24x24.png 24w, \/blog\/wp-ttn-blog\/uploads\/2025\/07\/Screenshot-2025-07-31-at-2.08.47\u202fPM-48x48.png 48w, \/blog\/wp-ttn-blog\/uploads\/2025\/07\/Screenshot-2025-07-31-at-2.08.47\u202fPM-96x96.png 96w\" sizes=\"(max-width: 944px) 100vw, 944px\" \/><p id=\"caption-attachment-73770\" class=\"wp-caption-text\">Example of Gke deployment.yaml<\/p><\/div>\n<p><strong>8.Create service file : &#8211;<\/strong> Create a service.yaml file to expose your deployment and allow network access to the application and apply them using the commands.<\/p>\n<div id=\"attachment_73773\" style=\"width: 912px\" class=\"wp-caption alignnone\"><img aria-describedby=\"caption-attachment-73773\" decoding=\"async\" loading=\"lazy\" class=\"size-full wp-image-73773\" src=\"https:\/\/www.tothenew.com\/blog\/wp-ttn-blog\/uploads\/2025\/07\/Screenshot-2025-07-31-at-2.19.00\u202fPM.png\" alt=\"service.yaml\" width=\"902\" height=\"554\" srcset=\"\/blog\/wp-ttn-blog\/uploads\/2025\/07\/Screenshot-2025-07-31-at-2.19.00\u202fPM.png 902w, \/blog\/wp-ttn-blog\/uploads\/2025\/07\/Screenshot-2025-07-31-at-2.19.00\u202fPM-300x184.png 300w, \/blog\/wp-ttn-blog\/uploads\/2025\/07\/Screenshot-2025-07-31-at-2.19.00\u202fPM-768x472.png 768w, \/blog\/wp-ttn-blog\/uploads\/2025\/07\/Screenshot-2025-07-31-at-2.19.00\u202fPM-624x383.png 624w\" sizes=\"(max-width: 902px) 100vw, 902px\" \/><p id=\"caption-attachment-73773\" class=\"wp-caption-text\">service.yaml<\/p><\/div>\n<pre>Kubectl apply\u00a0 -f deployment.yaml\r\nKubectl apply\u00a0 -f service.yaml<\/pre>\n<p><strong>9. Verify the gke secrets : &#8211; <\/strong>After applying the service and deployment verify that the csi driver created the gke secrets or not using the following command.<\/p>\n<pre>Kubectl get secrets -n dev<\/pre>\n<div id=\"attachment_73775\" style=\"width: 910px\" class=\"wp-caption alignnone\"><img aria-describedby=\"caption-attachment-73775\" decoding=\"async\" loading=\"lazy\" class=\"size-full wp-image-73775\" src=\"https:\/\/www.tothenew.com\/blog\/wp-ttn-blog\/uploads\/2025\/07\/Screenshot-2025-07-31-at-2.25.30\u202fPM.png\" alt=\"Kubernetes Secrets\" width=\"900\" height=\"82\" srcset=\"\/blog\/wp-ttn-blog\/uploads\/2025\/07\/Screenshot-2025-07-31-at-2.25.30\u202fPM.png 900w, \/blog\/wp-ttn-blog\/uploads\/2025\/07\/Screenshot-2025-07-31-at-2.25.30\u202fPM-300x27.png 300w, \/blog\/wp-ttn-blog\/uploads\/2025\/07\/Screenshot-2025-07-31-at-2.25.30\u202fPM-768x70.png 768w, \/blog\/wp-ttn-blog\/uploads\/2025\/07\/Screenshot-2025-07-31-at-2.25.30\u202fPM-624x57.png 624w\" sizes=\"(max-width: 900px) 100vw, 900px\" \/><p id=\"caption-attachment-73775\" class=\"wp-caption-text\">Kubernetes Secrets<\/p><\/div>\n<p><strong><span style=\"text-decoration: underline;\">Conclusion<\/span> :-<\/strong><\/p>\n<p>In conclusion, maintaining the security and integrity of your Google Kubernetes Engine applications depends heavily on efficient secret management. Organisations can greatly lower the risk of sensitive data exposure by utilising GKE&#8217;s built-in features, like Kubernetes Secrets, and integrating with reliable programs like Google Cloud Secret Manager. Developers and operations teams can create and implement secure, resilient applications in the GKE environment with confidence if the strategies discussed are put into practice, from appropriate secret creation and distribution to strong access controls and frequent rotation.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Introduction\u00a0 Management of sensitive information such as API keys, credentials and configuration secrets are an important part of developing safe and reliable Skylands applications. In Google Cloud Ecosystem, Secret Manager provides a centralized and safe way to save, access and manage these secrets.When running applications on Google Kubernetes Engine (GKE), including Secret Manager guarantees that [&hellip;]<\/p>\n","protected":false},"author":1959,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"iawp_total_views":751},"categories":[2348],"tags":[1892,6362],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/posts\/73253"}],"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\/1959"}],"replies":[{"embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/comments?post=73253"}],"version-history":[{"count":25,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/posts\/73253\/revisions"}],"predecessor-version":[{"id":74348,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/posts\/73253\/revisions\/74348"}],"wp:attachment":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/media?parent=73253"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/categories?post=73253"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/tags?post=73253"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}