terraform-provider-google
terraform-provider-google copied to clipboard
Container image option in google_compute_instance_template
Community Note
- Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request
- Please do not leave "+1" or "me too" comments, they generate extra noise for issue followers and do not help prioritize the request
- If you are interested in working on this issue or have submitted a pull request, please leave a comment. If the issue is assigned to the "modular-magician" user, it is either in the process of being autogenerated, or is planned to be autogenerated soon. If the issue is assigned to a user, that user is claiming responsibility for the issue. If the issue is assigned to "hashibot", a community member has claimed the issue already.
Description
We can simplify application deployment by deploying containers to instances in managed instance groups. This is supported in GCP as here.
New or Affected Resource(s)
- google_compute_instance_template
Potential Terraform Configuration
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
}
...
}
References
- https://cloud.google.com/compute/docs/containers/deploying-containers#managedinstancegroupcontainer
- https://www.terraform.io/docs/providers/google/r/compute_instance_template.html
- #0000
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?
Is this supported by the REST API? If so, could someone provide a docs link? Thanks!
b/262532046
- The user wants to deploy an application by deploying containers to instances in managed instance groups, based on my observations of this issue. This feature is available in the GUI.
- Applications can be deployed by giving a "command" and a "container image." We can set up the image to run on a virtual machine via GUI.
- I attempted to deploy a container using the GUI option, and after providing appropriate information in the configure container section, I looked up the equivalent REST for that. There, I noticed that the container's configuration is passed along with the VM instance's "metadata" element.
"metadata": {
"items": [
{
"key": "gce-container-declaration",
"value": "spec:\n containers:\n - name: instance-1\n image: gcr.io/google-containers/busybox\n command:\n - echo \"Hello world\"\n stdin: false\n tty: false\n restartPolicy: Always\n#
This container declaration format is not a public API and may change without notice. Please\n# use gcloud command-line tool or Google Cloud Console to run Containers on Google Compute Engine."
}
]
},
- However, it is evident from the warning that this container declaration format is not a public API. In light of the fact that this is not a public API and may change without notice.
- So Terraform cannot support this feature, until the API becomes public.