mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-23 03:41:45 +00:00
Merge pull request #78198 from Random-Liu/node-e2e-service-account
Use default service account when creating test instance.
This commit is contained in:
commit
d1d6f64cda
@ -558,7 +558,13 @@ func testImage(imageConfig *internalGCEImage, junitFilePrefix string) *TestResul
|
||||
|
||||
// Provision a gce instance using image
|
||||
func createInstance(imageConfig *internalGCEImage) (string, error) {
|
||||
klog.V(1).Infof("Creating instance %+v", *imageConfig)
|
||||
p, err := computeService.Projects.Get(*project).Do()
|
||||
if err != nil {
|
||||
return "", fmt.Errorf("failed to get project info %q", *project)
|
||||
}
|
||||
// Use default service account
|
||||
serviceAccount := p.DefaultServiceAccount
|
||||
klog.V(1).Infof("Creating instance %+v with service account %q", *imageConfig, serviceAccount)
|
||||
name := imageToInstanceName(imageConfig)
|
||||
i := &compute.Instance{
|
||||
Name: name,
|
||||
@ -583,6 +589,14 @@ func createInstance(imageConfig *internalGCEImage) (string, error) {
|
||||
},
|
||||
},
|
||||
},
|
||||
ServiceAccounts: []*compute.ServiceAccount{
|
||||
{
|
||||
Email: serviceAccount,
|
||||
Scopes: []string{
|
||||
"https://www.googleapis.com/auth/cloud-platform",
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
for _, accelerator := range imageConfig.resources.Accelerators {
|
||||
@ -602,7 +616,6 @@ func createInstance(imageConfig *internalGCEImage) (string, error) {
|
||||
i.GuestAccelerators = append(i.GuestAccelerators, ac)
|
||||
}
|
||||
|
||||
var err error
|
||||
i.Metadata = imageConfig.metadata
|
||||
if _, err := computeService.Instances.Get(*project, *zone, i.Name).Do(); err != nil {
|
||||
op, err := computeService.Instances.Insert(*project, *zone, i).Do()
|
||||
|
Loading…
Reference in New Issue
Block a user