Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Container image option in google_compute_instance_template #4193

Open
JasperWoo opened this issue Aug 9, 2019 · 8 comments
Open

Container image option in google_compute_instance_template #4193

JasperWoo opened this issue Aug 9, 2019 · 8 comments

Comments

@JasperWoo
Copy link

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

  1. https://cloud.google.com/compute/docs/containers/deploying-containers#managedinstancegroupcontainer
  2. https://www.terraform.io/docs/providers/google/r/compute_instance_template.html
  • #0000
@ghost ghost added the enhancement label Aug 9, 2019
@mercuriete
Copy link

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.

@mjrlee
Copy link

mjrlee commented Aug 22, 2019

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!

@paddycarver
Copy link
Contributor

There's more information on this here: #1022 (comment)

@AlistairB
Copy link

AlistairB commented Aug 17, 2020

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.

@AlistairB
Copy link

@paddycarver Sorry for the ping. Can the upstream label be removed as per my above comment?

@danawillow danawillow added this to the Goals milestone Aug 31, 2020
modular-magician added a commit to modular-magician/terraform-provider-google that referenced this issue Nov 9, 2020
modular-magician added a commit that referenced this issue Nov 9, 2020
@melinath
Copy link
Collaborator

Is this supported by the REST API? If so, could someone provide a docs link? Thanks!

@AarshDhokai
Copy link
Contributor

b/262532046

@AarshDhokai
Copy link
Contributor

  • 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

9 participants