Customize service account name. (#8901)

This commit is contained in:
acmore
2020-06-16 12:49:41 -05:00
committed by GitHub
parent 4facac023f
commit fa0a677aac
4 changed files with 19 additions and 4 deletions
+12 -3
View File
@@ -1,10 +1,15 @@
package common
import (
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
rayiov1alpha1 "ray-operator/api/v1alpha1"
"strings"
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)
const (
defaultServiceAccountName = "default"
)
type PodConfig struct {
@@ -28,12 +33,16 @@ func BuildPod(conf *PodConfig) *corev1.Pod {
// Build the containers for the pod (there is currently only one).
containers := []corev1.Container{buildContainer(conf)}
serviceAccountName := defaultServiceAccountName
if len(conf.Extension.ServiceAccountName) > 0 {
serviceAccountName = conf.Extension.ServiceAccountName
}
spec := corev1.PodSpec{
Volumes: conf.Extension.Volumes,
Containers: containers,
Affinity: conf.Extension.Affinity,
Tolerations: conf.Extension.Tolerations,
ServiceAccountName: conf.RayCluster.Namespace,
ServiceAccountName: serviceAccountName,
}
pod := &corev1.Pod{