我需要通过环境变量公开我的两个命名端口。这是我的kubernetes部署yaml文件:
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
name: flink-taskmanager1255
spec:
replicas: 1
template:
metadata:
labels:
app: flink
component: taskmanager
spec:
volumes:
- name: task-pv-storage
persistentVolumeClaim:
claimName: task-pv-claim
containers:
- name: taskmanager
image: myrepo:9555/flink
args:
- taskmanager
resources:
limits:
cpu: "1"
memory: "2Gi"
requests:
cpu: "0.5"
memory: "1Gi"
ports:
- containerPort: 5021
name: data
- containerPort: 5022
name: rpc
- containerPort: 5125
name: query
livenessProbe:
tcpSocket:
port: data
initialDelaySeconds: 35
periodSeconds: 10
volumeMounts:
- mountPath: "/usr/share/flink/"
name: task-pv-storage
env:
- name: JOB_MANAGER_RPC_ADDRESS
value: flink-jobmanager
- name: FLINK_CONFIG_PATH
value: /usr/share/flink/flink-conf.yaml
- name: FLINK_LOG_DIR
value: /usr/share/flink/logs/
- name: TM_RPC_PORT
valueFrom:
resourceFieldRef:
containerName: taskmanager
fieldPath: ports.rpc
- name: TM_DATA_PORT
valueFrom:
resourceFieldRef:
containerName: taskmanager
fieldPath: ports.data
我收到此错误:
error: error converting YAML to JSON: yaml: line 51: mapping values are not allowed in this context
我相信我试图访问我的命名端口的方式是错误的,但我不知道正确的方法是什么。访问指定端口的正确方法是什么?
答案 0 :(得分:0)
对于初学者来说,尝试像这样重新排列你的yaml(减少一个缩进)
- name: TM_RPC_PORT
valueFrom:
resourceFieldRef:
containerName: taskmanager
fieldPath: ports.rpc