@@ -422,15 +422,6 @@ func constructDeployment(ctx context.Context, app *spinv1alpha1.SpinApp, config
422422 }
423423 maps .Copy (templateLabels , readyLabels )
424424
425- // Add Azure workload identity label if configured
426- if app .Spec .WorkloadIdentity != nil {
427- if val , ok := app .Spec .WorkloadIdentity .ProviderMetadata ["azure" ]; ok {
428- if val == "true" {
429- templateLabels ["azure.workload.identity/use" ] = "true"
430- }
431- }
432- }
433-
434425 // TODO: Once we land admission webhooks write some validation for this e.g.
435426 // don't allow setting memory limit with cyclotron runtime.
436427 resources := corev1.ResourceRequirements {
@@ -453,6 +444,8 @@ func constructDeployment(ctx context.Context, app *spinv1alpha1.SpinApp, config
453444
454445 labels := constructAppLabels (app )
455446
447+ serviceAccountName := getServiceAccountName (ctx , app )
448+
456449 var container corev1.Container
457450 if config .RuntimeClassName != nil {
458451 container = corev1.Container {
@@ -518,7 +511,7 @@ func constructDeployment(ctx context.Context, app *spinv1alpha1.SpinApp, config
518511 },
519512 Spec : corev1.PodSpec {
520513 RuntimeClassName : config .RuntimeClassName ,
521- ServiceAccountName : getServiceAccountName ( app ) ,
514+ ServiceAccountName : serviceAccountName ,
522515 Containers : []corev1.Container {container },
523516 ImagePullSecrets : app .Spec .ImagePullSecrets ,
524517 Volumes : volumes ,
@@ -541,12 +534,22 @@ func constructDeployment(ctx context.Context, app *spinv1alpha1.SpinApp, config
541534}
542535
543536// getServiceAccountName returns the service account name to use for the deployment.
544- // If workload identity is configured, it returns the configured service account name .
537+ // If serviceAccountName is specified on the SpinApp, it returns that value .
545538// Otherwise, it returns "default" which is the Kubernetes default.
546- func getServiceAccountName (app * spinv1alpha1.SpinApp ) string {
547- if app .Spec .WorkloadIdentity != nil {
548- return app .Spec .WorkloadIdentity .ServiceAccountName
539+ func getServiceAccountName (ctx context.Context , app * spinv1alpha1.SpinApp ) string {
540+ log := logging .FromContext (ctx ).WithValues ("component" , "getServiceAccountName" )
541+
542+ log .Debug ("Determining service account name" ,
543+ "app" , app .Name ,
544+ "namespace" , app .Namespace ,
545+ "serviceAccountNameInSpec" , app .Spec .ServiceAccountName )
546+
547+ if app .Spec .ServiceAccountName != "" {
548+ log .Debug ("Using service account from SpinApp" , "serviceAccountName" , app .Spec .ServiceAccountName )
549+ return app .Spec .ServiceAccountName
549550 }
551+
552+ log .Info ("Using default service account" , "serviceAccountName" , "default" )
550553 return "default"
551554}
552555
0 commit comments