(api spec.API)
| 316 | } |
| 317 | |
| 318 | func userPodContainers(api spec.API) ([]kcore.Container, []kcore.Volume) { |
| 319 | volumes := []kcore.Volume{ |
| 320 | MntVolume(), |
| 321 | CortexVolume(), |
| 322 | ClientConfigVolume(), |
| 323 | } |
| 324 | containerMounts := []kcore.VolumeMount{ |
| 325 | MntMount(), |
| 326 | CortexMount(), |
| 327 | ClientConfigMount(), |
| 328 | } |
| 329 | |
| 330 | containers := make([]kcore.Container, len(api.Pod.Containers)) |
| 331 | for i, container := range api.Pod.Containers { |
| 332 | containerResourceList := kcore.ResourceList{} |
| 333 | containerResourceLimitsList := kcore.ResourceList{} |
| 334 | securityContext := kcore.SecurityContext{ |
| 335 | Privileged: pointer.Bool(true), |
| 336 | } |
| 337 | |
| 338 | var readinessProbe *kcore.Probe |
| 339 | if api.Kind == userconfig.RealtimeAPIKind { |
| 340 | readinessProbe = GetProbeSpec(container.ReadinessProbe) |
| 341 | } |
| 342 | |
| 343 | if container.Compute.CPU != nil { |
| 344 | containerResourceList[kcore.ResourceCPU] = *k8s.QuantityPtr(container.Compute.CPU.Quantity.DeepCopy()) |
| 345 | } |
| 346 | |
| 347 | if container.Compute.Mem != nil { |
| 348 | containerResourceList[kcore.ResourceMemory] = *k8s.QuantityPtr(container.Compute.Mem.Quantity.DeepCopy()) |
| 349 | } |
| 350 | |
| 351 | if container.Compute.GPU > 0 { |
| 352 | containerResourceList["nvidia.com/gpu"] = *kresource.NewQuantity(container.Compute.GPU, kresource.DecimalSI) |
| 353 | containerResourceLimitsList["nvidia.com/gpu"] = *kresource.NewQuantity(container.Compute.GPU, kresource.DecimalSI) |
| 354 | } |
| 355 | |
| 356 | if container.Compute.Inf > 0 { |
| 357 | totalHugePages := container.Compute.Inf * _hugePagesMemPerInf |
| 358 | containerResourceList["aws.amazon.com/neuron"] = *kresource.NewQuantity(container.Compute.Inf, kresource.DecimalSI) |
| 359 | containerResourceList["hugepages-2Mi"] = *kresource.NewQuantity(totalHugePages, kresource.BinarySI) |
| 360 | containerResourceLimitsList["aws.amazon.com/neuron"] = *kresource.NewQuantity(container.Compute.Inf, kresource.DecimalSI) |
| 361 | containerResourceLimitsList["hugepages-2Mi"] = *kresource.NewQuantity(totalHugePages, kresource.BinarySI) |
| 362 | |
| 363 | securityContext.Capabilities = &kcore.Capabilities{ |
| 364 | Add: []kcore.Capability{ |
| 365 | "SYS_ADMIN", |
| 366 | "IPC_LOCK", |
| 367 | }, |
| 368 | } |
| 369 | } |
| 370 | |
| 371 | if container.Compute.Shm != nil { |
| 372 | volumes = append(volumes, ShmVolume(container.Compute.Shm.Quantity, "dshm-"+container.Name)) |
| 373 | containerMounts = append(containerMounts, ShmMount("dshm-"+container.Name)) |
| 374 | } |
| 375 |
no test coverage detected