|
6 | 6 | "hash/fnv"
|
7 | 7 | "strings"
|
8 | 8 |
|
| 9 | + "github.com/operator-framework/operator-lifecycle-manager/pkg/controller/security" |
9 | 10 | corev1 "k8s.io/api/core/v1"
|
10 | 11 | "k8s.io/apimachinery/pkg/api/resource"
|
11 | 12 | metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
@@ -113,14 +114,6 @@ func Pod(source *operatorsv1alpha1.CatalogSource, name string, image string, saN
|
113 | 114 | pullPolicy = corev1.PullAlways
|
114 | 115 | }
|
115 | 116 |
|
116 |
| - // Security context |
117 |
| - readOnlyRootFilesystem := false |
118 |
| - allowPrivilegeEscalation := false |
119 |
| - runAsNonRoot := true |
120 |
| - |
121 |
| - // See: https://github.com/operator-framework/operator-registry/blob/master/Dockerfile#L27 |
122 |
| - runAsUser := int64(1001) |
123 |
| - |
124 | 117 | pod := &corev1.Pod{
|
125 | 118 | ObjectMeta: metav1.ObjectMeta{
|
126 | 119 | GenerateName: source.GetName() + "-",
|
@@ -172,31 +165,20 @@ func Pod(source *operatorsv1alpha1.CatalogSource, name string, image string, saN
|
172 | 165 | corev1.ResourceMemory: resource.MustParse("50Mi"),
|
173 | 166 | },
|
174 | 167 | },
|
175 |
| - SecurityContext: &corev1.SecurityContext{ |
176 |
| - ReadOnlyRootFilesystem: &readOnlyRootFilesystem, |
177 |
| - AllowPrivilegeEscalation: &allowPrivilegeEscalation, |
178 |
| - Capabilities: &corev1.Capabilities{ |
179 |
| - Drop: []corev1.Capability{"ALL"}, |
180 |
| - }, |
181 |
| - }, |
182 | 168 | ImagePullPolicy: pullPolicy,
|
183 | 169 | TerminationMessagePolicy: corev1.TerminationMessageFallbackToLogsOnError,
|
184 | 170 | },
|
185 | 171 | },
|
186 |
| - SecurityContext: &corev1.PodSecurityContext{ |
187 |
| - RunAsNonRoot: &runAsNonRoot, |
188 |
| - RunAsUser: &runAsUser, |
189 |
| - SeccompProfile: &corev1.SeccompProfile{ |
190 |
| - Type: corev1.SeccompProfileTypeRuntimeDefault, |
191 |
| - }, |
192 |
| - }, |
193 | 172 | NodeSelector: map[string]string{
|
194 | 173 | "kubernetes.io/os": "linux",
|
195 | 174 | },
|
196 | 175 | ServiceAccountName: saName,
|
197 | 176 | },
|
198 | 177 | }
|
199 | 178 |
|
| 179 | + // Update pod security |
| 180 | + security.ApplyPodSpecSecurity(&pod.Spec) |
| 181 | + |
200 | 182 | // Override scheduling options if specified
|
201 | 183 | if source.Spec.GrpcPodConfig != nil {
|
202 | 184 | grpcPodConfig := source.Spec.GrpcPodConfig
|
|
0 commit comments