我正在为 Cube.js Cube Store 工作者在 Kubernetes 中部署 StatefulSet。
我需要根据 pod 名称和特定端口号动态设置 CUBESTORE_SERVER_NAME 环境变量。
以下是我当前的 StatefulSet 配置:
apiVersion: apps/v1
kind: StatefulSet
metadata:
name: cubestore-worker
spec:
serviceName: cubestore-worker
replicas: 3
selector:
matchLabels:
app: cubestore-worker
template:
metadata:
labels:
app: cubestore-worker
spec:
dnsPolicy: ClusterFirst
containers:
- name: cubestore
image: cubejs/cubestore:latest
ports:
- containerPort: 9001
env:
- name: POD_NAME
valueFrom:
fieldRef:
fieldPath: metadata.name
- name: CUBESTORE_SERVER_NAME
value: ${POD_NAME}:9001
envFrom:
- configMapRef:
name: cubestore-worker-configmap
volumeMounts:
- name: cubestore-storage
mountPath: /cube/data
volumes:
- name: cubestore-storage
persistentVolumeClaim:
claimName: cubestore-pvc-shared
我正在尝试将 CUBESTORE_SERVER_NAME 设置为 pod 名称和端口的组合,例如cubestore-worker-0:9001
。但是,我当前的方法似乎不起作用,并且变量设置不正确。
如何正确设置 CUBESTORE_SERVER_NAME 环境变量以在 StatefulSet 中动态包含 pod 名称和端口?