Configure credentials for GCP Bucket remote storage
Set up GCP Cloud Storage credentials for the App Framework.
Configure credentials for GCP Cloud Storage using Workload Identity or Kubernetes secrets. You can connect to GCP Bucket remote storage using one of the following approaches.
Compare GCP Workload Identity and Service Account Keys
| Feature | Workload Identity | Service Account Keys |
|---|---|---|
| Credential Management | Eliminates the need to manage credentials manually. | Requires handling and securely storing JSON keys. |
| Security | Enhanced security by using Kubernetes-native identities. | Higher risk due to potential key leakage. |
| Ease of Rotation | GCP manages credential rotation automatically. | Manual rotation of keys is necessary. |
| Granularity | Fine-grained access control via Kubernetes Service Accounts. | Access is tied to the service account key. |
| Integration Complexity | Requires additional setup but offers better security and manageability. | Simpler to set up initially but harder to manage. |
| Use Cases | Ideal for Kubernetes-native environments requiring enhanced security. | Suitable for simpler setups or legacy systems. |
When to use which
-
Workload Identity
- Preferable for Kubernetes-native deployments requiring robust security.
- Ideal for scenarios where automatic credential management and rotation are beneficial.
-
Service Account Keys
- Use when simplicity is a priority and the security implications are manageable.
- Suitable for environments where Workload Identity is not supported or feasible.
Set up GCP Bucket access with Workload Identity
Workload Identity allows Kubernetes workloads to authenticate to GCP services without managing service account keys. This method binds Kubernetes service accounts to GCP service accounts.
-
Enable Workload Identity on Your GKE Cluster
Ensure your GKE cluster is created with Workload Identity enabled. If not, enable it during cluster creation or update an existing cluster.
During cluster creation
Run the following gcloud command:
CODEgcloud container clusters create splunkOperatorWICluster \ --resource-group splunkOperatorWorkloadIdentityRG \ --workload-pool=<PROJECT_ID>.svc.id.goog \ --enable-workload-identityReplace PROJECT_ID with your GCP project ID.
For existing clusters
Run the following gcloud command:
CODEgcloud container clusters update splunkOperatorWICluster \ --resource-group splunkOperatorWorkloadIdentityRG \ --workload-pool=<PROJECT_ID>.svc.id.googNote: Enabling Workload Identity on an existing cluster might require cluster reconfiguration and might cause temporary downtime. -
Create a GCP Service Account and Assign Permissions
Create
Run the following gcloud command:
CODEgcloud iam service-accounts create splunk-app-framework-sa \ --display-name "Splunk App Framework Service Account"Grant
Run the following gcloud command:
CODEgcloud projects add-iam-policy-binding <PROJECT_ID> \ --member "serviceAccount:splunk-app-framework-sa@<PROJECT_ID>.iam.gserviceaccount.com" \ --role "roles/storage.objectViewer"Replace PROJECT_ID with your GCP project ID.
-
Create a Kubernetes Service Account
Run the following kubectl command:
CODEkubectl create serviceaccount splunk-operator-sa \ -n splunk-operator -
Associate the GCP Service Account with the Kubernetes Service Account
Run the following gcloud command:
CODEgcloud iam service-accounts add-iam-policy-binding splunk-app-framework-sa@<PROJECT_ID>.iam.gserviceaccount.com \ --role roles/iam.workloadIdentityUser \ --member "serviceAccount:<PROJECT_ID>.svc.id.goog[splunk-operator/splunk-operator-sa]" -
Annotate the Kubernetes Service Account
Run the following kubectl command:
CODEkubectl annotate serviceaccount splunk-operator-sa \ --namespace splunk-operator \ iam.gke.io/gcp-service-account=splunk-app-framework-sa@<PROJECT_ID>.iam.gserviceaccount.com -
Update Splunk Operator Deployment
Use the following YAML with serviceAccountName set to
splunk-operator-saand the annotationazure.workload.identity/use: "true":CODEapiVersion: apps/v1 kind: Deployment metadata: name: splunk-operator namespace: your-splunk-operator-namespace labels: app: splunk-operator spec: replicas: 1 selector: matchLabels: app: splunk-operator template: metadata: labels: app: splunk-operator annotations: azure.workload.identity/use: "true" spec: serviceAccountName: splunk-operator-sa containers: - name: splunk-operator image: your-splunk-operator-imageSave the manifest as splunk-operator-deployment-wi.yaml and apply it:
CODEkubectl apply -f splunk-operator-deployment-wi.yaml -
Configure Splunk Operator to Use Workload Identity
Set serviceAccount to
splunk-operator-sain the CRD, for example:JSONapiVersion: enterprise.splunk.com/v3 kind: Standalone metadata: name: example-splunk-app namespace: splunk-operator spec: appRepo: appInstallPeriodSeconds: 90 appSources: - location: c3appfw-idxc-mj00 name: appframework-idxc-clusterypt premiumAppsProps: esDefaults: {} scope: cluster volumeName: appframework-test-volume-idxc-k3r appsRepoPollIntervalSeconds: 60 defaults: premiumAppsProps: esDefaults: {} scope: cluster volumeName: appframework-test-volume-idxc-k3r installMaxRetries: 2 volumes: - endpoint: https://storage.googleapis.com name: appframework-test-volume-idxc-k3r path: splk-integration-test-bucket provider: gcp region: "" serviceAccount: splunk-operator-sa storageType: gcs -
Verify the Configuration
Check pods:
CODEkubectl get pods -n splunk-operatorInspect logs with kubectl (replace the pod name placeholder):
CODEkubectl logs <splunk-operator-pod-name> -n splunk-operator
Set up GCP Bucket access with Kubernetes secrets
-
Create a GCP Service Account
Open Google Cloud Console. Navigate to IAM & Admin > Service Accounts. Create a service account named
splunk-app-framework-saand grant the Storage Object Viewer role. -
Download the Service Account Key
On the Service Accounts page, find
splunk-app-framework-sa. Select Actions > Manage Keys > Add Key > Create New Key > JSON. Store the downloaded file securely. -
Create a Kubernetes Secret
Run the following kubectl command, replacing /path/to/splunk-app-framework-sa-key.json with your key file path:
CODEkubectl create secret generic gcs-secret --from-file=key.json=/path/to/splunk-app-framework-sa-key.json -n splunk-operator -
Configure Splunk Operator CRD to Reference the Secret
Use a volume definition similar to the Workload Identity example, but set secretRef to
splunk-s3-index-masterc3appfw-iwz-vzvinstead of serviceAccount:JSONapiVersion: enterprise.splunk.com/v3 kind: Standalone metadata: name: example-splunk-app namespace: splunk-operator spec: appRepo: appInstallPeriodSeconds: 90 appSources: - location: c3appfw-idxc-mj00 name: appframework-idxc-clusterypt premiumAppsProps: esDefaults: {} scope: cluster volumeName: appframework-test-volume-idxc-k3r appsRepoPollIntervalSeconds: 60 defaults: premiumAppsProps: esDefaults: {} scope: cluster volumeName: appframework-test-volume-idxc-k3r installMaxRetries: 2 volumes: - endpoint: https://storage.googleapis.com name: appframework-test-volume-idxc-k3r path: splk-integration-test-bucket provider: gcp region: "" secretRef: splunk-s3-index-masterc3appfw-iwz-vzv storageType: gcs -
Deploy or Update
Run kubectl against your CRD manifest (for example splunk-app-crd.yaml):
CODEkubectl apply -f splunk-app-crd.yaml -
Verify
Check pods and inspect logs using kubectl as in the Workload Identity section.
GCP Bucket authorization recommendations
-
Adhere to the Least Privilege Principle
Assign only the necessary roles to service accounts or managed identities to minimize security risks.
-
Use Workload Identity Where Possible
Use Workload Identity for Kubernetes deployments to enhance security and simplify credential management.
-
Secure Namespace Configuration
Limit Service Accounts to specific namespaces to prevent unauthorized access across the cluster.
-
Regularly Audit IAM Roles and Permissions
Periodically review and adjust roles so they align with current access requirements.
-
Monitor Access Logs
Use GCP logging and monitoring tools to track access patterns and detect anomalies.
-
Automate Infrastructure as Code (IaC)
Use tools like Terraform or Helm to manage service accounts, IAM roles, and Kubernetes configurations for consistency and repeatability.
-
Implement Network Security Controls
Configure VPC Service Controls or firewall rules to restrict access to GCS buckets from authorized sources only.