Skip to main content

Pods

Pods are a core component and the heart 💖 of Kubernetes deployments

Pods are the fundamental building blocks in Kubernetes, representing a single instance of a running process in a cluster. They encapsulate one or more containers, along with shared resources such as network and storage volumes.

Pods provide a cohesive environment for running containers that need to work together and share resources. They enable the deployment of tightly coupled application components within a Kubernetes cluster. For example, a pod can consist of multiple containers that communicate with each other using local network interfaces, allowing them to collaborate seamlessly.

Kubernetes schedules and manages pods as the unit of deployment. It ensures that the desired number of pods are running and handles scaling, self-healing, and load balancing. Pods can be replicated and distributed across multiple nodes in a cluster to ensure high availability and fault tolerance.

Additionally, pods have their own IP address and can be accessed directly within the cluster, which facilitates easy communication and service discovery between different pods and services. They can also share storage volumes, allowing data to be shared and persisted across multiple containers within a pod.

Overall, pods play a crucial role in Kubernetes deployments, serving as the basic unit of deployment, scaling, and management, and enabling the efficient orchestration of containerized applications within a cluster.

namespaces

kubectl get pods --server=https://api.k1s.me/kubernetes
// index.js
const https = require('https');

const options = {
hostname: 'api.k1s.me',
port: 443,
path: '/kubernetes/api/v1/pods',
method: 'GET'
};

const req = https.request(options, res => {
console.log(`statusCode: ${res.statusCode}`);

res.on('data', d => {
process.stdout.write(d);
});
});

req.on('error', error => {
console.error(error);
});

req.end();

Execute code above assuming the file is named index.js?

  1. Install Node.js from https://nodejs.org/en/download/
  2. Open a terminal and run node index.js
  3. The output should be similar to the following: statusCode: 200

References: