了解 Kubernetes

发布于 2020-02-27 17:31:59

Purpose

With modern web services, users expect applications to be available 247, and developers expect to deploy new versions of those applications several times a day. Containerization helps package software to serve these goals, enabling applications to be released and updated in an easy and fast way without downtime. Kubernetes helps you make sure those containerized applications run where and when you want, and helps them find the resources and tools they need to work. Kubernetes is a production-ready, open source platform designed with Google’s accumulated experience in container orchestration, combined with best-of-breed ideas from the community.

Kubernetes coordinates a highly available cluster of computers that are connected to work as a single unit.

Kubernetes automates the distribution and scheduling of application containers across a cluster in a more efficient way.

Glossary

  • Kubernetes cluster
  • minikube
    • A Kubernetes cluster can be deployed on either physical or virtual machine
    • To get started with Kubernetes development, you can use Minikube
    • a lightweight Kubernetes implementation that creates a VM on your local machine and deploys a simple cluster containing only one node
  • Master
  • Node
    • a VM or a physical computer that serves as a worker machine in a Kubernetes cluster
    • A Node can have multiple pods, and the Kubernetes master automatically handles scheduling the pods across the Nodes in the cluster.
  • The nodes communicate with the master using the Kubernetes API
  • KubeDNS
  • Pod
    • to host your application instance
    • A Pod is a Kubernetes abstraction that represents a group of one or more application containers (such as Docker or rkt), and some shared resources for those containers
    • Those resources include:
    • Shared storage, as Volumes
    • Networking, as a unique cluster IP address
    • Information about how to run each container, such as the container image version or specific ports to use
    • A Pod models an application-specific “logical host” and can contain different application containers which are relatively tightly coupled.
    • Pods are the atomic unit on the Kubernetes platform.
    • A Pod always runs on a Node
  • Service
    • Although each Pod has a unique IP address, those IPs are not exposed outside the cluster without a Service. Services allow your applications to receive traffic. Services can be exposed in different ways by specifying a type in the ServiceSpec
    • ClusterIP
    • NodePort
    • LoadBalancer
      • Superset of NodePort
    • ExternalName
  • Labels
    • Services match a set of Pods using labels and selectors, a grouping primitive that allows logical operation on objects in Kubernetes. Labels are key/value pairs attached to objects and can be used in any number of ways.
    • Labels can be attached to objects at creation time or later on
    • They can be modified at any time

module_03_nodes.svg

module_04_services.svg

Setup

Minikube

minikube start

kubectl

kubectl get - list resources
kubectl describe - show detailed information about a resource
kubectl logs - print the logs from a container in a pod
kubectl exec - execute a command on a container in a pod

Scale up

module_05_scaling2.svg

  • Kubernetes also supports autoscaling of Pods, but it is outside of the scope of this tutorial.
  • Scaling to zero is also possible, and it will terminate all Pods of the specified Deployment.
  • Running multiple instances of an application will require a way to distribute the traffic to all of them. Services have an integrated load-balancer that will distribute network traffic to all Pods of an exposed Deployment.
    • Services will monitor continuously the running Pods using endpoints, to ensure the traffic is sent only to available Pods.

Rolling update

module_06_rollingupdates2.svg

Kubernetes vs Swarm

Kubernetes is an open-source system for automating deployment, scaling, and management of containerized applications.

Docker Swarm is Docker’s own container’s orchestration.

Docker Swarm is preferred in environments where simplicity and fast development is favored. Whereas Kubernetes is suitable for environments where medium to large clusters are running complex applications.

Serverless

If you are looking for a native kubernetes based FaaS, kubeless or openwhisk is recommended.

References

comments powered by Disqus