Skip to content

Commit 9fdf7a4

Browse files
committed
Support serverPod.automountServiceAccountToken
1 parent 5bf77ae commit 9fdf7a4

File tree

13 files changed

+88
-5
lines changed

13 files changed

+88
-5
lines changed

documentation/domains/Cluster.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,10 @@
234234
"$ref": "https://raw.githubusercontent.com/yannh/kubernetes-json-schema/master/v1.28.2/_definitions.json#/definitions/io.k8s.api.core.v1.Toleration"
235235
}
236236
},
237+
"automountServiceAccountToken": {
238+
"description": "Indicates whether a service account token should be automatically mounted on the pod. Defaults to true if not set. See `kubectl explain pods.spec.automountServiceAccountToken`.",
239+
"type": "boolean"
240+
},
237241
"readinessProbe": {
238242
"description": "Settings for the readiness probe associated with a WebLogic Server instance. If not specified, the operator will create an HTTP probe accessing the /weblogic/ready path. If an HTTP probe is specified then the operator will fill in `path`, `port`, and `scheme`, if they are missing. The operator will also fill in any missing tuning-related fields if they are unspecified. Tuning-related fields will be inherited from the domain and cluster scopes unless a more specific scope defines a different action, such as a different HTTP path to access.",
239243
"$ref": "https://raw.githubusercontent.com/yannh/kubernetes-json-schema/master/v1.28.2/_definitions.json#/definitions/io.k8s.api.core.v1.Probe"

documentation/domains/Cluster.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ The specification of the operation of the WebLogic cluster. Required.
5555
| --- | --- | --- |
5656
| `affinity` | [Affinity](k8s1.28.2.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. |
58+
| `automountServiceAccountToken` | Boolean | Indicates whether a service account token should be automatically mounted on the pod. Defaults to true if not set. See `kubectl explain pods.spec.automountServiceAccountToken`. |
5859
| `containers` | Array of [Container](k8s1.28.2.md#container) | Additional containers to be included in the server Pod. See `kubectl explain pods.spec.containers`. |
5960
| `containerSecurityContext` | [Security Context](k8s1.28.2.md#security-context) | Container-level security attributes. Will override any matching Pod-level attributes. See `kubectl explain pods.spec.containers.securityContext`. 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/. |
6061
| `env` | Array of [Env Var](k8s1.28.2.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`. |

documentation/domains/Domain.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1107,6 +1107,10 @@
11071107
"$ref": "https://raw.githubusercontent.com/yannh/kubernetes-json-schema/master/v1.28.2/_definitions.json#/definitions/io.k8s.api.core.v1.Toleration"
11081108
}
11091109
},
1110+
"automountServiceAccountToken": {
1111+
"description": "Indicates whether a service account token should be automatically mounted on the pod. Defaults to true if not set. See `kubectl explain pods.spec.automountServiceAccountToken`.",
1112+
"type": "boolean"
1113+
},
11101114
"readinessProbe": {
11111115
"description": "Settings for the readiness probe associated with a WebLogic Server instance. If not specified, the operator will create an HTTP probe accessing the /weblogic/ready path. If an HTTP probe is specified then the operator will fill in `path`, `port`, and `scheme`, if they are missing. The operator will also fill in any missing tuning-related fields if they are unspecified. Tuning-related fields will be inherited from the domain and cluster scopes unless a more specific scope defines a different action, such as a different HTTP path to access.",
11121116
"$ref": "https://raw.githubusercontent.com/yannh/kubernetes-json-schema/master/v1.28.2/_definitions.json#/definitions/io.k8s.api.core.v1.Probe"

documentation/domains/Domain.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,7 @@ The current status of the operation of the WebLogic domain. Updated automaticall
156156
| --- | --- | --- |
157157
| `affinity` | [Affinity](k8s1.28.2.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`. |
158158
| `annotations` | Map | The annotations to be added to generated resources. |
159+
| `automountServiceAccountToken` | Boolean | Indicates whether a service account token should be automatically mounted on the pod. Defaults to true if not set. See `kubectl explain pods.spec.automountServiceAccountToken`. |
159160
| `containers` | Array of [Container](k8s1.28.2.md#container) | Additional containers to be included in the server Pod. See `kubectl explain pods.spec.containers`. |
160161
| `containerSecurityContext` | [Security Context](k8s1.28.2.md#security-context) | Container-level security attributes. Will override any matching Pod-level attributes. See `kubectl explain pods.spec.containers.securityContext`. 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/. |
161162
| `env` | Array of [Env Var](k8s1.28.2.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`. |

integration-tests/src/test/java/oracle/weblogic/domain/ServerPod.java

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright (c) 2020, 2022, Oracle and/or its affiliates.
1+
// Copyright (c) 2020, 2025, 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
package oracle.weblogic.domain;
@@ -96,6 +96,11 @@ public class ServerPod {
9696
+ "ServiceAccount will be used. The ServiceAccount has to exist at the time the pod is created.")
9797
private String serviceAccountName;
9898

99+
@ApiModelProperty(
100+
"Indicates whether a service account token should be automatically mounted on the pod. "
101+
+ "Defaults to true if not set. See `kubectl explain pods.spec.automountServiceAccountToken`.")
102+
private Boolean automountServiceAccountToken = null;
103+
99104
@ApiModelProperty("Memory and CPU minimum requirements and limits for the server.")
100105
private V1ResourceRequirements resources;
101106

@@ -462,6 +467,23 @@ public void setServiceAccountName(String serviceAccountName) {
462467
this.serviceAccountName = serviceAccountName;
463468
}
464469

470+
public ServerPod automountServiceAccountToken(Boolean automountServiceAccountToken) {
471+
this.automountServiceAccountToken = automountServiceAccountToken;
472+
return this;
473+
}
474+
475+
public Boolean automountServiceAccountToken() {
476+
return automountServiceAccountToken;
477+
}
478+
479+
public Boolean getAutomountServiceAccountToken() {
480+
return automountServiceAccountToken;
481+
}
482+
483+
public void setAutomountServiceAccountToken(Boolean automountServiceAccountToken) {
484+
this.automountServiceAccountToken = automountServiceAccountToken;
485+
}
486+
465487
public ServerPod resources(V1ResourceRequirements resources) {
466488
this.resources = resources;
467489
return this;

kubernetes/crd/cluster-crd.yaml

Lines changed: 6 additions & 1 deletion
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: 34ed6e0ff57580da665db440dce607569f175d0d93934c0e31b2ab26e7ede28d
8+
weblogic.sha256: 251af6bc71a6c64c9f40bf8b60f5eee1a82dbf32a3439f7fe035c0baa89280bd
99
name: clusters.weblogic.oracle
1010
spec:
1111
group: weblogic.oracle
@@ -329,6 +329,11 @@ spec:
329329
operator:
330330
type: string
331331
type: array
332+
automountServiceAccountToken:
333+
description: Indicates whether a service account token should
334+
be automatically mounted on the pod. Defaults to true if not
335+
set. See `kubectl explain pods.spec.automountServiceAccountToken`.
336+
type: boolean
332337
readinessProbe:
333338
description: Settings for the readiness probe associated with
334339
a WebLogic Server instance. If not specified, the operator will

kubernetes/crd/domain-crd.yaml

Lines changed: 16 additions & 1 deletion
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: 3c9cb1077e51677d24c80535ad61c7b524c415e44dda7eda48e9e344f4bb3809
8+
weblogic.sha256: d5781dca31795f836ae89e7139d88fce344b88395f61659d8c7c912467c70a98
99
name: domains.weblogic.oracle
1010
spec:
1111
group: weblogic.oracle
@@ -1433,6 +1433,11 @@ spec:
14331433
operator:
14341434
type: string
14351435
type: array
1436+
automountServiceAccountToken:
1437+
description: Indicates whether a service account token should
1438+
be automatically mounted on the pod. Defaults to true if
1439+
not set. See `kubectl explain pods.spec.automountServiceAccountToken`.
1440+
type: boolean
14361441
readinessProbe:
14371442
description: Settings for the readiness probe associated with
14381443
a WebLogic Server instance. If not specified, the operator
@@ -5216,6 +5221,11 @@ spec:
52165221
operator:
52175222
type: string
52185223
type: array
5224+
automountServiceAccountToken:
5225+
description: Indicates whether a service account token should
5226+
be automatically mounted on the pod. Defaults to true if not
5227+
set. See `kubectl explain pods.spec.automountServiceAccountToken`.
5228+
type: boolean
52195229
readinessProbe:
52205230
description: Settings for the readiness probe associated with
52215231
a WebLogic Server instance. If not specified, the operator will
@@ -8107,6 +8117,11 @@ spec:
81078117
type: string
81088118
operator:
81098119
type: string
8120+
automountServiceAccountToken:
8121+
description: Indicates whether a service account token should
8122+
be automatically mounted on the pod. Defaults to true
8123+
if not set. See `kubectl explain pods.spec.automountServiceAccountToken`.
8124+
type: boolean
81108125
readinessProbe:
81118126
description: Settings for the readiness probe associated
81128127
with a WebLogic Server instance. If not specified, the

operator/src/main/java/oracle/kubernetes/operator/helpers/BasePodStepContext.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright (c) 2019, 2024, Oracle and/or its affiliates.
1+
// Copyright (c) 2019, 2025, 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
package oracle.kubernetes.operator.helpers;
@@ -228,6 +228,7 @@ protected V1PodSpec createPodSpec() {
228228
.topologySpreadConstraints(getTopologySpreadConstraints())
229229
.nodeSelector(getServerSpec().getNodeSelectors())
230230
.serviceAccountName(getServerSpec().getServiceAccountName())
231+
.automountServiceAccountToken(getServerSpec().getAutomountServiceAccountToken())
231232
.nodeName(getServerSpec().getNodeName())
232233
.schedulerName(getServerSpec().getSchedulerName())
233234
.priorityClassName(getServerSpec().getPriorityClassName())

operator/src/main/java/oracle/kubernetes/operator/helpers/JobStepContext.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -584,6 +584,7 @@ protected V1PodSpec createPodSpec() {
584584
.activeDeadlineSeconds(getActiveDeadlineSeconds())
585585
.restartPolicy("Never")
586586
.serviceAccountName(info.getDomain().getSpec().getServiceAccountName())
587+
.automountServiceAccountToken(info.getDomain().getSpec().getAutomountServiceAccountToken())
587588
.addVolumesItem(new V1Volume().name(SECRETS_VOLUME).secret(getSecretsVolume()))
588589
.addVolumesItem(
589590
new V1Volume().name(SCRIPTS_VOLUME).configMap(getConfigMapVolumeSource()))

operator/src/main/java/oracle/kubernetes/operator/processing/EffectiveServerSpec.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright (c) 2018, 2024, Oracle and/or its affiliates.
1+
// Copyright (c) 2018, 2025, 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
package oracle.kubernetes.operator.processing;
@@ -162,6 +162,8 @@ public interface EffectiveServerSpec {
162162

163163
String getServiceAccountName();
164164

165+
Boolean getAutomountServiceAccountToken();
166+
165167
String getSchedulerName();
166168

167169
List<V1Toleration> getTolerations();

0 commit comments

Comments
 (0)