Skip to main content

Kubernetes Core Concepts Guide 🚀

ETCD 📚

ETCDCTL Command Interaction

ETCDCTL can interact with the ETCD Server using two API versions: Version 2 and Version 3. By default, it is set to use Version 2. Each version has different sets of commands.

ETCDCTL Version 2 Commands:

  • etcdctl backup
  • etcdctl cluster-health
  • etcdctl mk
  • etcdctl mkdir
  • etcdctl set

ETCDCTL Version 3 Commands:

  • etcdctl snapshot save
  • etcdctl endpoint health
  • etcdctl get
  • etcdctl put
To set the right version of the API, set the environment variable ETCDCTL_API:

Replication Controller (RC) 💾

Replica Set 📊

Deployments.yml 📄


Imperative CLI Commands 🛠️

Create an NGINX Pod

Generate POD Manifest YAML file (-o yaml). Don’t create it (—dry-run)

Create a Deployment

Generate Deployment YAML file (-o yaml). Don’t create it (—dry-run)

Generate Deployment YAML file (-o yaml). Don’t create it (—dry-run) and save it to a file

Make necessary changes to the file (e.g., adding more replicas) and then create the deployment:
In Kubernetes version 1.19+, we can specify the --replicas option to create a deployment with 4 replicas:

Services 🛠️

Service Types

Cluster IP

Load Balancer


Namespaces 🏷️

Create a Namespace

A namespace is a logical grouping of resources.

Connecting to Servers in Different Nodes & Namespaces

To connect to the same namespace, we can use a service name of that resource to connect (e.g., mysql.connect("db-service")).

Pod Definition File

A pod definition file that will auto-create a pod in a specific namespace defined in the YAML label section (e.g., namespace: dev).

Switch to Another Namespace Permanently (from Default)

Resource Quota for Namespace

Limit the usage of resources in a specific namespace.

Imperative Commands for Services 🛠️

Create a Service Named redis-service of Type ClusterIP to Expose Pod redis on Port 6379

(This will automatically use the pod’s labels as selectors.) Or
(This will not use the pod’s labels as selectors, instead it will assume selectors as app=redis. You cannot pass in selectors as an option. Generate the file and modify the selectors before creating the service.)

Create a Service Named nginx of Type NodePort to Expose Pod nginx’s Port 80 on Port 30080 on the Nodes

(This will automatically use the pod’s labels as selectors, but you cannot specify the node port. Generate a definition file and then add the node port manually before creating the service with the pod.) Or
(This will not use the pod’s labels as selectors.) Both the above commands have their own challenges. While one cannot accept a selector, the other cannot accept a node port. I recommend going with the kubectl expose command. If you need to specify a node port, generate a definition file using the same command and manually input the node port before creating the service.