sharman
sharman

Reputation: 535

AWS and kubernetes volumes - how to share configuration across multiple Pods?

Fairly new to K8s and I am trying to find a way by which I can share a configuration file across pods. Using hostPath mean I have to

  1. Mount an NFS drive
  2. Add the configuration file to all of the nodes

If I provision multiple nodes then I have to mount the drive on all nodes.

Is there a way (S3) by which I can share the configuration? Or if NFS is the best way to tackle it.

Upvotes: 1

Views: 793

Answers (2)

Rico
Rico

Reputation: 61551

The standard way to share configuration files is using a ConfigMap. Essentially once you create one and assign it to a pod spec as a volume it will get injected in all the pods in all the nodes where your pod is running.

There are multiple ways of using ConfigMaps described here.

Note, that there's a 1mb limit on a ConfigMap size. This is an etcd limitation.

If you are looking at storing larger files an NFS Volume would be an option.

IMO, S3 (or any public cloud object storage) doesn't make sense to store configs, since it doesn't have the best performance, meaning you have to go outside your cluster to fetch a file. Also, there's no direct support in Kubernetes for object storage configs.

Upvotes: 2

Lev Kuznetsov
Lev Kuznetsov

Reputation: 3728

If this is a relatively small file you can mount a ConfigMap value, see here:

https://kubernetes.io/docs/tasks/configure-pod-container/configure-pod-configmap/#add-configmap-data-to-a-volume

Upvotes: 0

Related Questions