Specify an `int` value in Kubernetes ConfigMap?

后端 未结 2 1345
南方客
南方客 2021-01-24 07:11

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

error: error validating \"my-deplo         


        
2条回答
  •  栀梦
    栀梦 (楼主)
    2021-01-24 07:40

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

    The options you can use it for (specified in this guide) are

    • As an environment variable
    • As a command line config flag (using environment variables)
    • Using the volume plugin.

    If you want to make the port configurable for your deployment/pod, you might consider using Helm. Helm allows you to use Go templates in your manifests/definitions, and then you can override them upon invocation.

    Take this MySQL Chart template as an example, you could set the port here as a config option like so:

    ports:
      - name: mysql
      containerPort: {{ default 3306 .Values.mysqlPort }}
    

    and then from there, set this value in your values.yaml

提交回复
热议问题