1

I have a config map that defines some variables like environment that are then passed into alot of deployment configurations like this

- name: ENV
      valueFrom:
        configMapKeyRef:
          name: my-config-map
          key: ENV

secrets and some volumes like ssl certs are common across the configs also. Is there some kubernetes type that I could create a base service deployment that extends a normal deployment? Or some other way to deal with this? Also using kustomize, there might be an option there.

shapeshifter
  • 2,967
  • 2
  • 25
  • 39
  • 2
    It is possible through PodPreset, take a look at the details from the following link https://kubernetes.io/docs/tasks/inject-data-application/podpreset/#pod-spec-with-configmap-example – Hang Du Aug 21 '19 at 11:03
  • Ah very nice! Missed that, thanks. – shapeshifter Aug 21 '19 at 11:06

1 Answers1

1

You can use a PodPreset object to inject information like secrets, volume mounts, and environment variables etc into pods at creation time.

Before starting using PodPreset you need to take few steps:

  • Firstly need to enable API type settings.k8s.io/v1alpha1/podpreset, which can be done by including settings.k8s.io/v1alpha1=true in the --runtime-config option for the API server
  • Enable the admission controller PodPreset. You can do it by including PodPreset in the --enable-admission-plugins option value specified for the API server
  • After that you need to creatie PodPreset objects in the namespace you will work in and create it by typing kubectl apply -f preset.yaml

Please refer to official documentation to see how it works.

aga
  • 3,790
  • 3
  • 11
  • 18