diff --git a/driver/kubernetes/factory.go b/driver/kubernetes/factory.go index 6b831321..7b71d9b3 100644 --- a/driver/kubernetes/factory.go +++ b/driver/kubernetes/factory.go @@ -145,6 +145,8 @@ func (f *factory) processDriverOpts(deploymentName string, namespace string, cfg if _, isImage := cfg.DriverOpts["image"]; !isImage { deploymentOpt.Image = bkimage.DefaultRootlessImage } + case "serviceaccount": + deploymentOpt.ServiceAccountName = v case "nodeselector": kvs := strings.Split(strings.Trim(v, `"`), ",") s := map[string]string{} diff --git a/driver/kubernetes/manifest/manifest.go b/driver/kubernetes/manifest/manifest.go index 9c9c390a..5f5467c8 100644 --- a/driver/kubernetes/manifest/manifest.go +++ b/driver/kubernetes/manifest/manifest.go @@ -14,10 +14,11 @@ import ( ) type DeploymentOpt struct { - Namespace string - Name string - Image string - Replicas int + Namespace string + Name string + Image string + Replicas int + ServiceAccountName string // Qemu Qemu struct { @@ -80,6 +81,7 @@ func NewDeployment(opt *DeploymentOpt) (d *appsv1.Deployment, c []*corev1.Config Annotations: annotations, }, Spec: corev1.PodSpec{ + ServiceAccountName: opt.ServiceAccountName, Containers: []corev1.Container{ { Name: containerName,