Skip to content

Commit bd3757e

Browse files
shangjin92jim.sj
andauthored
fix #207: Support to set environment variables in NameServer pod. (#208)
Co-authored-by: jim.sj <[email protected]>
1 parent e80e97f commit bd3757e

File tree

4 files changed

+213
-0
lines changed

4 files changed

+213
-0
lines changed

charts/rocketmq-operator/crds/rocketmq.apache.org_nameservices.yaml

Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1023,6 +1023,111 @@ spec:
10231023
dnsPolicy:
10241024
description: dnsPolicy defines how a pod's DNS will be configured
10251025
type: string
1026+
env:
1027+
description: Env defines custom env, e.g. JAVA_OPT_EXT
1028+
items:
1029+
description: EnvVar represents an environment variable present in
1030+
a Container.
1031+
properties:
1032+
name:
1033+
description: Name of the environment variable. Must be a C_IDENTIFIER.
1034+
type: string
1035+
value:
1036+
description: 'Variable references $(VAR_NAME) are expanded using
1037+
the previously defined environment variables in the container
1038+
and any service environment variables. If a variable cannot
1039+
be resolved, the reference in the input string will be unchanged.
1040+
Double $$ are reduced to a single $, which allows for escaping
1041+
the $(VAR_NAME) syntax: i.e. "$$(VAR_NAME)" will produce the
1042+
string literal "$(VAR_NAME)". Escaped references will never
1043+
be expanded, regardless of whether the variable exists or
1044+
not. Defaults to "".'
1045+
type: string
1046+
valueFrom:
1047+
description: Source for the environment variable's value. Cannot
1048+
be used if value is not empty.
1049+
properties:
1050+
configMapKeyRef:
1051+
description: Selects a key of a ConfigMap.
1052+
properties:
1053+
key:
1054+
description: The key to select.
1055+
type: string
1056+
name:
1057+
description: 'Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names
1058+
TODO: Add other useful fields. apiVersion, kind, uid?'
1059+
type: string
1060+
optional:
1061+
description: Specify whether the ConfigMap or its key
1062+
must be defined
1063+
type: boolean
1064+
required:
1065+
- key
1066+
type: object
1067+
fieldRef:
1068+
description: 'Selects a field of the pod: supports metadata.name,
1069+
metadata.namespace, `metadata.labels[''<KEY>'']`, `metadata.annotations[''<KEY>'']`,
1070+
spec.nodeName, spec.serviceAccountName, status.hostIP,
1071+
status.podIP, status.podIPs.'
1072+
properties:
1073+
apiVersion:
1074+
description: Version of the schema the FieldPath is
1075+
written in terms of, defaults to "v1".
1076+
type: string
1077+
fieldPath:
1078+
description: Path of the field to select in the specified
1079+
API version.
1080+
type: string
1081+
required:
1082+
- fieldPath
1083+
type: object
1084+
resourceFieldRef:
1085+
description: 'Selects a resource of the container: only
1086+
resources limits and requests (limits.cpu, limits.memory,
1087+
limits.ephemeral-storage, requests.cpu, requests.memory
1088+
and requests.ephemeral-storage) are currently supported.'
1089+
properties:
1090+
containerName:
1091+
description: 'Container name: required for volumes,
1092+
optional for env vars'
1093+
type: string
1094+
divisor:
1095+
anyOf:
1096+
- type: integer
1097+
- type: string
1098+
description: Specifies the output format of the exposed
1099+
resources, defaults to "1"
1100+
pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$
1101+
x-kubernetes-int-or-string: true
1102+
resource:
1103+
description: 'Required: resource to select'
1104+
type: string
1105+
required:
1106+
- resource
1107+
type: object
1108+
secretKeyRef:
1109+
description: Selects a key of a secret in the pod's namespace
1110+
properties:
1111+
key:
1112+
description: The key of the secret to select from. Must
1113+
be a valid secret key.
1114+
type: string
1115+
name:
1116+
description: 'Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names
1117+
TODO: Add other useful fields. apiVersion, kind, uid?'
1118+
type: string
1119+
optional:
1120+
description: Specify whether the Secret or its key must
1121+
be defined
1122+
type: boolean
1123+
required:
1124+
- key
1125+
type: object
1126+
type: object
1127+
required:
1128+
- name
1129+
type: object
1130+
type: array
10261131
hostNetwork:
10271132
description: HostNetwork can be true or false
10281133
type: boolean

deploy/crds/rocketmq.apache.org_nameservices.yaml

Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1023,6 +1023,111 @@ spec:
10231023
dnsPolicy:
10241024
description: dnsPolicy defines how a pod's DNS will be configured
10251025
type: string
1026+
env:
1027+
description: Env defines custom env, e.g. JAVA_OPT_EXT
1028+
items:
1029+
description: EnvVar represents an environment variable present in
1030+
a Container.
1031+
properties:
1032+
name:
1033+
description: Name of the environment variable. Must be a C_IDENTIFIER.
1034+
type: string
1035+
value:
1036+
description: 'Variable references $(VAR_NAME) are expanded using
1037+
the previously defined environment variables in the container
1038+
and any service environment variables. If a variable cannot
1039+
be resolved, the reference in the input string will be unchanged.
1040+
Double $$ are reduced to a single $, which allows for escaping
1041+
the $(VAR_NAME) syntax: i.e. "$$(VAR_NAME)" will produce the
1042+
string literal "$(VAR_NAME)". Escaped references will never
1043+
be expanded, regardless of whether the variable exists or
1044+
not. Defaults to "".'
1045+
type: string
1046+
valueFrom:
1047+
description: Source for the environment variable's value. Cannot
1048+
be used if value is not empty.
1049+
properties:
1050+
configMapKeyRef:
1051+
description: Selects a key of a ConfigMap.
1052+
properties:
1053+
key:
1054+
description: The key to select.
1055+
type: string
1056+
name:
1057+
description: 'Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names
1058+
TODO: Add other useful fields. apiVersion, kind, uid?'
1059+
type: string
1060+
optional:
1061+
description: Specify whether the ConfigMap or its key
1062+
must be defined
1063+
type: boolean
1064+
required:
1065+
- key
1066+
type: object
1067+
fieldRef:
1068+
description: 'Selects a field of the pod: supports metadata.name,
1069+
metadata.namespace, `metadata.labels[''<KEY>'']`, `metadata.annotations[''<KEY>'']`,
1070+
spec.nodeName, spec.serviceAccountName, status.hostIP,
1071+
status.podIP, status.podIPs.'
1072+
properties:
1073+
apiVersion:
1074+
description: Version of the schema the FieldPath is
1075+
written in terms of, defaults to "v1".
1076+
type: string
1077+
fieldPath:
1078+
description: Path of the field to select in the specified
1079+
API version.
1080+
type: string
1081+
required:
1082+
- fieldPath
1083+
type: object
1084+
resourceFieldRef:
1085+
description: 'Selects a resource of the container: only
1086+
resources limits and requests (limits.cpu, limits.memory,
1087+
limits.ephemeral-storage, requests.cpu, requests.memory
1088+
and requests.ephemeral-storage) are currently supported.'
1089+
properties:
1090+
containerName:
1091+
description: 'Container name: required for volumes,
1092+
optional for env vars'
1093+
type: string
1094+
divisor:
1095+
anyOf:
1096+
- type: integer
1097+
- type: string
1098+
description: Specifies the output format of the exposed
1099+
resources, defaults to "1"
1100+
pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$
1101+
x-kubernetes-int-or-string: true
1102+
resource:
1103+
description: 'Required: resource to select'
1104+
type: string
1105+
required:
1106+
- resource
1107+
type: object
1108+
secretKeyRef:
1109+
description: Selects a key of a secret in the pod's namespace
1110+
properties:
1111+
key:
1112+
description: The key of the secret to select from. Must
1113+
be a valid secret key.
1114+
type: string
1115+
name:
1116+
description: 'Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names
1117+
TODO: Add other useful fields. apiVersion, kind, uid?'
1118+
type: string
1119+
optional:
1120+
description: Specify whether the Secret or its key must
1121+
be defined
1122+
type: boolean
1123+
required:
1124+
- key
1125+
type: object
1126+
type: object
1127+
required:
1128+
- name
1129+
type: object
1130+
type: array
10261131
hostNetwork:
10271132
description: HostNetwork can be true or false
10281133
type: boolean

pkg/apis/rocketmq/v1alpha1/nameservice_types.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,8 @@ type NameServiceSpec struct {
4747
StorageMode string `json:"storageMode"`
4848
// HostPath is the local path to store data
4949
HostPath string `json:"hostPath"`
50+
// Env defines custom env, e.g. JAVA_OPT_EXT
51+
Env []corev1.EnvVar `json:"env,omitempty"`
5052
// VolumeClaimTemplates defines the StorageClass
5153
VolumeClaimTemplates []corev1.PersistentVolumeClaim `json:"volumeClaimTemplates"`
5254
// Pod Security Context

pkg/controller/nameservice/nameservice_controller.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -374,6 +374,7 @@ func (r *ReconcileNameService) statefulSetForNameService(nameService *rocketmqv1
374374
// Name must be lower case !
375375
Name: "name-service",
376376
ImagePullPolicy: nameService.Spec.ImagePullPolicy,
377+
Env: nameService.Spec.Env,
377378
Ports: []corev1.ContainerPort{{
378379
ContainerPort: cons.NameServiceMainContainerPort,
379380
Name: cons.NameServiceMainContainerPortName,

0 commit comments

Comments
 (0)