Deploy on GKE
Learn how to deploy the DocumentDB Kubernetes Operator on GKE.
Understanding the configuration¶
GKE load balancer annotation¶
When using GKE, set the DocumentDB spec.environment field to gke.
Supported values are aks, eks, and gke. If you omit this field, the
operator doesn't apply cloud-specific service annotations. For field details,
see the API reference.
When spec.environment: "gke" is set, the operator adds Google Cloud-specific
service annotations:
This annotation tells GKE to provision an external Google Cloud load balancer for the gateway Service so that it's reachable from outside the Kubernetes cluster. For details on the underlying behavior and additional annotations you can layer on top, see GKE Service parameters and Configure load balancing.
Storage class¶
GKE provisions the
Compute Engine persistent disk CSI driver
by default and ships several built-in storage classes. The default class is
standard-rwo, which is backed by balanced persistent disks. For production
workloads, use a class that matches your performance and availability
requirements, such as premium-rwo.
| Storage class | Disk type | Use case |
|---|---|---|
standard-rwo |
pd-balanced |
General purpose, balanced cost and performance |
premium-rwo |
pd-ssd |
Production workloads requiring SSD performance |
For available classes, see:
Monitoring and troubleshooting¶
Common issues¶
If the Service stays in Pending, verify the GKE network configuration and
load balancer setup:
kubectl get svc -n documentdb-instance-ns
kubectl describe svc documentdb-service-sample-documentdb -n documentdb-instance-ns
gcloud compute forwarding-rules list --project PROJECT_ID
If PVCs don't bind, verify your storage classes and that the Compute Engine persistent disk CSI driver pods are healthy:
kubectl get storageclass
kubectl get pvc -A
kubectl describe pvc PVC_NAME -n NAMESPACE
kubectl get pods -n kube-system -l k8s-app=gcp-compute-persistent-disk-csi-driver
Cost and security considerations¶
Cost optimization¶
- Use smaller machine types for development workloads, such as
e2-small - Use standard storage classes where SSD performance isn't required
- Scale node pools down in non-production environments
- Review GKE pricing for current rates
Security baseline¶
- Workload Identity for Google Cloud API access
- Network policies enabled
- Encryption at rest for persistent disks
- TLS configuration for database traffic
- Least-privilege IAM service accounts
Hardening examples¶
# Enable network policy enforcement
gcloud container clusters update CLUSTER_NAME \
--location REGION_OR_ZONE \
--enable-network-policy
# Enable Workload Identity
gcloud container clusters update CLUSTER_NAME \
--location REGION_OR_ZONE \
--workload-pool=PROJECT_ID.svc.id.goog