MCPcopy Create free account
hub / github.com/NVIDIA/gpu-operator / TransformValidatorShared

Function TransformValidatorShared

controllers/object_controls.go:2396–2431  ·  view source on GitHub ↗

TransformValidatorShared applies general transformations to the validator daemonset with required config as per ClusterPolicy

(obj *appsv1.DaemonSet, config *gpuv1.ClusterPolicySpec)

Source from the content-addressed store, hash-verified

2394
2395// TransformValidatorShared applies general transformations to the validator daemonset with required config as per ClusterPolicy
2396func TransformValidatorShared(obj *appsv1.DaemonSet, config *gpuv1.ClusterPolicySpec) error {
2397 // update image
2398 image, err := gpuv1.ImagePath(&config.Validator)
2399 if err != nil {
2400 return err
2401 }
2402 obj.Spec.Template.Spec.Containers[0].Image = image
2403 // update image pull policy
2404 obj.Spec.Template.Spec.Containers[0].ImagePullPolicy = gpuv1.ImagePullPolicy(config.Validator.ImagePullPolicy)
2405 // set image pull secrets
2406 if len(config.Validator.ImagePullSecrets) > 0 {
2407 addPullSecrets(&obj.Spec.Template.Spec, config.Validator.ImagePullSecrets)
2408 }
2409 // set resource limits
2410 if config.Validator.Resources != nil {
2411 // apply resource limits to all containers
2412 for i := range obj.Spec.Template.Spec.Containers {
2413 obj.Spec.Template.Spec.Containers[i].Resources.Requests = config.Validator.Resources.Requests
2414 obj.Spec.Template.Spec.Containers[i].Resources.Limits = config.Validator.Resources.Limits
2415 }
2416 }
2417 // set arguments if specified for validator container
2418 if len(config.Validator.Args) > 0 {
2419 obj.Spec.Template.Spec.Containers[0].Args = config.Validator.Args
2420 }
2421 // set/append environment variables for validator container
2422 if len(config.Validator.Env) > 0 {
2423 for _, env := range config.Validator.Env {
2424 setContainerEnv(&(obj.Spec.Template.Spec.Containers[0]), env.Name, env.Value)
2425 }
2426 }
2427 // update the security context for the validator container
2428 transformValidatorSecurityContext(&obj.Spec.Template.Spec.Containers[0])
2429
2430 return nil
2431}
2432
2433// TransformValidatorComponent applies changes to given validator component
2434func TransformValidatorComponent(config *gpuv1.ClusterPolicySpec, podSpec *corev1.PodSpec, component string) error {

Callers 3

TransformValidatorFunction · 0.85

Calls 3

addPullSecretsFunction · 0.85
setContainerEnvFunction · 0.85

Tested by 1