K8s ReplicaSets By Namespace Test

In Azure Kubernetes Service (AKS), a ReplicaSet is a key component of the Kubernetes environment that ensures a specified number of pod replicas are running at any given time. The Kubernetes controller maintains the desired state for the application by automatically managing the creation and deletion of pods to ensure that the desired number of replicas are available.

This test auto-discovers the ReplicaSets in each namespace, and for each ReplicaSet, reports the age, count of replicas (including ready replica and available replica) ensuring that the application is fully functional and can handle the load with the expected number of healthy pods. This test also reports on under-utilization of the allocated memory and CPU by the pods that leads to potential performance issues.

Target of the test : Azure Kubernetes Service Cluster

Agent deploying the test : A remote agent

Outputs of the test : One set of results for each ReplicaSet in every namespace configured in the Azure Kubernetes Service Cluster being monitored.

Configurable parameters for the test
Parameter Description

Test Period

How often should the test be executed.

Host

The IP address of the host for which this test is to be configured.

Port

Specify the port at which the specified Host listens. By default, this is 6443.

Load Balancer / Master Node IP

To run this test and report metrics, the eG agent needs to connect to the Kubernetes API on the master node and run API commands. To enable this connection, the eG agent has to be configured with either of the following:

  • If only a single master node exists in the cluster, then configure the eG agent with the IP address of the master node.
  • If the target cluster consists of more than one master node, then you need to configure the eG agent with the IP address of the load balancer that is managing the cluster. In this case, the load balancer will route the eG agent's connection request to any available master node in the cluster, thus enabling the agent to connect with the API server on that node, run API commands on it, and pull metrics.

By default, this parameter will display the Load Balancer / Master Node IP that you configured when manually adding the Kubernetes/OpenShift cluster for monitoring, using the Kubernetes Cluster Preferences page in the eG admin interface (see Figure 3). The steps for managing the cluster using the eG admin interface are discussed elaborately in How to Monitor the Kubernetes/OpenShift Cluster Using eG Enterprise?

Whenever the eG agent runs this test, it uses the IP address that is displayed (by default) against this parameter to connect to the Kubernetes API. If there is any change in this IP address at a later point in time, then make sure that you update this parameter with it, by overriding its default setting.

SSL

By default, the Kubernetes/OpenShift cluster is SSL-enabled. This is why, the eG agent, by default, connects to the Kubernetes API via an HTTPS connection. Accordingly, this flag is set to Yes by default.

If the cluster is not SSL-enabled in your environment, then set this flag to No.

K8s Cluster API Prefix

By default, this parameter is set to none. Do not disturb this setting if you are monitoring a Kubernetes/OpenShift Cluster.

To run this test and report metrics for Rancher clusters, the eG agent needs to connect to the Kubernetes API on the master node of the Rancher cluster and run API commands. The Kubernetes API of Rancher clusters is of the default format: http(s)://{IP Address of kubernetes}/{api endpoints}. The Server section of the kubeconfig.yaml file downloaded from the Rancher console helps in identifying the Kubernetes API of the cluster. For e.g., https://{IP address of Kubernetes}/k8s/clusters/c-m-bznxvg4w/ is usually the URL of the Kubernetes API of a Rancher cluster.

For the eG agent to connect to the master node of a Rancher cluster and pull out metrics, the eG agent should be made aware of the API endpoints in the Kubernetes API of the Rancher cluster. To aid this, you can specify the API endpoints available in the Kubernetes API of the Rancher cluster against this parameter. In our example, this parameter can be specified as: /k8s/clusters/c-m-bznxvg4w/.

Authentication Token

The eG agent requires an authentication bearer token to access the Kubernetes API, run API commands on the cluster, and pull metrics of interest. The steps for generating this token have been detailed in How Does eG Enterprise Monitor a Kubernetes/OpenShift Cluster?

Typically, once you generate the token, you can associate that token with the target Kubernetes/OpenShift cluster, when manually adding that cluster for monitoring using the eG admin interface. The steps for managing the cluster using the eG admin interface are discussed elaborately in How to Monitor the Kubernetes/OpenShift Cluster Using eG Enterprise?

By default, this parameter will display the Authentication Token that you provided in the Kubernetes Cluster Preferences page of the eG admin interface, when manually adding the cluster for monitoring (see Figure 3).

Whenever the eG agent runs this test, it uses the token that is displayed (by default) against this parameter for accessing the API and pulling metrics. If for any reason, you generate a new authentication token for the target cluster at a later point in time, then make sure you update this parameter with the change. For that, copy the new token and paste it against this parameter.

Namespace to Monitor

To enable the eG agent to monitor a specific Namespace on Kubernetes/OpenShift cluster, specify the name of that Namespace against this parameter. For instance, eshop. Doing so will enable the eG agent to monitor and report metrics specific to this Namespace.

Proxy Host

If the eG agent connects to the Kubernetes API on the master node via a proxy server, then provide the IP address of the proxy server here. If no proxy is used, then the default setting -none - of this parameter, need not be changed,

Proxy Port

If the eG agent connects to the Kubernetes API on the master node via a proxy server, then provide the port number at which that proxy server listens here. If no proxy is used, then the default setting -none - of this parameter, need not be changed,

Proxy Username, Proxy Password, Confirm Password

These parameters are applicable only if the eG agent uses a proxy server to connect to the Kubernetes/OpenShift cluster, and that proxy server requires authentication. In this case, provide a valid user name and password against the Proxy Username and Proxy Password parameters, respectively. Then, confirm the password by retyping it in the Confirm Password text box.

If no proxy server is used, or if the proxy server used does not require authentication, then the default setting - none - of these parameters, need not be changed.

Kubernetes version

The Version text box indicates the version of the Kubernetes/OpenShift cluster to be managed. The default value is none. If the value of this parameter is not "none", the test uses the value provided (e.g., 28.1) as the Kubernetes version.

Timeout

Specify the duration (in seconds) for which this test should wait for a response from the Kubernetes/OpenShift cluster. If there is no response from the cluster beyond the configured duration, the test will timeout. By default, this is set to 5 seconds.

Measurements made by the test

Measurement

Description

Measurement Unit

Interpretation

Replicaset age

Indicates the age of this ReplicaSet.

Minutes

When the age of a ReplicaSet in AKS increases, it typically means that the ReplicaSet has been running around for a longer period without being updated or replaced.

Replicas

Indicates the number of replicas in this ReplicaSet.

Number

A ReplicaSet (RS) ensures that a specified number of identical pods are running at all times. It automatically replaces failed pods and scales applications horizontally.

The replica count in ReplicaSet should be chosen based on application’s availability, scalability requirements, traffic volume, and available resources in AKS cluster. For most production scenarios, 3 replicas is a reasonable starting point, providing basic fault tolerance and availability.

Ready replicas

Indicates the number of ready replicas in this ReplicaSet.

Number

For most production use cases, the desirable count for ready replicas should be equal to the desired replica count set in the ReplicaSet definition. This ensures that the application is fully deployed, all pods are healthy, and the application can handle traffic as expected. For example, if the number of replicas is 3 in ReplicaSet, then desirable ready replica count should be 3.

Fully labeled replicas

Indicates the number of fully labeled replicas in this ReplicaSet.

Number

Ideally, the number of fully labeled replicas should equal the desired replica count for the ReplicaSet.

For example, if desired replica count is 3, then 3 pods should have correct labels matching the ReplicaSet's selector. This ensures that the pods in ReplicaSet are correctly labeled according to the ReplicaSet's selector to maintain consistency and ensure the desired number of replicas are managed.

Available replicas

Indicates the number of available replicas in this ReplicaSet.

Number

The desired available replica count should be equal to the desired replica count. For example, if the number of replicas is 3 in ReplicaSet, then the available replica count should ideally be 3, which means application is fully scaled and can handle traffic.

Observed generations

Indicates the number of observed generations in this ReplicaSet.

Number

Generation denotes the version of the ReplicaSet's specification, incremented when changes occur (such as updates to the pod template or scaling changes).

Observed generation denotes the version of the ReplicaSet's specification that Kubernetes has been observed and is actively managed.

The desired value for the observed generation in a ReplicaSet should always be equal to the generation of the ReplicaSet. This indicates that Kubernetes has fully reconciled the ReplicaSet with the desired state, including any updates or changes made, and that the ReplicaSet is in a stable and consistent state.

CPU usage

Indicates the amount of CPU resources used by the containers in this ReplicaSet.

Millicpu

 

CPU limits

Indicates the total amount of CPU resources that containers in this ReplicaSet are allowed to use, as per the resource quota.

Millicpu

Resource requests/limits set using the ResourceQuota object govern the aggregate resource consumption of a namespace - i.e., the total resources that can be consumed/requested across all pods/containers in a namespace.

A resource quota is violated only when the total consumption of a resource, across pods/containers in the namespace, exceeds the limits defined in the resource quota.

For instance, say that the resource quota of a namespace enforces a CPU usage limit of 2 cores and a memory usage limit of 500Gi. In this case, Kubernetes will allow you to create 2 containers with a CPU core each and 100Gi of memory each. However, if an attempt is made to create another container configured with 1 CPU core and 200Gi of memory, then such an addition operation will fail. This is because, the addition increases the total CPU usage of the namespace to 3 CPU cores, which violates the 2 core limit set by the resource quota.

CPU requests

Indicates the minimum amount of CPU resources that is guaranteed to the containers in this ReplicaSet, as per the resource quota.

Millicpu

Memory limits

Indicates the total amount of memory resources that containers in this ReplicaSet are allowed to use, as per the resource quota.

GB

Memory requests

Indicates the minimum amount of memory resources that is guaranteed to the containers in this ReplicaSet, as per the resource quota.

GB

CPU throttled as percent of Node CPU configured

Indicates the percentage of CPU throttled in this ReplicaSet when Node CPU is configured.

Percent

The ideal value for CPU throttled as a percent of node CPU configured should be as low as possible, ideally close to 0%. This indicates that the pods are able to consume the CPU resources allocated to them without being throttled.

CPU slack

Indicates the amount of CPU slack in this ReplicaSet.

Millicpu

CPU slack in ReplicaSet refers to the amount of unused CPU capacity available to a pod or container that is below its CPU limit.

A high value of this measure indicates that the pod or container is under-utilizing the allocated CPU.

Memory usage

Indicates the amount of memory resources used by the containers in this ReplicaSet.

GB

 

Memory slack

Indicates the amount of memory slack in this ReplicaSet.

GB

Memory slack in ReplicaSet refers to the amount of unused memory available to a pod or container that is below its memory limit.

A high value of this measure indicates that the pod or container is under-utilizing the allocated memory.

CPU throttled

Indicates the amount of CPU throttled in this ReplicaSet.

Millicpu

CPU throttling in a ReplicaSet occurs when a container within a pod exceeds the CPU limit that has been set for it, and Kubernetes restricts the container's access to the CPU resources.

A high value of this measure indicates that the containers or pods exceed the allocated CPU resources, leading to performance issues.