forked from GoogleCloudPlatform/magic-modules
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Cloud Run v1 Multi-Container Example with New Fields (GoogleCloud…
…Platform#7971) * cloudrun: Add container name field for Services Adds the template.spec.containers.name field for specifying container names in Cloud Run v1 Services. * cloudrun: Update the description of the Service containers field Updates the description of the Cloud Run v1 Service field template.spec.containers to reflect that the field is repeated and to remove other obsolete information. * cloudrun: Add empty dir volume type for Services Adds the beta template.spec.volumes.empty_dir field for configuring ephemeral volumes in Cloud Run v1 Services. * cloudrun: Add multi-container Service example Adds an example google_cloud_run_service resource with multiple containers and a shared empty dir volume. Container dependencies are specified as a json encoded annotation.
- Loading branch information
Showing
2 changed files
with
88 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
61 changes: 61 additions & 0 deletions
61
mmv1/templates/terraform/examples/cloud_run_service_multicontainer.tf.erb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
resource "google_cloud_run_service" "<%= ctx[:primary_resource_id] %>" { | ||
name = "<%= ctx[:vars]['cloud_run_service_name'] %>" | ||
location = "us-central1" | ||
provider = google-beta | ||
|
||
metadata { | ||
annotations = { | ||
"run.googleapis.com/launch-stage" = "BETA" | ||
} | ||
} | ||
template { | ||
metadata { | ||
annotations = { | ||
"run.googleapis.com/container-dependencies" = jsonencode({hello-1 = ["hello-2"]}) | ||
} | ||
} | ||
spec { | ||
containers { | ||
name = "hello-1" | ||
ports { | ||
container_port = 8080 | ||
} | ||
image = "us-docker.pkg.dev/cloudrun/container/hello" | ||
volume_mounts { | ||
name = "shared-volume" | ||
mount_path = "/mnt/shared" | ||
} | ||
} | ||
containers { | ||
name = "hello-2" | ||
image = "us-docker.pkg.dev/cloudrun/container/hello" | ||
env { | ||
name = "PORT" | ||
value = "8081" | ||
} | ||
startup_probe { | ||
http_get { | ||
port = 8081 | ||
} | ||
} | ||
volume_mounts { | ||
name = "shared-volume" | ||
mount_path = "/mnt/shared" | ||
} | ||
} | ||
volumes { | ||
name = "shared-volume" | ||
empty_dir { | ||
medium = "Memory" | ||
size_limit = "128Mi" | ||
} | ||
} | ||
} | ||
} | ||
|
||
lifecycle { | ||
ignore_changes = [ | ||
metadata[0].annotations["run.googleapis.com/launch-stage"], | ||
] | ||
} | ||
} |