Extending deployments with default configuration

8/21/2019

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
kubernetes
kustomize

1 Answer

8/22/2019

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.

-- muscat
Source: StackOverflow