Connector for Kubernetes Engine

Workflows connector that defines the built-in function used to access a Kubernetes Engine container-based application within a workflow.

Explore further

For detailed documentation that includes this code sample, see the following:

Code sample

YAML

  # This workflow demonstrates how to use the Google Kubernetes Engine (GKE) connector: 
 # Create a GKE cluster and then delete it 
 # Each step waits until the long-running operation of creating or deleting the cluster completes 
 # Expected output: "SUCCESS" 
 main 
 : 
  
 params 
 : 
  
 [] 
  
 steps 
 : 
  
 - 
  
 init 
 : 
  
 assign 
 : 
  
 - 
  
 project_id 
 : 
  
 ${sys.get_env("GOOGLE_CLOUD_PROJECT_ID")} 
  
 - 
  
 cluster_zone 
 : 
  
 "us-central1-a" 
  
 - 
  
 cluster_id 
 : 
  
 "CLUSTER_ID" 
  
 # replace CLUSTER_ID placeholder 
  
 - 
  
 cluster_full_name 
 : 
  
 ${"projects/" + project_id + "/locations/" + cluster_zone + "/clusters/" + cluster_id} 
  
 - 
  
 create_gke_cluster 
 : 
  
 call 
 : 
  
 googleapis.container.v1.projects.zones.clusters.create 
  
 args 
 : 
  
 projectId 
 : 
  
 ${project_id} 
  
 zone 
 : 
  
 ${cluster_zone} 
  
 body 
 : 
  
 cluster 
 : 
  
 name 
 : 
  
 ${cluster_id} 
  
 initial_node_count 
 : 
  
 1 
  
 parent 
 : 
  
 ${"projects/" + project_id + "/locations/" + cluster_zone} 
  
 - 
  
 assert_running 
 : 
  
 call 
 : 
  
 assert_cluster_status 
  
 args 
 : 
  
 expected_status 
 : 
  
 "RUNNING" 
  
 project_id 
 : 
  
 ${project_id} 
  
 cluster_zone 
 : 
  
 ${cluster_zone} 
  
 cluster_id 
 : 
  
 ${cluster_id} 
  
 cluster_full_name 
 : 
  
 ${cluster_full_name} 
  
 - 
  
 delete_gke_cluster 
 : 
  
 call 
 : 
  
 googleapis.container.v1.projects.zones.clusters.delete 
  
 args 
 : 
  
 projectId 
 : 
  
 ${project_id} 
  
 zone 
 : 
  
 ${cluster_zone} 
  
 clusterId 
 : 
  
 ${cluster_id} 
  
 name 
 : 
  
 ${cluster_full_name} 
  
 - 
  
 the_end 
 : 
  
 return 
 : 
  
 "SUCCESS" 
 assert_cluster_status 
 : 
  
 params 
 : 
  
 [ 
 expected_status 
 , 
  
 project_id 
 , 
  
 cluster_zone 
 , 
  
 cluster_id 
 , 
  
 cluster_full_name 
 ] 
  
 steps 
 : 
  
 - 
  
 get_cluster 
 : 
  
 call 
 : 
  
 googleapis.container.v1.projects.zones.clusters.get 
  
 args 
 : 
  
 projectId 
 : 
  
 ${project_id} 
  
 zone 
 : 
  
 ${cluster_zone} 
  
 clusterId 
 : 
  
 ${cluster_id} 
  
 name 
 : 
  
 ${cluster_full_name} 
  
 result 
 : 
  
 cluster 
  
 - 
  
 compare 
 : 
  
 switch 
 : 
  
 - 
  
 condition 
 : 
  
 ${cluster.status == expected_status} 
  
 next 
 : 
  
 end 
  
 - 
  
 fail 
 : 
  
 raise 
 : 
  
 ${"Expected VM status is " + expected_status + ". Received " + cluster.status + " instead."} 
 

What's next

To search and filter code samples for other Google Cloud products, see the Google Cloud sample browser .

Create a Mobile Website
View Site in Mobile | Classic
Share by: