@@ -25,6 +25,12 @@ import (
2525 appsv1 "k8s.io/api/apps/v1"
2626 corev1 "k8s.io/api/core/v1"
2727 metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
28+ "k8s.io/utils/ptr"
29+ )
30+
31+ const (
32+ // InitContainerCommand -
33+ InitContainerCommand = "/usr/local/bin/container-scripts/init.sh"
2834)
2935
3036// DaemonSet func
@@ -34,18 +40,13 @@ func DaemonSet(
3440 labels map [string ]string ,
3541 annotations map [string ]string ,
3642) * appsv1.DaemonSet {
37- runAsUser := int64 (0 )
3843 serviceName := "octavia-rsyslog"
3944
4045 // The API pod has an extra volume so the API and the provider agent can
4146 // communicate with each other.
4247 volumes := GetVolumes (instance .Name )
43- //parentOctaviaName := octavia.GetOwningOctaviaControllerName(instance)
44- //certsSecretName := fmt.Sprintf("%s-certs-secret", parentOctaviaName)
45- //volumes = append(volumes, GetCertVolume(certsSecretName)...)
4648
4749 volumeMounts := octavia .GetVolumeMounts (serviceName )
48- //volumeMounts = append(volumeMounts, GetCertVolumeMount()...)
4950
5051 livenessProbe := & corev1.Probe {
5152 // TODO might need tuning
@@ -76,6 +77,11 @@ func DaemonSet(
7677 },
7778 }
7879
80+ args := []string {
81+ "-c" ,
82+ InitContainerCommand ,
83+ }
84+
7985 envVars := map [string ]env.Setter {}
8086
8187 envVars ["KOLLA_CONFIG_STRATEGY" ] = env .SetValue ("COPY_ALWAYS" )
@@ -107,9 +113,28 @@ func DaemonSet(
107113 Resources : instance .Spec .Resources ,
108114 ReadinessProbe : readinessProbe ,
109115 LivenessProbe : livenessProbe ,
116+ },
117+ },
118+ InitContainers : []corev1.Container {
119+ {
120+ Name : "init" ,
121+ // TODO(gthiemonge) Using Octavia HM Container image is a workaround to get a container with pyroute2
122+ // Replace it by an init container image with pyroute2 when it's available
123+ // OSPRH-8434
124+ Image : octaviav1 .OctaviaHealthManagerContainerImage ,
110125 SecurityContext : & corev1.SecurityContext {
111- RunAsUser : & runAsUser ,
126+ RunAsUser : ptr .To (int64 (0 )),
127+ Capabilities : & corev1.Capabilities {
128+ Add : []corev1.Capability {"NET_ADMIN" , "NET_RAW" , "SYS_ADMIN" , "SYS_NICE" },
129+ Drop : []corev1.Capability {},
130+ },
131+ },
132+ Command : []string {
133+ "/bin/bash" ,
112134 },
135+ Env : env .MergeEnvs ([]corev1.EnvVar {}, envVars ),
136+ Args : args ,
137+ VolumeMounts : GetInitVolumeMounts (),
113138 },
114139 },
115140 Volumes : volumes ,
@@ -127,19 +152,9 @@ func DaemonSet(
127152 },
128153 corev1 .LabelHostname ,
129154 )
130- if instance . Spec . NodeSelector != nil && len (instance .Spec .NodeSelector ) > 0 {
155+ if len (instance .Spec .NodeSelector ) > 0 {
131156 daemonset .Spec .Template .Spec .NodeSelector = instance .Spec .NodeSelector
132157 }
133158
134- initContainerDetails := APIDetails {
135- // TODO(gthiemonge) Using Octavia HM Container image is a workaround to get a container with pyroute2
136- // Replace it by an init container image with pyroute2 when it's available
137- // OSPRH-8434
138- ContainerImage : octaviav1 .OctaviaHealthManagerContainerImage ,
139- VolumeMounts : octavia .GetInitVolumeMounts (),
140- Env : env .MergeEnvs ([]corev1.EnvVar {}, envVars ),
141- }
142- daemonset .Spec .Template .Spec .InitContainers = InitContainer (initContainerDetails )
143-
144159 return daemonset
145160}
0 commit comments