Overview
Rancher provides native integration with Google Kubernetes Engine (GKE) through theClusterDriverGKE driver. This enables provisioning, managing, and importing GKE clusters directly from Rancher using Google Cloud APIs.
Cluster Driver
Driver Name:GKE
Defined in: pkg/apis/management.cattle.io/v3/cluster_types.go:84
Configuration Spec
GKE clusters are configured using theGKEClusterConfigSpec structure.
Cluster Spec Fields
Authentication Configuration
googlecredentialConfig-authEncodedJson: Base64-encoded service account JSON key
pkg/api/norman/customization/gke/handler.go:217
Networking Configuration
Node Pool Configuration
Private Cluster Configuration
Security & Addons
Advanced Features
API Integration
The GKE handler provides API endpoints for interacting with Google Cloud services. Handler Location:pkg/api/norman/customization/gke/handler.go
Available Endpoints
- gkeMachineTypes: List available machine types for a zone
- gkeNetworks: List VPC networks
- gkeSubnetworks: List subnets for a network and region
- gkeServiceAccounts: List service accounts
- gkeVersions: List available Kubernetes versions
- gkeZones: List available zones
- gkeClusters: List existing GKE clusters
- gkeSharedSubnets: List shared VPC subnets
- gkeFamiliesFromProject: List image families from a project
- gkeImageFamilies: List images in an image family
- gkeDiskTypes: List available disk types
pkg/api/norman/customization/gke/handler.go:82-185
Credential Authentication
The handler supports two authentication methods:- Cloud Credential ID: Pass
cloudCredentialIdas query parameter - Direct Credentials: POST credentials in request body
pkg/api/norman/customization/gke/handler.go:274-292
Project ID Requirements
Most endpoints require theprojectId query parameter, except:
gkeImageFamilies: Used for browsing public imagesgkeFamiliesFromProject: RequiresimageProjectsparameter
pkg/api/norman/customization/gke/handler.go:62-67
Cluster Status
The GKE cluster status is tracked instatus.gkeStatus:
pkg/apis/management.cattle.io/v3/cluster_types.go:422-425
Zonal vs Regional Clusters
Zonal Clusters
Regional Clusters
Provisioning Workflow
- Create Cluster Object: Define cluster with
spec.gkeConfig - Credential Validation: Validate GCP service account
- Resource Creation: GKE operator provisions:
- GKE cluster control plane
- Node pools
- Network resources (if needed)
- Status Updates: Cluster status reflects provisioning state
- Agent Deployment: Rancher cluster agent deployed
- Ready State: Cluster becomes active and manageable
Importing Existing Clusters
To import an existing GKE cluster:imported: true, Rancher registers the cluster without modifying its configuration.
Shared VPC Support
GKE clusters can use shared VPC networks from host projects:gkeSharedSubnets API endpoint to list available shared subnets.
Source: pkg/api/norman/customization/gke/handler.go:133-139
Autopilot Mode
GKE Autopilot provides a fully managed Kubernetes experience:- Google manages nodes, scaling, and security
- Node pools are not configurable
- Pay-per-pod pricing model
Best Practices
Networking
- Use VPC-native clusters with IP aliases for better performance
- Enable network policy for pod-to-pod security
- Use private nodes to enhance security
- Configure authorized networks for API server access
Node Pools
- Use multiple node pools for different workload types
- Enable autoscaling for dynamic workloads
- Use preemptible instances for fault-tolerant workloads
- Enable auto-repair and auto-upgrade for node management
Security
- Use Workload Identity instead of service account keys
- Enable private endpoint for private clusters
- Use customer-managed encryption keys (CMEK) for data encryption
- Configure master authorized networks to restrict API access
- Use latest GKE release channel for security patches
High Availability
- Use regional clusters for production workloads
- Distribute node pools across multiple zones
- Configure maintenance windows during low-traffic periods
Monitoring & Logging
- Enable Cloud Logging and Cloud Monitoring
- Use GKE usage metering for cost tracking
- Configure log retention policies
Troubleshooting
Credential Issues
If credential validation fails:- Verify service account has required roles:
Kubernetes Engine AdminCompute ViewerService Account User
- Check if service account JSON is properly base64-encoded
- Ensure API is enabled:
gcloud services enable container.googleapis.com
pkg/api/norman/customization/gke/handler.go:188-235
Private Cluster Access
For private clusters withenablePrivateEndpoint: true:
- Rancher determines if tunneling is required
privateRequiresTunnel: true: Cluster agent tunnel requiredprivateRequiresTunnel: false: Direct API access possible
Quota Exceeded
If you encounter quota errors:- Check GCP quotas: CPUs, IPs, In-use IPs
- Request quota increase in GCP console
- Reduce initial node count or machine size
Network Configuration Errors
Common issues:- Subnet IP range exhaustion: Use larger subnet CIDR
- Secondary range conflicts: Ensure pod/service ranges don’t overlap
- Shared VPC permissions: Verify host project permissions
Node Pool Creation Failures
Check:- Service account has required OAuth scopes
- Machine type is available in selected zones
- Sufficient project quotas for instances
- Boot disk type and size are valid
Related Resources
- Google Kubernetes Engine Documentation
- GKE Best Practices
- GKE Operator GitHub
- VPC-Native Clusters
- GKE Autopilot
API Reference
Cluster Type Definition
Location:pkg/apis/management.cattle.io/v3/cluster_types.go:163
GKE Handler Registration
The GKE API handler is registered in the Norman API server and handles all GKE-related API requests. Location:pkg/api/norman/customization/gke/handler.go:42-49
Access Control
The handler performs cluster-based access control checks to ensure users can only access credentials associated with clusters they have permission to update. Location:pkg/api/norman/customization/gke/handler.go:237-272