We can simplify application deployment by deploying containers to instances in managed instance groups. This is supported in GCP as here.
resource "google_compute_instance_template" "default" {
...
// New option: Deploy container from Google Container Registry
container {
source_image = "http://us.gcr.io/path_to_image:latest"
}
// Create a new boot disk from an image
disk {
source_image = "debian-cloud/debian-9"
auto_delete = true
boot = true
}
...
}
Hi i wanted this feature but I saw this is a beta feature:
https://cloud.google.com/sdk/gcloud/reference/beta/compute/instance-templates/create-with-container
It is posible to add create with container to the google-beta terraform provider?
anyways, I would like to have in addition to container.source_image the following:
container.env
--container-env=[KEY=VALUE, …,…]
Declare environment variables KEY with value VALUE passed to container. Only the last value of KEY is taken when KEY is repeated more than once.
Values, declared with --container-env flag override those with the same KEY from file, provided in --container-env-file.
container.arg
--container-arg=CONTAINER_ARG
Argument to append to container entrypoint or to override container CMD. Each argument must have a separate flag. Arguments are appended in the order of flags. Example:
Assuming the default entry point of the container (or an entry point overridden with --container-command flag) is a Bourne shell-compatible executable, in order to execute 'ls -l' command in the container, the user could use:
and so on.
Thank you very much.
This is currently possible by using https://registry.terraform.io/modules/terraform-google-modules/container-vm/google/1.0.0 to generate the metadata.
Would rather see it natively though!
There's more information on this here: https://github.com/terraform-providers/terraform-provider-google/issues/1022#issuecomment-361774647
Hi,
--container-env, --container-arg and --container-image are now appearing in gcloud stable https://cloud.google.com/sdk/gcloud/reference/compute/instance-templates/create-with-container . As such I believe this is no longer blocked on upstream? Can we get these properties added?
There are also multiple other --container-* commands that would be nice to support.
FWIW, https://registry.terraform.io/modules/terraform-google-modules/container-vm/google/2.0.0 is nice, but custom modules add another layer of misdirection and can be hard to customize and understand what you are getting. I think they should be additive on existing working terraform google provider functionality.
@paddycarver Sorry for the ping. Can the upstream label be removed as per my above comment?
Most helpful comment
This is currently possible by using https://registry.terraform.io/modules/terraform-google-modules/container-vm/google/1.0.0 to generate the metadata.
Would rather see it natively though!