Skip to content

Commit

Permalink
gcp: add --confidential-vm option to support confidential vm
Browse files Browse the repository at this point in the history
  • Loading branch information
HuijingHei committed May 15, 2023
1 parent 551e93e commit 5bf8c07
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 1 deletion.
1 change: 1 addition & 0 deletions mantle/cmd/kola/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ func init() {
sv(&kola.GCPOptions.ServiceAcct, "gcp-service-account", "", "GCP service account to attach to instance (default project default)")
bv(&kola.GCPOptions.ServiceAuth, "gcp-service-auth", false, "for non-interactive auth when running within GCP")
sv(&kola.GCPOptions.JSONKeyFile, "gcp-json-key", "", "use a service account's JSON key for authentication (default \"~/"+auth.GCPConfigPath+"\")")
bv(&kola.GCPOptions.Confidential, "gcp-confidential-vm", false, "create confidential instances")

// openstack-specific options
sv(&kola.OpenStackOptions.ConfigPath, "openstack-config-file", "", "Path to a clouds.yaml formatted OpenStack config file. The underlying library defaults to ./clouds.yaml")
Expand Down
1 change: 1 addition & 0 deletions mantle/cmd/ore/gcloud/gcloud.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ func init() {
sv(&opts.Network, "network", "default", "network name")
sv(&opts.JSONKeyFile, "json-key", "", "use a service account's JSON key for authentication")
GCloud.PersistentFlags().BoolVar(&opts.ServiceAuth, "service-auth", false, "use non-interactive auth when running within GCP")
GCloud.PersistentFlags().BoolVar(&opts.Confidential, "confidential-vm", false, "create confidential instances")

cli.WrapPreRun(GCloud, preauth)
}
Expand Down
1 change: 1 addition & 0 deletions mantle/platform/api/gcloud/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ type Options struct {
ServiceAcct string
JSONKeyFile string
ServiceAuth bool
Confidential bool
*platform.Options
}

Expand Down
10 changes: 9 additions & 1 deletion mantle/platform/api/gcloud/compute.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,15 @@ func (a *API) mkinstance(userdata, name string, keys []*agent.Key, useServiceAcc
Value: &userdata,
})
}

// create confidential instance
if a.options.Confidential {
instance.ConfidentialInstanceConfig = &compute.ConfidentialInstanceConfig {
EnableConfidentialCompute: true,
}
instance.Scheduling = &compute.Scheduling {
OnHostMaintenance: "TERMINATE",
}
}
return instance

}
Expand Down

0 comments on commit 5bf8c07

Please sign in to comment.