Divide and assign a variable on the K8S pod level

6/24/2021

I have a K8S cluster; In one deployment inside this cluster has a variable in the ConfigMap. This variable contains a list of objects. I want to divide the list of objects and assign the subset to the number of pods in the deployment. The goal is to make it dynamic.

Example

I will give an example to make clear. Let's assume the variable as 9 objects and the deployment has 3 pods. I want to divide the list (9 objects/ 3 pods = 3 objects/pod). So Pod1 has objects 1,2,3; Pod2 has objects 4,5,6; Pod3 has objects 7,8,9.

enter image description here

Note: I'm using Terraform to manage the resources and manage the variables.

-- Emad Mokhtar
kubernetes
kubernetes-helm
terraform

0 Answers