I am creating GCP VMs using the programmable Java APIs interface.
Maven dependency:
<dependency>
<groupId>com.google.cloud</groupId>
<artifactId>google-cloud-compute</artifactId>
<version>1.21.0</version>
</dependency>
Java code:
Instance instanceResource = Instance.newBuilder()
.setName(instanceName)
.setMachineType(MACHINE_TYPE)
.addDisks(disk)
// etc (...)
.build();
When I create a new VM using the GCP user interface, I see an option "Deploy a container image to this VM instance" in the "Container" section of the main screen.
How can I use that feature and deploy a container to the VM using the Java code?
In other words, how do I use the gcloud compute instances create-with-container
command from Java?
As per the GCP official document Deploying containers on VMs and MIGs Limitation,