Kubernetes - read arguments "args" properties from .INI file or configMap

2/7/2022

I have kubernetes file with arguments that I am propagating through the args. Everything works OK! Instead of the args can I read the configuration from some .ini or properties file or configMap ? I cannot find example for using the values from properties file or configMap instead of the args properties. Or what will be the proposed best approach how these values should be read and how I should modify my deployment YAML. Thanks!

apiVersion: apps/v1
kind: Deployment
metadata:
  name: ads
spec:
  replicas: 1
  template:
    metadata:
      name: ads
    spec:
      containers:
      - name: ads
        image: repo/ads:test1
        #args:
        args: ["-web_server", "10.1.1.1",
               "-web_name", "WEB_Test1",
               "-server_name", "ads"]
  selector:
    matchLabels:
      app: ads
-- AndreyS
kubernetes

1 Answer

2/7/2022

Sure you can, here's the official K8s example how to store properties in ConfigMap and how to access them in your container. If this document doesn't meet your requirement, do update your question with the reason and your exact expectation.

-- gohm'c
Source: StackOverflow