pod-ip
v0.1.8
Published
Get the IP address of a Pod in Kubernetes
Downloads
16
Readme
Overview
This package consists of a couple of utilities to get IP addresses of containers and host from inside a kubernetes pod or docker container.
Usage
- Install this package
using yarn:
yarn add pod-ip
or using npm:
npm install pod-ip
- Get IP address (ES6 module syntax)
import * as podIp from "pod-ip";
podIp.ipSync(); // ⇨ '1.1.1.1'
or using CommonJS syntax:
const podIp = require("pod-ip");
podIp.ipSync(); // ⇨ '1.1.1.1'
API Summary
| Method | |
| --- | --- |
| podIp.ip
| Get IP address asynchronously.
| podIp.ipSync
| Get IP address synchronously.
API
podIp.ip
Get IP address asynchronously
Example:
import * as podIp from "pod-ip";
podIp.ip().then(console.log); // ⇨ '1.1.1.1'
podIp.ipSync
Get IP address synchronously
Example:
import * as podIp from "pod-ip";
podIp.ipSync(); // ⇨ '1.1.1.1'
Acknowledgements
This project was inspired by docker-ip-get and internal-ip.