Skip to content

Commit e7bc6e7

Browse files
committed
Merge branch 'susport-automountServiceAccountToken' into 'main'
Support serverPod.automountServiceAccountToken See merge request weblogic-cloud/weblogic-kubernetes-operator!4930
2 parents d918e30 + 15935eb commit e7bc6e7

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: 3655b015d8b8433e99f974fe3c1a0f58a6522f9ce96297ad99846b92e5bbdb3d
8+
weblogic.sha256: 7b6e1da3b2d3de53d1599a1a661928703204e674280c69b550691315ece7eed9
99
name: clusters.weblogic.oracle
1010
spec:
1111
group: weblogic.oracle
@@ -346,6 +346,11 @@ spec:
346346
operator:
347347
type: string
348348
type: array
349+
automountServiceAccountToken:
350+
description: Indicates whether a service account token should
351+
be automatically mounted on the pod. Defaults to true if not
352+
set. See `kubectl explain pods.spec.automountServiceAccountToken`.
353+
type: boolean
349354
readinessProbe:
350355
description: Settings for the readiness probe associated with
351356
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: 7af2914eff11dd15c13db2abe0271889e45e8f4127e89d6068ab11d91e39dfe6
8+
weblogic.sha256: 29199903d6443114651bf47005d57eacdae7230c7e22b878a1ffbf5ab767f153
99
name: domains.weblogic.oracle
1010
spec:
1111
group: weblogic.oracle
@@ -1451,6 +1451,11 @@ spec:
14511451
operator:
14521452
type: string
14531453
type: array
1454+
automountServiceAccountToken:
1455+
description: Indicates whether a service account token should
1456+
be automatically mounted on the pod. Defaults to true if
1457+
not set. See `kubectl explain pods.spec.automountServiceAccountToken`.
1458+
type: boolean
14541459
readinessProbe:
14551460
description: Settings for the readiness probe associated with
14561461
a WebLogic Server instance. If not specified, the operator
@@ -5432,6 +5437,11 @@ spec:
54325437
operator:
54335438
type: string
54345439
type: array
5440+
automountServiceAccountToken:
5441+
description: Indicates whether a service account token should
5442+
be automatically mounted on the pod. Defaults to true if not
5443+
set. See `kubectl explain pods.spec.automountServiceAccountToken`.
5444+
type: boolean
54355445
readinessProbe:
54365446
description: Settings for the readiness probe associated with
54375447
a WebLogic Server instance. If not specified, the operator will
@@ -8477,6 +8487,11 @@ spec:
84778487
type: string
84788488
operator:
84798489
type: string
8490+
automountServiceAccountToken:
8491+
description: Indicates whether a service account token should
8492+
be automatically mounted on the pod. Defaults to true
8493+
if not set. See `kubectl explain pods.spec.automountServiceAccountToken`.
8494+
type: boolean
84808495
readinessProbe:
84818496
description: Settings for the readiness probe associated
84828497
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
@@ -585,6 +585,7 @@ protected V1PodSpec createPodSpec() {
585585
.activeDeadlineSeconds(getActiveDeadlineSeconds())
586586
.restartPolicy("Never")
587587
.serviceAccountName(info.getDomain().getSpec().getServiceAccountName())
588+
.automountServiceAccountToken(info.getDomain().getSpec().getAutomountServiceAccountToken())
588589
.addVolumesItem(new V1Volume().name(SECRETS_VOLUME).secret(getSecretsVolume()))
589590
.addVolumesItem(
590591
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)