Logically seperate azure kubernetes deployments

4/18/2019

I have a kubernetes cluster created and deployed with app.

First if I deployed with firstapp.yaml which created a pod and a service to expose the pod externally .

If i have two nodes in the cluster and then make another deployment with secondapp.yaml .

I noticed ,that the second deployment went to different node. Although this is desired behaviour for logical seperation .

Is it something that's provided by kubernetes. How will it manage deployments made using different files? will they always go on seperate nodes (if there are nodes provisioned) ?

If not, what is the practice to be followed if i want logical seperation between two nodes which i want to behave as two environments , let's say dev and qa environment.

-- Mandar Jogalekar
azure
azure-aks
azure-kubernetes
kubernetes

2 Answers

4/19/2019

Agreed with @4c74356b41. As an addition. It does not matter where your pods are, you can have multiple replicas of your application split between say 50 nodes, they can still communicate with each other (services, service discovery, network CNI) and share resources etc.

And yes, this is a default behavior of Kubernetes, which you can influence by taints, toleration's, resources, limits Node affinity and anti-affinity (you can find a lot of information about each of those in documentation or simply googling it). Also where the Pods are scheduled is dependent on Node capacity. Your pod has been set to a particular Node because Scheduler calculated it had best score, first taking into account mentioned conditions. You can find details about the process here.

Again as @4c74356b41 mentions, if you want to split your cluster into multiple environments, lets say for different teams or as you mention for dev and qa environments you can use namespaces for that. They are basically making a smaller clusters in your cluster (note that this is more of a logical separation and not a separation from security perspective, until you add other components like for example roles) You can just add a namespace field to your deployment YAML to specify into which namespace you want to deploy your pods - still does not matter on which nodes they are. Depending on your use case.

Please note that what I wrote is oversimplified and I didn't mention many things in between, which you can easily find in most Kubernetes tutorials.

-- aurelius
Source: StackOverflow

4/18/2019

No, they will not necessary go to different nodes. Scheduler determines where to put the pod based on different criteria.

As for your last question - it makes no sense. You can use namespaces\network policies to separate environments, you shouldn't care on which node(s) your pods are. Thats the whole point of having a cluster.

You can use placement constraints to achieve what you ask for, but it makes no sense at all.

https://kubernetes.io/docs/concepts/configuration/assign-pod-node/

-- 4c74356b41
Source: StackOverflow