How to expose the scale of a deployment or statefulset to the pods in it?

user7876637

My first thought was using the downward API, but that doesn't seem to expose the scale of a deployment / statefulset. I was hoping to be able to avoid adding it in as a separate environment variable manually, or having to rely on pods all discovering each other to determine the scale if possible.

Use-case: Deploying many pods for an application that connects to an external service. Said service does some form of consistent hashing (I believe is the right term?) for sending the data to clients, so clients that connect send an id number from 0 - N-1 and a total number of clients N. In this case, the deployment/statefulset scale would be N.

coderanger

You would definitely have to use a StatefulSet for this, and I don't think you can pull it from the DownwardAPI because the replica count isn't part of the pod spec (it's part of the statefulset spec). You could get the parent object name and then set up a service account to be able to query the API to get the replica count, but that seems like more work than putting the value in a label or env var.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

How to expose a headless service for a StatefulSet externally in Kubernetes

How can I expose a Statefulset with a load balancer?

Immediately scale up Kubernetes Statefulset/Deployment to full capacity

Skipping a pod deployment in statefulset

How does multiple replicas/pods scale Kubernetes?

Ping pods of a statefulset via DNS

StatefulSet update: recreate THEN delete pods

How to do mulit pods deployment in kubernetes

Kubernetes expose multiple pods

How can I expose a StatefulSet service with ClusterIP None on Google Cloud Platform?

Running DB as Kubernetes Deployment or StatefulSet?

Configure starting index of StatefulSet's pods in Kubernetes

How Knative swiches traffic to activator when pods scale to zero

how to automatically scale down to 0 when a pods is not used for some time?

Scale down Kubernetes pods

How many pods can be configured per deployment in kubernetes?

In Kubernetes how can I have a hard minimum number of pods for Deployment?

How to overwrite file in pods container in Kubernetes deployment file?

How to Specify ServiceAccountName for Pods in GKE Deployment.YAML

How to rolling restart pods without changing deployment yaml in kubernetes?

kubernetes - How to ensure running pods are terminated before new pods are created for a deployment

How do I expose functions I add to a file that I created with cocoa pods?

SQL Server Kubernetes StatefulSet deployment not ready

What are the options to scale up/scale down a kubernetes statefulset during runtime?

Expose pods in AKS to internet with existing setup

Kubernetes scale down specific pods

Configure the starting index of pods being created by a StatefulSet in kubernetes

Pods in StatefulSet still terminating after the old liveness probe time

Stop all Pods in a StatefulSet before scaling it up or down