Home > Net >  Is it possible to use kubectl to check the containers of applications distribution in an AWS EKS clu
Is it possible to use kubectl to check the containers of applications distribution in an AWS EKS clu

Time:11-25

I want to see how the containers of an application are distributed/spread in the cluster. Which command can be used to find it out? I want to check if the containers are all running in the same AZ.

CodePudding user response:

You can install Kubectl and use it on your instance. You can read more about how to use it for EKS here.

CodePudding user response:

You can use kubectl with custom-columns to get any custom output. So it depends on which status data (if any) EKS enrich the pod with. I would recommend to check if it sets any EKS specific labels or annotations.

I can provide an example of custom-columns so you get the idea of how to use it:

kubectl get pods -A -o custom-columns='NAMESPACE:.metadata.namespace,NAME:.metadata.name,REQUESTS_CPU:.spec.containers[*].resources.requests.cpu,REQUESTS_MEMORY:.spec.containers[*].resources.requests.memory,LIMIT_CPU:.spec.containers[*].resources.limits.cpu,LiMIT_MEMORY:.spec.containers[*].resources.limits.memory'

That command will show you all pods on your cluster and how its CPU and memory requests are set:

NAMESPACE       NAME                                       REQUESTS_CPU   REQUESTS_MEMORY   LIMIT_CPU   LiMIT_MEMORY
cattle-system   rancher-7c676f75c-29jrz                    <none>         <none>            <none>      <none>
cattle-system   rancher-7c676f75c-dz4k4                    <none>         <none>            <none>      <none>
cattle-system   rancher-7c676f75c-hzs5q                    <none>         <none>            <none>      <none>
cert-manager    cert-manager-646c67487-8j4wz               <none>         <none>            <none>      <none>
cert-manager    cert-manager-cainjector-7cb8669d6b-sxklw   <none>         <none>            <none>      <none>
cert-manager    cert-manager-webhook-696c5db7ff-vzjdl      <none>         <none>            <none>      <none>
ingress-nginx   ingress-nginx-admission-create-mt4cb       <none>         <none>            <none>      <none>
ingress-nginx   ingress-nginx-admission-patch-99p6p        <none>         <none>            <none>      <none>
ingress-nginx   nginx-ingress-controller-5dpjh             <none>         <none>            <none>      <none>
kube-system     coredns-59499769fb-4m6m2                   100m           70Mi              <none>      170Mi
kube-system     coredns-autoscaler-67cbd4599c-7ld97        20m            10Mi              <none>      <none>
kube-system     kube-flannel-5fgzm                         100m           50Mi              100m        50Mi
kube-system     metrics-server-585b7cc746-bzksn            100m           200Mi             <none>      <none>
kube-system     rke-coredns-addon-deploy-job-jjj4k         <none>         <none>            <none>      <none>
kube-system     rke-ingress-controller-deploy-job-htrkn    <none>         <none>            <none>      <none>
kube-system     rke-metrics-addon-deploy-job-fqzpd         <none>         <none>            <none>      <none>
kube-system     rke-network-plugin-deploy-job-kffmk        <none>         <none>            <none>      <none>

In order to figure out which data is available that you can include in your custom columns, I would recommend to get one pod, and show it as YAML, like

kubectl get pod -n kube-system coredns-59499769fb-4m6m2 -o yaml 

When you look at that YAML, you will be able to find out how to reference your custom-column output.

CodePudding user response:

For every service kubernetes creates a corresponding endpoints resource that contains the IP addresses of the pods. You can use

kubectl describe endpoints <service-name>

To find out those IPs. Then you could look to which subnets they belong.

If you want to have your pods distributed among your AZs, have a look at pod topology spread constraints:

https://kubernetes.io/docs/concepts/scheduling-eviction/topology-spread-constraints/

  • Related