npm.io
0.1.8 • Published 3 years ago

pod-ip

Licence
MIT
Version
0.1.8
Deps
2
Size
17 kB
Vulns
0
Weekly
0
Stars
2

Overview

Build Status npm npm bundle size npm codecov

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

  1. Install this package

using yarn:

yarn add pod-ip

or using npm:

npm install pod-ip
  1. 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.

Keywords