<p>Is there a way to specify <code>int</code> values in ConfigMap? When I try to specify a port number I get the following error.</p>

<pre><code>error: error validating "my-deployment.yml": error validating data: expected type int, for field spec.template.spec.containers[0].ports[0].containerPort, got string; if you choose to ignore these errors, turn validation off with --validate=false
</code></pre>

<p>Here is the sample config file I am using:</p>

<pre><code>apiVersion: extensions/v1beta1
kind: Deployment
metadata:
  name: my-service
spec:
  replicas: 2
  template:
    metadata:
      labels:
        app: poweramp-email-service
    spec:
      containers:
      - name: poweramp-email-service
        env:
          - name: SERVICE_PORT_NUM
            valueFrom:
              configMapKeyRef:
                name: stg-config
                key: poweramp-email-service.port
        image: nginx
        ports:
        - containerPort: my-service.port
</code></pre>

<p>And here is the simple <code>stg.properties</code> file I am using to generate the ConfigMap using the command: <code>kubectl create configmap stg-config --from-file stg.properties</code></p>

<pre><code>my-service.port=9513
</code></pre>

<p>You can't use configmap values in <code>spec.template.spec.containers[0].ports[0].containerPort</code> I'm afraid, it's for configuration values.</p>

<p>The options you can use it for (specified in <a href="https://kubernetes.io/docs/user-guide/configmap/" rel="nofollow noreferrer">this guide</a>) are</p>

<ul>
<li>As an environment variable</li>
<li>As a command line config flag (using environment variables)</li>
<li>Using the volume plugin.</li>
</ul>

<p>If you want to make the port configurable for your deployment/pod, you might consider using <a href="http://helm.sh/" rel="nofollow noreferrer">Helm</a>. Helm allows you to use Go templates in your manifests/definitions, and then you can override them upon invocation. </p>

<p>Take this <a href="https://github.com/kubernetes/charts/blob/master/stable/mysql/templates/deployment.yaml" rel="nofollow noreferrer">MySQL Chart template as an example</a>, you could set the port here as a config option like so:</p>

<pre><code>ports:
  - name: mysql
  containerPort: {{ default 3306 .Values.mysqlPort }}
</code></pre>

<p>and then from there, set this value in your <a href="https://github.com/kubernetes/charts/blob/master/stable/mysql/values.yaml" rel="nofollow noreferrer">values.yaml</a></p>
