TransformSandboxDevicePlugin transforms sandbox-device-plugin daemonset with required config as per ClusterPolicy
(obj *appsv1.DaemonSet, config *gpuv1.ClusterPolicySpec, n ClusterPolicyController)
| 1685 | |
| 1686 | // TransformSandboxDevicePlugin transforms sandbox-device-plugin daemonset with required config as per ClusterPolicy |
| 1687 | func TransformSandboxDevicePlugin(obj *appsv1.DaemonSet, config *gpuv1.ClusterPolicySpec, n ClusterPolicyController) error { |
| 1688 | // update validation container |
| 1689 | err := transformValidationInitContainer(obj, config) |
| 1690 | if err != nil { |
| 1691 | return err |
| 1692 | } |
| 1693 | // update image |
| 1694 | image, err := gpuv1.ImagePath(&config.SandboxDevicePlugin) |
| 1695 | if err != nil { |
| 1696 | return err |
| 1697 | } |
| 1698 | obj.Spec.Template.Spec.Containers[0].Image = image |
| 1699 | |
| 1700 | // update image pull policy |
| 1701 | obj.Spec.Template.Spec.Containers[0].ImagePullPolicy = gpuv1.ImagePullPolicy(config.SandboxDevicePlugin.ImagePullPolicy) |
| 1702 | // set image pull secrets |
| 1703 | if len(config.SandboxDevicePlugin.ImagePullSecrets) > 0 { |
| 1704 | addPullSecrets(&obj.Spec.Template.Spec, config.SandboxDevicePlugin.ImagePullSecrets) |
| 1705 | } |
| 1706 | // set resource limits |
| 1707 | if config.SandboxDevicePlugin.Resources != nil { |
| 1708 | // apply resource limits to all containers |
| 1709 | for i := range obj.Spec.Template.Spec.Containers { |
| 1710 | obj.Spec.Template.Spec.Containers[i].Resources.Requests = config.SandboxDevicePlugin.Resources.Requests |
| 1711 | obj.Spec.Template.Spec.Containers[i].Resources.Limits = config.SandboxDevicePlugin.Resources.Limits |
| 1712 | } |
| 1713 | } |
| 1714 | // set arguments if specified for device-plugin container |
| 1715 | if len(config.SandboxDevicePlugin.Args) > 0 { |
| 1716 | obj.Spec.Template.Spec.Containers[0].Args = config.SandboxDevicePlugin.Args |
| 1717 | } |
| 1718 | // set/append environment variables for device-plugin container |
| 1719 | if len(config.SandboxDevicePlugin.Env) > 0 { |
| 1720 | for _, env := range config.SandboxDevicePlugin.Env { |
| 1721 | setContainerEnv(&(obj.Spec.Template.Spec.Containers[0]), env.Name, env.Value) |
| 1722 | } |
| 1723 | } |
| 1724 | |
| 1725 | // set hostNetwork for sandbox-device-plugin if specified |
| 1726 | applyHostNetworkConfig(&obj.Spec.Template.Spec, config.SandboxDevicePlugin.HostNetwork) |
| 1727 | |
| 1728 | return nil |
| 1729 | } |
| 1730 | |
| 1731 | // TransformKataDevicePlugin transforms kata-device-plugin daemonset with required config as per ClusterPolicy |
| 1732 | func TransformKataDevicePlugin(obj *appsv1.DaemonSet, config *gpuv1.ClusterPolicySpec, n ClusterPolicyController) error { |
nothing calls this directly
no test coverage detected