Home > Net >  What are the differences of defining configMap in volumes?
What are the differences of defining configMap in volumes?

Time:01-10

I'm just curious about what are the differences between these 2 ways of defining ConfigMap in volumes section?

p.s. test-config is including config.json file.

newpod.yaml:

apiVersion: v1
kind: Pod
metadata:
  name: configmappod
spec:
  containers:
  - name: configmapcontainer
    image: blue
    volumeMounts:
      - name: config-vol
        mountPath: "/config/newConfig.json"
        subPath: "config.json"
        readOnly: true
  volumes:
    - name: config-vol
      projected:
        sources:
        - configMap:
            name: test-config
            items:
              - key: config.json
                path: config.json

newpod2.yaml

apiVersion: v1
kind: Pod
metadata:
  name: configmappod
spec:
  containers:
  - name: configmapcontainer
    image: blue
    volumeMounts:
      - name: config-vol
        mountPath: "/config/newConfig.json"
        subPath: "config.json"
        readOnly: true
  volumes:
    - name: config-vol
      configMap:
        name: test-config

CodePudding user response:

No different, they yield the same result. By the way, the readOnly attribute is redundant, it does not have any effect in both cases.

  •  Tags:  
  • Related