I have following pod manifest file.in that, I have defined some environment variables.
I want to assign an environment variable value to the container port as follow.
- containerPort: $(PORT_HTTP)
but this yaml trigger error when I try to create it:
ValidationError(Pod.spec.containers[0].ports[0].containerPort): invalid type for io.k8s.api.core.v1.ContainerPort.containerPort: got "string", expected "integer"; if you choose to ignore these errors, turn validation off with --validate=false
apiVersion: v1
kind: Pod
metadata:
creationTimestamp: null
labels:
run: webapp
name: webapp
spec:
containers:
- env:
- name: PORT_HTTP
value: 8080
- name: PORT_HTTPS
value: 8443
image: nginx
name: webapp
ports:
- containerPort: $(PORT_HTTP)
resources: {}
dnsPolicy: ClusterFirst
restartPolicy: Never
status: {}
How to convert string value to integer value in yaml.