|
1 | | -## kubectl-ip-check |
| 1 | +# kubectl ip-check |
2 | 2 |
|
3 | | -A kubectl plugin to check ip address resources across the cluster nodes. Provides overall allocated, used and free IPs in cluster. |
| 3 | +A kubectl plugin to improve visibility on IP address utilization in EKS clusters with VPC CNI. |
4 | 4 |
|
5 | | -Example: |
| 5 | + |
| 6 | + |
| 7 | +## Overview |
| 8 | + |
| 9 | +`ip-check` plugin is designed to check the status of IP addresses in your Kubernetes cluster. It provides visibility into total allocated IPs, used IPs, and free IPs throughout the cluster by fetching details from EC2 instances and analyzing pod IPs on each node. |
| 10 | + |
| 11 | +For each node, the plugin: |
| 12 | +- Retrieves total IP addresses from network interfaces attached to EC2 instances |
| 13 | +- Counts used IPs from pods that are not using host networking |
| 14 | +- Calculates free/unused IP addresses allocated to nodes |
| 15 | + |
| 16 | +**Currently supports:** AWS EKS clusters with VPC CNI |
| 17 | + |
| 18 | +## Installation |
| 19 | + |
| 20 | +### Via Krew (plugin manager) |
| 21 | + |
| 22 | +```bash |
| 23 | +# TODO: Will be available via krew once published |
| 24 | +kubectl krew install ip-check |
6 | 25 | ``` |
7 | | -~ $ ./kubectl-ip-check-linux |
8 | | -Allocated IPs: 682 | Used IPs: 170 | Free IPs: 512 |
9 | | -
|
10 | | -NAME INSTANCE-ID INSTANCE-TYPE AVAILABILITY-ZONE INTERNAL-IP TOTAL-IPS USED-IPS FREE-IPS |
11 | | -ip-192-168-10-106.ec2.internal i-064adaf03c2efb4f2 t3.small us-east-1a 192.168.10.106 8 3 5 |
12 | | -ip-192-168-101-147.ec2.internal i-04f5d79942c711aa6 m5.2xlarge us-east-1d 192.168.101.147 15 1 14 |
13 | | -ip-192-168-103-152.ec2.internal i-01ef79740a15eea5d m5.2xlarge us-east-1d 192.168.103.152 30 5 25 |
14 | | -ip-192-168-11-45.ec2.internal i-018fe96ee7b764915 t3.small us-east-1a 192.168.11.45 8 3 5 |
15 | | -ip-192-168-11-69.ec2.internal i-00aef0ee2330568cb t3.small us-east-1a 192.168.11.69 8 3 5 |
16 | | -ip-192-168-11-73.ec2.internal i-06bdaf3673c7159b9 t3.small us-east-1a 192.168.11.73 8 3 5 |
17 | | -ip-192-168-111-254.ec2.internal i-02781e32ca8d3539a m5.2xlarge us-east-1d 192.168.111.254 30 5 25 |
18 | | -ip-192-168-116-45.ec2.internal i-03fd3290d4503e43e m5.2xlarge us-east-1d 192.168.116.45 30 5 25 |
| 26 | + |
| 27 | +### Manual Installation |
| 28 | + |
| 29 | +1. Download the latest tar zip from the [releases page](https://github.com/4rivappa/kubectl-ip-check/releases) |
| 30 | +2. Extract executable and place it in your PATH: |
| 31 | + |
| 32 | +```bash |
| 33 | +# Extract executable and move it to your PATH |
| 34 | +sudo mv kubectl-ip_check /usr/local/bin/kubectl-ip_check |
19 | 35 | ``` |
| 36 | + |
| 37 | +## Motivation |
| 38 | + |
| 39 | +With smaller CIDR ranges in VPC subnets, using default configurations of VPC CNI can quickly exhaust available IP addresses in the network. As shown in the example above, nearly 75-80% of IPs are unused but allocated to nodes in the cluster due to default configuration settings (`WARM_ENI_TARGET`, `WARM_IP_TARGET`). |
| 40 | + |
| 41 | +This plugin helps users: |
| 42 | +- **Gain visibility** into IP address usage across the cluster |
| 43 | +- **Detect overallocation** in IP allocation |
| 44 | +- **Optimize VPC CNI configuration** to mitigate IP exhaustion |
| 45 | +- **Plan capacity** for cluster scaling |
| 46 | +- **Troubleshoot** IP-related issues |
| 47 | + |
| 48 | +## How It Works |
| 49 | + |
| 50 | +The plugin operates by: |
| 51 | + |
| 52 | +1. **Discovering Nodes**: Uses the Kubernetes API to list all nodes in the cluster |
| 53 | +2. **Analyzing ENIs**: Calls AWS EC2 `DescribeNetworkInterfaces` API for each node instance to get total allocated IP addresses |
| 54 | +3. **Counting Pod IPs**: Queries Kubernetes API to count pod IPs on each node (excluding host-networked pods) |
| 55 | +4. **Calculating Usage**: Computes used vs. free IP addresses per node and aggregates cluster-wide statistics |
| 56 | + |
| 57 | +## Required Permissions |
| 58 | + |
| 59 | +The plugin requires the following permissions to function: |
| 60 | + |
| 61 | +**AWS:** |
| 62 | +- `ec2:DescribeNetworkInterfaces` permission for the instances in your cluster |
| 63 | + |
| 64 | +**Kubernetes:** |
| 65 | +- Read access to `nodes` and `pods` resources in the cluster |
| 66 | + |
| 67 | +## Configuration |
| 68 | + |
| 69 | +The plugin automatically detects your Kubernetes configuration from: |
| 70 | +1. In-cluster service account (when running inside a pod) |
| 71 | +2. `~/.kube/config` file |
| 72 | +3. `KUBECONFIG` environment variable |
| 73 | + |
| 74 | +AWS credentials are resolved using the standard AWS credential chain: |
| 75 | +1. Environment variables (`AWS_ACCESS_KEY_ID`, `AWS_SECRET_ACCESS_KEY`) |
| 76 | +2. AWS credentials file (`~/.aws/credentials`) |
| 77 | + |
| 78 | +## License |
| 79 | + |
| 80 | +This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details. |
0 commit comments