runbatch

package module
v0.1.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 22, 2022 License: MIT Imports: 9 Imported by: 0

README

runbatch

runbatch is a tool for running a docker container in a transient GCE VM instance. The instance will be deleted once the container exits. It can be invoked in several ways described below.

Go function runbatch.Start()

Start accepts an Input struct specifying at a minimum:

  • GCP project ID where the VM instance will be created.
  • GCP zone where the VM instance will be created.
  • GCP service account that will run the workload.
  • Fully qualified docker image name for the workload to run.

For more details see runbatch.go.

Command line tool: cmd/gcp-runbatch/main.go

This is a wrapper around Start that accepts command line parameters for the inputs described above. For more details run: go run cmd/gcp-runbatch/main.go --help.

GCP Cloud Function: function.StartRunBatch

This is a wrapper around Start that accepts its input as JSON. To deploy to GCP, run:

go mod vendor
gcloud functions deploy runbatch-start \
  --trigger-http \
  --no-allow-unauthenticated \
  --runtime=go116 \
  --entry-point=Function

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Function

func Function(w http.ResponseWriter, r *http.Request)

Function is the entrypoint for running runbatch as a Cloud Function.

Types

type Input

type Input struct {
	// ProjectID is the GCP project ID where the VM instance will be created.
	ProjectID string `json:"projectId"`

	// Zone is the GCP zone where the VM instance will be created.
	Zone string `json:"zone"`

	// ServiceAccount is the GCP service account that will run the workload.
	ServiceAccount string `json:"serviceAccount"`

	// MachinePrefix is a prefix for the VM instance name.
	MachinePrefix string `json:"machinePrefix"`

	// Image is the fully qualified docker image name for the workload to run.
	Image string `json:"image"`

	// JSONEnv is a JSON-encoded string of environment variables to set for the
	// container, e.g. `{"FOO":"foo","BAR":"bar"}`.
	JSONEnv string `json:"jsonEnv"`

	// SecretJSONEnvs is a comma separated list of references to Secret Manager
	// secrets, e.g.: `projects/12345/secrets/secret_name/versions/latest`. The
	// secret payloads are expected to be JSON-encoded strings of environment
	// variables to set for the container.
	SecretJSONEnvs []string `json:"secretJsonEnvs"`
}

type Output

type Output struct {
	InstanceName string `json:"instanceName"`
}

func Start

func Start(ctx context.Context, input *Input) (*Output, error)

Start runs the workload specified in input on a transient GCE VM instance.

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL