/ kuberentes

HowTo use Kubernetes Control

What is Kubernetes?

Kubernetes is an open source orchestration system for Docker containers. It handles scheduling onto nodes in a compute cluster and actively manages workloads to ensure that their state matches the users' declared intentions. Using the concepts of "labels" and "pods", it groups the container which make up an application into logical units for easy management and discovery.

"Errm, come again" you say? No worries, Deis put together The Children's Illustrated Guide to Kubernetes:


What is a pod?

A pod (as in a pod of whales or pea pod) is a group of one or more containers (such as Docker containers), with shared storage/network, and a specification for how to run the containers. A pod’s contents are always co-located and co-scheduled, and run in a shared context. A pod models an application-specific “logical host” - it contains one or more application containers which are relatively tightly coupled — in a pre-container world, they would have executed on the same physical or virtual machine.

Source: https://kubernetes.io/docs/concepts/workloads/pods/pod/#what-is-a-pod

Get pods

  • kubectl get pods

Describe Deployment

  • kubectl describe deployment {POD}

Describe Ingress

  • kubectl describe ingress {POD}

Describe Service, Replicaset, etc

  • kubectl describe [rs|svc|etc] {POD}


  • kubectl logs -f {POD} --timestamps


  • kubectl -ti exec {POD} bash

What is a label?

Labels are key/value pairs that are attached to objects, such as pods. Labels are intended to be used to specify identifying attributes of objects that are meaningful and relevant to users, but do not directly imply semantics to the core system. Labels can be used to organize and to select subsets of objects. Labels can be attached to objects at creation time and subsequently added and modified at any time. Each object can have a set of key/value labels defined. Each Key must be unique for a given object.

Source: https://kubernetes.io/docs/concepts/overview/working-with-objects/labels/

Use selectors and labels

Combine with kubectl delete, decribe, get etc

Describe one app and show deployed docker images
  • kubectl describe deployment -l environment=ff-develop | grep -B5 image
Select a whole environment
  • kubectl --selectors="environment=ff-alpha"
Check for certain variables on all pods with label my-test
  • kubectl describe pods -l "environment=my-test"

Kubernetes Docs: "Working with Objects and Labels"

How to update an image in a pod?

The default pull policy is IfNotPresent which causes the Kubelet to skip pulling an image if it already exists. If you would like to always force a pull, you can do one of the following: set the imagePullPolicy of the container to Always

Source: https://kubernetes.io/docs/concepts/containers/images/

How to pull in a new docker image into a deployment?

  • kubectl delete --selectors="app=policy-api,environment=ff-develop" pod

Helm - Official Kubernetes Package Manager


Upgrade a ReplicaSet and its resources

  • helm upgrade -f ./environment/ff-develop.yaml -f ./app/product-api.yaml (kubectl get pods -l environment=ff-develop,app=product-api --no-headers | awk -F"-" '{print $5"-"$6}') . --recreate-pods

Above command also restarts the pods and pulls in a new image. Please note: If you don't have a good image tagging process in your company this can break things.

Destroy a ReplicaSet and all its resources

Danger Zone

Please note: You can be shown the door in your company for using below command without utilizing your brain up to a considerable percentage of its capacity..

  • kubectl get pods -l environment=ff-develop --no-headers | awk -F"-" '{print $5"-"$6}' | xargs helm del

Use --purge switch if you want to annihilate helm's versioning history on your cluster. Needless to say that this is not recommended.

HowTo use Kubernetes Control
Share this