question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Kubernetes deployment: Pods from a service are being scheduled on the same node

See original GitHub issue

I was trying to deploy pulsar using GKE. While I was deploying the ZooKeeper service I noticed that its pods were being scheduled on the same node. I am really new to Kubernetes but this looks a little odd to me:

deployment/kubernetes/google-kubernetes-engine/zookeeper.yaml

spec:
    serviceName: zookeeper
    replicas: 3
    template:
        metadata:
            labels:
                app: pulsar
                component: zookeeper
                cluster: pulsar-gke
            annotations:
                pod.alpha.kubernetes.io/initialized: "true"
                prometheus.io/scrape: "true"
                prometheus.io/port: "8080"

        spec:
            # Make sure multiple pods of ZK don't get scheduled on the
            # same node, unless there are no other available nodes
            affinity:
                podAntiAffinity:
                    preferredDuringSchedulingIgnoredDuringExecution:
                      - weight: 1
                        podAffinityTerm:
                            labelSelector:
                                matchExpressions:
                                  - key: "app"
                                    operator: In
                                    values:
                                      - zookeeper
                            topologyKey: "kubernetes.io/hostname"

I read this Kubernetes affinity example and I think that the key used in matchExpressions should be component, not app. When I use component as the key, all the ZooKeeper pods are scheduled on different nodes.

If I am correct, this error is present in all the Kubernetes deployment files.

Is there any Kubernetes expert willing to take a look at this?

Thank you!

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
stupidusernamecommented, Oct 13, 2019

@cdbartholomew Thanks for submitting the PR!

1reaction
ghostcommented, Oct 13, 2019

they put component in this one here

Read more comments on GitHub >

github_iconTop Results From Across the Web

Assigning Pods to Nodes - Kubernetes
Node affinity is conceptually similar to nodeSelector , allowing you to constrain which nodes your Pod can be scheduled on based on node ......
Read more >
Advanced Kubernetes pod to node scheduling
In Kubernetes, the task of scheduling pods to specific nodes in the cluster is handled by the kube-scheduler. The default behavior of this ......
Read more >
Kubernetes: How to deploy different pods close to each other ...
You need to make sure that no more than one pod is scheduled on a node to make sure your pods are as...
Read more >
Avoiding kubernetes scheduler to run all pods in single node ...
The podAntiAfinity with requiredDuringSchedulingIgnoredDuringExecution can be used to prevent the same pod from being scheduled to the same ...
Read more >
How To Avoid Placement of More Than One Pod Replicas on ...
How to configure deployment to avoid co-location of replicas on a single node? Environment. Platform9 Managed Kubernetes - All Versions; Kube-Scheduler ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found