From 65037e461124a4d0058817bb839a84c88b16546f Mon Sep 17 00:00:00 2001 From: robertlestak Date: Fri, 3 Feb 2023 18:46:08 -0800 Subject: [PATCH] kubernetes driver: add serviceaccount opt Signed-off-by: robertlestak --- driver/kubernetes/factory.go | 2 ++ driver/kubernetes/manifest/manifest.go | 10 ++++++---- 2 files changed, 8 insertions(+), 4 deletions(-) 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,