mirror of
https://github.com/wassname/ray.git
synced 2026-06-27 17:49:47 +08:00
Customize service account name. (#8901)
This commit is contained in:
@@ -64,7 +64,7 @@ controller-gen:
|
||||
ifeq (, $(shell which controller-gen))
|
||||
@{ \
|
||||
set -e ;\
|
||||
CONTROLLER_GEN_TMP_DIR=$$(mktemp -d)" ;\
|
||||
CONTROLLER_GEN_TMP_DIR="$$(mktemp -d)" ;\
|
||||
cd "$$CONTROLLER_GEN_TMP_DIR" ;\
|
||||
go mod init tmp ;\
|
||||
go get sigs.k8s.io/controller-tools/cmd/controller-gen@v0.2.2 ;\
|
||||
|
||||
@@ -98,6 +98,9 @@ type Extension struct {
|
||||
// but do not directly imply semantics to the core system. Labels can be used to organize and to select subsets of objects.
|
||||
Labels map[string]string `json:"labels,omitempty"`
|
||||
|
||||
// The service acccount name.
|
||||
ServiceAccountName string `json:"serviceAccountName,omitempty"`
|
||||
|
||||
// NodeSelector specifies a map of key-value pairs. For the pod to be eligible
|
||||
// to run on a node, the node must have each of the indicated key-value pairs as
|
||||
// labels. Optional.
|
||||
|
||||
@@ -836,6 +836,9 @@ spec:
|
||||
to an implementation-defined value. More info: https://kubernetes.io/docs/concepts/configuration/manage-compute-resources-container/'
|
||||
type: object
|
||||
type: object
|
||||
serviceAccountName:
|
||||
description: The service acccount name.
|
||||
type: string
|
||||
tolerations:
|
||||
description: The pod this Toleration is attached to tolerates
|
||||
any taint that matches the triple <key,value,effect> using the
|
||||
|
||||
@@ -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{
|
||||
|
||||
Reference in New Issue
Block a user