Skip to content

Commit ae1a51e

Browse files
authored
Adjust pod security for V8o requirements (#3897)
* Adjust pod security for V8o requirements
1 parent fb8046b commit ae1a51e

File tree

19 files changed

+198
-58
lines changed

19 files changed

+198
-58
lines changed

Dockerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright (c) 2017, 2022, Oracle and/or its affiliates.
1+
# Copyright (c) 2017, 2023, Oracle and/or its affiliates.
22
# Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl.
33
#
44
# HOW TO BUILD THIS IMAGE
@@ -9,7 +9,7 @@
99
# -------------------------
1010
FROM ghcr.io/oracle/oraclelinux:9-slim AS jre-build
1111

12-
ENV JAVA_URL="https://download.java.net/java/GA/jdk19.0.1/afdd2e245b014143b62ccb916125e3ce/10/GPL/openjdk-19.0.1_linux-x64_bin.tar.gz"
12+
ENV JAVA_URL="https://download.java.net/java/GA/jdk19.0.2/fdb695a9d9064ad6b064dc6df578380c/7/GPL/openjdk-19.0.2_linux-x64_bin.tar.gz"
1313

1414
RUN set -eux; \
1515
microdnf -y install gzip tar; \

documentation/4.0/content/security/domain-security/image-protection.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
title: "Container image protection"
33
date: 2019-03-08T19:00:49-05:00
4-
weight: 1
4+
weight: 2
55
description: "WebLogic domain in image protection."
66
---
77

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
---
2+
title: "Pod and container security"
3+
date: 2019-03-08T19:00:49-05:00
4+
weight: 1
5+
description: "Pod and container security."
6+
---
7+
8+
The WebLogic Kubernetes Operator [enforces pod and container security best practices](https://kubernetes.io/docs/concepts/security/pod-security-standards/)
9+
for the pods and containers that the operator creates for WebLogic Server instances, the init container for
10+
auxiliary images, sidecar containers for Fluentd or the WebLogic Monitoring Exporter, and the introspection job.
11+
12+
Beginning with operator version 4.0.5, the operator adds the following pod-level `securityContext` content:
13+
14+
```yaml
15+
securityContext:
16+
seccompProfile:
17+
type: RuntimeDefault
18+
```
19+
20+
The operator also adds the following container-level `securityContext` content to each container:
21+
22+
```yaml
23+
securityContext:
24+
runAsUser: 1000
25+
runAsNonRoot: true
26+
privileged: false
27+
allowPrivilegeEscalation: false
28+
capabilities:
29+
drop:
30+
- ALL
31+
```
32+
33+
On OpenShift environments, the operator omits the `runAsUser` element.
34+
35+
Customers can [configure pod and container generation](https://oracle.github.io/weblogic-kubernetes-operator/managing-domains/domain-resource/#domain-and-cluster-spec-elements)
36+
for WebLogic Server instances using the `serverPod` element in the Domain resource. If specified, the operator will use the
37+
`serverPod.podSecurityContext` or `serverPod.containerSecurityContext` content from the Domain resource rather than using the default content shown previously.

documentation/4.0/content/security/domain-security/weblogic-channels.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
title: "External network access security"
33
date: 2019-03-08T19:07:36-05:00
4-
weight: 2
4+
weight: 3
55
description: "Remote access security."
66
---
77

documentation/domains/Cluster.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -867,7 +867,7 @@
867867
"type": "string"
868868
},
869869
"podSecurityContext": {
870-
"description": "Pod-level security attributes. See `kubectl explain pods.spec.securityContext`.",
870+
"description": "Pod-level security attributes. See `kubectl explain pods.spec.securityContext`. Beginning with operator version 4.0.5, if no value is specified for this field, the operator will use default content for the pod-level `securityContext`. More info: https://oracle.github.io/weblogic-kubernetes-operator/security/domain-security/pod-and-container/.",
871871
"$ref": "https://github.com/garethr/kubernetes-json-schema/blob/master/v1.13.5/_definitions.json#/definitions/io.k8s.api.core.v1.PodSecurityContext"
872872
},
873873
"priorityClassName": {
@@ -918,7 +918,7 @@
918918
"$ref": "#/definitions/ProbeTuning"
919919
},
920920
"containerSecurityContext": {
921-
"description": "Container-level security attributes. Will override any matching Pod-level attributes. See `kubectl explain pods.spec.containers.securityContext`.",
921+
"description": "Container-level security attributes. Will override any matching Pod-level attributes. See `kubectl explain pods.spec.containers.securityContext`. Beginning with operator version 4.0.5, if no value is specified for this field, the operator will use default content for container-level `securityContext`. More info: https://oracle.github.io/weblogic-kubernetes-operator/security/domain-security/pod-and-container/.",
922922
"$ref": "https://github.com/garethr/kubernetes-json-schema/blob/master/v1.13.5/_definitions.json#/definitions/io.k8s.api.core.v1.SecurityContext"
923923
},
924924
"schedulerName": {

documentation/domains/Cluster.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ The specification of the operation of the WebLogic cluster. Required.
5656
| `affinity` | [Affinity](k8s1.13.5.md#affinity) | The Pod's scheduling constraints. More info: https://oracle.github.io/weblogic-kubernetes-operator/faq/node-heating/. See `kubectl explain pods.spec.affinity`. |
5757
| `annotations` | Map | The annotations to be added to generated resources. |
5858
| `containers` | Array of [Container](k8s1.13.5.md#container) | Additional containers to be included in the server Pod. See `kubectl explain pods.spec.containers`. |
59-
| `containerSecurityContext` | [Security Context](k8s1.13.5.md#security-context) | Container-level security attributes. Will override any matching Pod-level attributes. See `kubectl explain pods.spec.containers.securityContext`. |
59+
| `containerSecurityContext` | [Security Context](k8s1.13.5.md#security-context) | Container-level security attributes. Will override any matching Pod-level attributes. See `kubectl explain pods.spec.containers.securityContext`. Beginning with operator version 4.0.5, if no value is specified for this field, the operator will use default content for container-level `securityContext`. More info: https://oracle.github.io/weblogic-kubernetes-operator/security/domain-security/pod-and-container/. |
6060
| `env` | Array of [Env Var](k8s1.13.5.md#env-var) | A list of environment variables to set in the container running a WebLogic Server instance. More info: https://oracle.github.io/weblogic-kubernetes-operator/userguide/managing-domains/domain-resource/#jvm-memory-and-java-option-environment-variables. See `kubectl explain pods.spec.containers.env`. |
6161
| `hostAliases` | Array of [Host Alias](k8s1.13.5.md#host-alias) | HostAliases is an optional list of hosts and IPs that will be injected into the pod's hosts file if specified. This is only valid for non-hostNetwork pods. |
6262
| `initContainers` | Array of [Container](k8s1.13.5.md#container) | Initialization containers to be included in the server Pod. See `kubectl explain pods.spec.initContainers`. |
@@ -66,7 +66,7 @@ The specification of the operation of the WebLogic cluster. Required.
6666
| `maxReadyWaitTimeSeconds` | integer | The maximum time in seconds that the operator waits for a WebLogic Server pod to reach the ready state before it considers the pod failed. Defaults to 1800 seconds. |
6767
| `nodeName` | string | NodeName is a request to schedule this Pod onto a specific Node. If it is non-empty, the scheduler simply schedules this pod onto that node, assuming that it fits the resource requirements. See `kubectl explain pods.spec.nodeName`. |
6868
| `nodeSelector` | Map | Selector which must match a Node's labels for the Pod to be scheduled on that Node. See `kubectl explain pods.spec.nodeSelector`. |
69-
| `podSecurityContext` | [Pod Security Context](k8s1.13.5.md#pod-security-context) | Pod-level security attributes. See `kubectl explain pods.spec.securityContext`. |
69+
| `podSecurityContext` | [Pod Security Context](k8s1.13.5.md#pod-security-context) | Pod-level security attributes. See `kubectl explain pods.spec.securityContext`. Beginning with operator version 4.0.5, if no value is specified for this field, the operator will use default content for the pod-level `securityContext`. More info: https://oracle.github.io/weblogic-kubernetes-operator/security/domain-security/pod-and-container/. |
7070
| `priorityClassName` | string | If specified, indicates the Pod's priority. "system-node-critical" and "system-cluster-critical" are two special keywords which indicate the highest priorities with the former being the highest priority. Any other name must be defined by creating a PriorityClass object with that name. If not specified, the pod priority will be the default or zero, if there is no default. See `kubectl explain pods.spec.priorityClassName`. |
7171
| `readinessGates` | Array of [Pod Readiness Gate](k8s1.13.5.md#pod-readiness-gate) | If specified, all readiness gates will be evaluated for Pod readiness. A Pod is ready when all its containers are ready AND all conditions specified in the readiness gates have a status equal to "True". More info: https://github.com/kubernetes/community/blob/master/keps/sig-network/0007-pod-ready%2B%2B.md. |
7272
| `readinessProbe` | [Probe Tuning](#probe-tuning) | Settings for the readiness probe associated with a WebLogic Server instance. |

documentation/domains/Domain.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -786,7 +786,7 @@
786786
"type": "string"
787787
},
788788
"podSecurityContext": {
789-
"description": "Pod-level security attributes. See `kubectl explain pods.spec.securityContext`.",
789+
"description": "Pod-level security attributes. See `kubectl explain pods.spec.securityContext`. Beginning with operator version 4.0.5, if no value is specified for this field, the operator will use default content for the pod-level `securityContext`. More info: https://oracle.github.io/weblogic-kubernetes-operator/security/domain-security/pod-and-container/.",
790790
"$ref": "https://github.com/garethr/kubernetes-json-schema/blob/master/v1.13.5/_definitions.json#/definitions/io.k8s.api.core.v1.PodSecurityContext"
791791
},
792792
"priorityClassName": {
@@ -837,7 +837,7 @@
837837
"$ref": "#/definitions/ProbeTuning"
838838
},
839839
"containerSecurityContext": {
840-
"description": "Container-level security attributes. Will override any matching Pod-level attributes. See `kubectl explain pods.spec.containers.securityContext`.",
840+
"description": "Container-level security attributes. Will override any matching Pod-level attributes. See `kubectl explain pods.spec.containers.securityContext`. Beginning with operator version 4.0.5, if no value is specified for this field, the operator will use default content for container-level `securityContext`. More info: https://oracle.github.io/weblogic-kubernetes-operator/security/domain-security/pod-and-container/.",
841841
"$ref": "https://github.com/garethr/kubernetes-json-schema/blob/master/v1.13.5/_definitions.json#/definitions/io.k8s.api.core.v1.SecurityContext"
842842
},
843843
"schedulerName": {

documentation/domains/Domain.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ The current status of the operation of the WebLogic domain. Updated automaticall
131131
| `affinity` | [Affinity](k8s1.13.5.md#affinity) | The Pod's scheduling constraints. More info: https://oracle.github.io/weblogic-kubernetes-operator/faq/node-heating/. See `kubectl explain pods.spec.affinity`. |
132132
| `annotations` | Map | The annotations to be added to generated resources. |
133133
| `containers` | Array of [Container](k8s1.13.5.md#container) | Additional containers to be included in the server Pod. See `kubectl explain pods.spec.containers`. |
134-
| `containerSecurityContext` | [Security Context](k8s1.13.5.md#security-context) | Container-level security attributes. Will override any matching Pod-level attributes. See `kubectl explain pods.spec.containers.securityContext`. |
134+
| `containerSecurityContext` | [Security Context](k8s1.13.5.md#security-context) | Container-level security attributes. Will override any matching Pod-level attributes. See `kubectl explain pods.spec.containers.securityContext`. Beginning with operator version 4.0.5, if no value is specified for this field, the operator will use default content for container-level `securityContext`. More info: https://oracle.github.io/weblogic-kubernetes-operator/security/domain-security/pod-and-container/. |
135135
| `env` | Array of [Env Var](k8s1.13.5.md#env-var) | A list of environment variables to set in the container running a WebLogic Server instance. More info: https://oracle.github.io/weblogic-kubernetes-operator/userguide/managing-domains/domain-resource/#jvm-memory-and-java-option-environment-variables. See `kubectl explain pods.spec.containers.env`. |
136136
| `hostAliases` | Array of [Host Alias](k8s1.13.5.md#host-alias) | HostAliases is an optional list of hosts and IPs that will be injected into the pod's hosts file if specified. This is only valid for non-hostNetwork pods. |
137137
| `initContainers` | Array of [Container](k8s1.13.5.md#container) | Initialization containers to be included in the server Pod. See `kubectl explain pods.spec.initContainers`. |
@@ -141,7 +141,7 @@ The current status of the operation of the WebLogic domain. Updated automaticall
141141
| `maxReadyWaitTimeSeconds` | integer | The maximum time in seconds that the operator waits for a WebLogic Server pod to reach the ready state before it considers the pod failed. Defaults to 1800 seconds. |
142142
| `nodeName` | string | NodeName is a request to schedule this Pod onto a specific Node. If it is non-empty, the scheduler simply schedules this pod onto that node, assuming that it fits the resource requirements. See `kubectl explain pods.spec.nodeName`. |
143143
| `nodeSelector` | Map | Selector which must match a Node's labels for the Pod to be scheduled on that Node. See `kubectl explain pods.spec.nodeSelector`. |
144-
| `podSecurityContext` | [Pod Security Context](k8s1.13.5.md#pod-security-context) | Pod-level security attributes. See `kubectl explain pods.spec.securityContext`. |
144+
| `podSecurityContext` | [Pod Security Context](k8s1.13.5.md#pod-security-context) | Pod-level security attributes. See `kubectl explain pods.spec.securityContext`. Beginning with operator version 4.0.5, if no value is specified for this field, the operator will use default content for the pod-level `securityContext`. More info: https://oracle.github.io/weblogic-kubernetes-operator/security/domain-security/pod-and-container/. |
145145
| `priorityClassName` | string | If specified, indicates the Pod's priority. "system-node-critical" and "system-cluster-critical" are two special keywords which indicate the highest priorities with the former being the highest priority. Any other name must be defined by creating a PriorityClass object with that name. If not specified, the pod priority will be the default or zero, if there is no default. See `kubectl explain pods.spec.priorityClassName`. |
146146
| `readinessGates` | Array of [Pod Readiness Gate](k8s1.13.5.md#pod-readiness-gate) | If specified, all readiness gates will be evaluated for Pod readiness. A Pod is ready when all its containers are ready AND all conditions specified in the readiness gates have a status equal to "True". More info: https://github.com/kubernetes/community/blob/master/keps/sig-network/0007-pod-ready%2B%2B.md. |
147147
| `readinessProbe` | [Probe Tuning](#probe-tuning) | Settings for the readiness probe associated with a WebLogic Server instance. |

kubernetes/charts/weblogic-operator/templates/_operator-dep.tpl

Lines changed: 16 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright (c) 2018, 2022, Oracle and/or its affiliates.
1+
# Copyright (c) 2018, 2023, Oracle and/or its affiliates.
22
# Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl.
33

44
{{- define "operator.operatorDeployment" }}
@@ -34,10 +34,9 @@ spec:
3434
{{- end }}
3535
spec:
3636
serviceAccountName: {{ .serviceAccount | quote }}
37-
{{- if .runAsUser }}
3837
securityContext:
39-
runAsUser: {{ .runAsUser }}
40-
{{- end }}
38+
seccompProfile:
39+
type: RuntimeDefault
4140
{{- with .nodeSelector }}
4241
nodeSelector:
4342
{{- toYaml . | nindent 8 }}
@@ -109,15 +108,15 @@ spec:
109108
{{- if .memoryLimits}}
110109
memory: {{ .memoryLimits }}
111110
{{- end }}
112-
{{- if (eq ( .kubernetesPlatform | default "Generic" ) "OpenShift") }}
113111
securityContext:
112+
{{- if (ne ( .kubernetesPlatform | default "Generic" ) "OpenShift") }}
113+
runAsUser: {{ .runAsUser | default 1000 }}
114+
{{- end }}
115+
runAsNonRoot: true
116+
privileged: false
114117
allowPrivilegeEscalation: false
115118
capabilities:
116119
drop: ["ALL"]
117-
runAsNonRoot: true
118-
seccompProfile:
119-
type: RuntimeDefault
120-
{{- end }}
121120
volumeMounts:
122121
- name: "weblogic-operator-cm-volume"
123122
mountPath: "/deployment/config"
@@ -259,10 +258,9 @@ spec:
259258
{{- end }}
260259
spec:
261260
serviceAccountName: {{ .serviceAccount | quote }}
262-
{{- if .runAsUser }}
263261
securityContext:
264-
runAsUser: {{ .runAsUser }}
265-
{{- end }}
262+
seccompProfile:
263+
type: RuntimeDefault
266264
{{- with .nodeSelector }}
267265
nodeSelector:
268266
{{- toYaml . | nindent 8 }}
@@ -320,15 +318,15 @@ spec:
320318
{{- if .memoryLimits}}
321319
memory: {{ .memoryLimits }}
322320
{{- end }}
323-
{{- if (eq ( .kubernetesPlatform | default "Generic") "OpenShift") }}
324321
securityContext:
322+
{{- if (ne ( .kubernetesPlatform | default "Generic" ) "OpenShift") }}
323+
runAsUser: {{ .runAsUser | default 1000 }}
324+
{{- end }}
325+
runAsNonRoot: true
326+
privileged: false
325327
allowPrivilegeEscalation: false
326328
capabilities:
327-
drop: ["ALL"]
328-
runAsNonRoot: true
329-
seccompProfile:
330-
type: RuntimeDefault
331-
{{- end }}
329+
drop: ["ALL"]
332330
volumeMounts:
333331
- name: "weblogic-webhook-cm-volume"
334332
mountPath: "/deployment/config"

kubernetes/crd/cluster-crd.yaml

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ apiVersion: apiextensions.k8s.io/v1
55
kind: CustomResourceDefinition
66
metadata:
77
annotations:
8-
weblogic.sha256: 9f051b9b7805fc9100cf6490873e80b91671c7165960bfbcd6e8007ae171937f
8+
weblogic.sha256: ffde049cbfc1e4ed71b15848d7cfcc06b79619f6b7e76bd564d8466c3f045e9f
99
name: clusters.weblogic.oracle
1010
spec:
1111
group: weblogic.oracle
@@ -115,8 +115,11 @@ spec:
115115
See `kubectl explain pods.spec.serviceAccountName`.
116116
type: string
117117
podSecurityContext:
118-
description: Pod-level security attributes. See `kubectl explain
119-
pods.spec.securityContext`.
118+
description: 'Pod-level security attributes. See `kubectl explain
119+
pods.spec.securityContext`. Beginning with operator version
120+
4.0.5, if no value is specified for this field, the operator
121+
will use default content for the pod-level `securityContext`.
122+
More info: https://oracle.github.io/weblogic-kubernetes-operator/security/domain-security/pod-and-container/.'
120123
properties:
121124
runAsUser:
122125
type: integer
@@ -291,8 +294,11 @@ spec:
291294
type: integer
292295
type: object
293296
containerSecurityContext:
294-
description: Container-level security attributes. Will override
297+
description: 'Container-level security attributes. Will override
295298
any matching Pod-level attributes. See `kubectl explain pods.spec.containers.securityContext`.
299+
Beginning with operator version 4.0.5, if no value is specified
300+
for this field, the operator will use default content for container-level
301+
`securityContext`. More info: https://oracle.github.io/weblogic-kubernetes-operator/security/domain-security/pod-and-container/.'
296302
properties:
297303
privileged:
298304
type: boolean

0 commit comments

Comments
 (0)