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

gcp: allow users to set podvm disk-type and align CLI options #2281

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions src/cloud-api-adaptor/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -94,11 +94,12 @@ azure() {
gcp() {
test_vars GCP_CREDENTIALS GCP_PROJECT_ID GCP_ZONE PODVM_IMAGE_NAME

[[ "${PODVM_IMAGE_NAME}" ]] && optionals+="-gcp-image-name ${PODVM_IMAGE_NAME} "
[[ "${PODVM_IMAGE_NAME}" ]] && optionals+="-image-name ${PODVM_IMAGE_NAME} "
[[ "${GCP_PROJECT_ID}" ]] && optionals+="-gcp-project-id ${GCP_PROJECT_ID} "
[[ "${GCP_ZONE}" ]] && optionals+="-gcp-zone ${GCP_ZONE} " # if not set retrieved from IMDS
[[ "${GCP_MACHINE_TYPE}" ]] && optionals+="-gcp-machine-type ${GCP_MACHINE_TYPE} " # default e2-medium
[[ "${GCP_NETWORK}" ]] && optionals+="-gcp-network ${GCP_NETWORK} " # defaults to 'default'
[[ "${GCP_ZONE}" ]] && optionals+="-zone ${GCP_ZONE} " # if not set retrieved from IMDS
[[ "${GCP_MACHINE_TYPE}" ]] && optionals+="-machine-type ${GCP_MACHINE_TYPE} " # default e2-medium
[[ "${GCP_NETWORK}" ]] && optionals+="-network ${GCP_NETWORK} " # defaults to 'default'
[[ "${GCP_DISK_TYPE}" ]] && optionals+="-disk-type ${GCP_DISK_TYPE} " # defaults to 'pd-standard'

set -x
exec cloud-api-adaptor gcp \
Expand Down
9 changes: 5 additions & 4 deletions src/cloud-providers/gcp/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,11 @@ func (_ *Manager) ParseCmd(flags *flag.FlagSet) {

flags.StringVar(&gcpcfg.GcpCredentials, "gcp-credentials", "", "Google Application Credentials, defaults to `GCP_CREDENTIALS`")
flags.StringVar(&gcpcfg.ProjectId, "gcp-project-id", "", "GCP Project ID")
flags.StringVar(&gcpcfg.Zone, "gcp-zone", "", "Zone")
flags.StringVar(&gcpcfg.ImageName, "gcp-image-name", "", "Pod VM image name")
flags.StringVar(&gcpcfg.MachineType, "gcp-machine-type", "e2-medium", "Pod VM instance type")
flags.StringVar(&gcpcfg.Network, "gcp-network", "", "Network ID to be used for the Pod VMs")
flags.StringVar(&gcpcfg.Zone, "zone", "", "Zone")
flags.StringVar(&gcpcfg.ImageName, "image-name", "", "Pod VM image name")
flags.StringVar(&gcpcfg.MachineType, "machine-type", "e2-medium", "Pod VM instance type")
flags.StringVar(&gcpcfg.Network, "network", "", "Network ID to be used for the Pod VMs")
flags.StringVar(&gcpcfg.DiskType, "disk-type", "pd-standard", "Any GCP disk type (pd-standard, pd-ssd, pd-balanced or pd-extreme)")
}

func (_ *Manager) LoadEnv() {
Expand Down
2 changes: 1 addition & 1 deletion src/cloud-providers/gcp/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ func (p *gcpProvider) CreateInstance(ctx context.Context, podName, sandboxID str
InitializeParams: &computepb.AttachedDiskInitializeParams{
DiskSizeGb: proto.Int64(20),
SourceImage: srcImage,
DiskType: proto.String(fmt.Sprintf("zones/%s/diskTypes/pd-standard", p.serviceConfig.Zone)),
DiskType: proto.String(fmt.Sprintf("zones/%s/diskTypes/%s", p.serviceConfig.Zone, p.serviceConfig.DiskType)),
},
AutoDelete: proto.Bool(true),
Boot: proto.Bool(true),
Expand Down
1 change: 1 addition & 0 deletions src/cloud-providers/gcp/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ type Config struct {
ImageName string
MachineType string
Network string
DiskType string
}

func (c Config) Redact() Config {
Expand Down
Loading