Coder Social home page Coder Social logo

k8s-training's Introduction

Kubernetes Basics

What is kubernetes

Kubernetes is an orchestration tool for container technologies, mainly docker.

Why is Kubernetes used

Docker allows a process to run in an isolated container, bundled with its dependencies. However with docker, these containers need to be managed individually.

Kubernetes manages these containers at scale, assigning them to groups to manage their replication and availability.

Kubernetes Components

Here's a brief oiverview of the main components that make up a Kubernetes system, we will then go into a more detailed description of each component.

Here is an overview:

overview

  • A group of containers is called a pod. We always manage the pod, never the container.

  • A a pod is created in the environment via a deployment. These are usually configured in a replica set, this determines how many copies of the pod will be deployed.

  • A deployment is created in the cluster, or in larger environments a namespace, which is a virtual cluster.

Clusters and Namespaces

A Kubernetes Cluster encompasses every component, from pods and deployments to nodes and networking. It's synonymous with your kubernetes environment.

A Namespace is a virtual cluster used for seperating different applications or application versions.

Pods

Pods are the smallest component that Kubernetes manages.

pods

These can be comprised of one or more containers, usually one.

You will usually find more containers in a pod if you have a custom logging or monitoring system.

Deployments

deployments

A deployment is how we manage groups of pods.

Pods are usually configured as a template and assigned to a Replica Set, then the replica set is deployed using a deployment.

This allows us to deploy multiple copies of a pod for high availability.

Physical overview

This is the physical heirarchy of a kubernetes cluster.

overview

Here we see how a deployment similar to the logical view fits into the physical world.

This cluster uses two nodes which aren’t shown on the logical diagram.

You can see two deployments of two pods. Kubernetes will attempt to schedule the pods in any given deployment on different nodes, this is to ensure that a failure in a node doesn’t result in a failure in the application.

Services

Services are how we assign networking to a pod.

service labels

This is done by assigning a label to the pod in the format key:value:

template:
  metadata:
    labels:
      key: value

The service then attached itself to those pods by using a selector:

spec:
  selector:
    key: value

There are several types of services that can be deployed the descriptions below are taken from the Kubernetes Documentation. The diagrams are inspired by this Medium post from Google.

ClusterIP

ClusterIP

Exposes the Service on a cluster-internal IP. Choosing this value makes the Service only reachable from within the cluster. This is the default ServiceType.

NodePort

NodePort

Exposes the Service on each Node’s IP at a static port (the NodePort). A ClusterIP Service, to which the NodePort Service routes, is automatically created. You’ll be able to contact the NodePort Service, from outside the cluster, by requesting :.

LoadBalancer

Loadbalancer

Exposes the Service externally using a cloud provider’s load balancer. NodePort and ClusterIP Services, to which the external load balancer routes, are automatically created.

Ingress

Ingress

Ingress is the network entry point to your internal cluster network.

It contains routing rules to ensure network traffic is routed to the correct locations.

Public Cloud platforms will usually have their own Ingress controller that integrate effectively with their underlying infrastructure. Most Ingress controllers run nginx.

ExternalName

Maps the Service to the contents of the externalName field (e.g. foo.bar.example.com), by returning a CNAME record with its value. No proxying of any kind is set up.

How is kubernetes used

Like most orchestration tools, a kubernetes deployment is defined in a number of manifests. These manifests describe the desired state of a kubernetes application.

These desired states are given to the control plane, which manages the cluster. The desired state of the cluster is applied with what's known as a control loop:

control loop

This takes the desired state of the cluster and observes the current state, if there is a difference, it acts to apply the changes. Once the changes are applied it restarts the loop, observing the current state comparing it against the desired state, ensuring it's constantly staying up to date and that no configuration drift has occurred.

kubectl

Command line tool for Kubernetes

This is what we will use to manage our cluster

For details or help with commands:

kubectl --help
kubectl --options

kubectl help

kubectl get

Display one or many resources

Commonly used for:

  • pod(s)
  • deployment(s)
  • svc (services)
kubectl get [resource]

kubectl get

kubectl describe

Describes the details of a resource.

This is used to get more information than is presented by the get command.

kubectl describe [resource]

kubectl describe

kubectl apply

Apply a configuration to a resource

Usually done with the -f flag to specify a manifest file

kubectl apply -f [file.yml]

kubectl apply

kubectl delete

Delete resources by:

  • file
  • name
  • selector
kubectl delete -f [file.yml]

kubectl delete

kubectl exec

Execute a command in a container

kubectl exec -it [pod] -- [command]

kubectl exec

Tasks

k8s-training's People

Contributors

mrmcshane avatar

Stargazers

 avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.