Kubernetes Concepts: Difference between revisions

From NovaOrdis Knowledge Base
Jump to navigation Jump to search
No edit summary
Line 65: Line 65:


The declarative model is essential to how Kubernetes operates.
The declarative model is essential to how Kubernetes operates.
=API Resources=
The full list of API resources (primitives, API objects) available to interact with in Kubernetes is generated by:
kubectl api-resources
'''NAME'''                              SHORTNAMES  APIGROUP                      NAMESPACED  '''KIND'''
bindings                                                                      true        Binding
componentstatuses                cs                                          false        ComponentStatus
configmaps                        cm                                          true        ConfigMap
endpoints                        ep                                          true        Endpoints
events                            ev                                          true        Event
limitranges                      limits                                      true        LimitRange
namespaces                        ns                                          false        [[Kubernetes Namespace Concepts|Namespace]]
nodes                            no                                          false        Node
persistentvolumeclaims            pvc                                        true        PersistentVolumeClaim
persistentvolumes                pv                                          false        PersistentVolume
pods                              po                                          true        [[Kubernetes Pod and Container Concepts#Pod|Pod]]
podtemplates                                                                  true        PodTemplate
replicationcontrollers            rc                                          true        ReplicationController
resourcequotas                    quota                                      true        ResourceQuota
secrets                                                                      true        [[Kubernetes Cluster Configuration Concepts#Secret|Secret]]
serviceaccounts                  sa                                          true        ServiceAccount
services                          svc                                        true        Service
mutatingwebhookconfigurations                  admissionregistration.k8s.io  false        MutatingWebhookConfiguration
validatingwebhookconfigurations                admissionregistration.k8s.io  false        ValidatingWebhookConfiguration
customresourcedefinitions        crd,crds    apiextensions.k8s.io          false        CustomResourceDefinition
apiservices                                    apiregistration.k8s.io        false        APIService
controllerrevisions                            apps                          true        ControllerRevision
daemonsets                        ds          apps                          true        DaemonSet
deployments                      deploy      apps                          true        Deployment
replicasets                      rs          apps                          true        ReplicaSet
statefulsets                      sts          apps                          true        [[Kubernetes_Higher_Level_Pod_Controllers#StatefulSet|StatefulSet]]
tokenreviews                                  authentication.k8s.io          false        TokenReview
localsubjectaccessreviews                      authorization.k8s.io          true        LocalSubjectAccessReview
selfsubjectaccessreviews                      authorization.k8s.io          false        SelfSubjectAccessReview
selfsubjectrulesreviews                        authorization.k8s.io          false        SelfSubjectRulesReview
subjectaccessreviews                          authorization.k8s.io          false        SubjectAccessReview
horizontalpodautoscalers          hpa          autoscaling                    true        HorizontalPodAutoscaler
cronjobs                          cj          batch                          true        CronJob
jobs                                          batch                          true        Job
certificatesigningrequests        csr          certificates.k8s.io            false        CertificateSigningRequest
stacks                                        compose.docker.com            true        Stack
leases                                        coordination.k8s.io            true        Lease
events                            ev          events.k8s.io                  true        Event
daemonsets                        ds          extensions                    true        DaemonSet
deployments                      deploy      extensions                    true        Deployment
ingresses                        ing          extensions                    true        Ingress
networkpolicies                  netpol      extensions                    true        NetworkPolicy
podsecuritypolicies              psp          extensions                    false        PodSecurityPolicy
replicasets                      rs          extensions                    true        ReplicaSet
ingresses                        ing          networking.k8s.io              true        Ingress
networkpolicies                  netpol      networking.k8s.io              true        NetworkPolicy
runtimeclasses                                node.k8s.io                    false        RuntimeClass
poddisruptionbudgets              pdb          policy                        true        PodDisruptionBudget
podsecuritypolicies              psp          policy                        false        PodSecurityPolicy
clusterrolebindings                            rbac.authorization.k8s.io      false        ClusterRoleBinding
clusterroles                                  rbac.authorization.k8s.io      false        ClusterRole
rolebindings                                  rbac.authorization.k8s.io      true        RoleBinding
roles                                          rbac.authorization.k8s.io      true        Role
priorityclasses                  pc          scheduling.k8s.io              false        PriorityClass
csidrivers                                    storage.k8s.io                false        CSIDriver
csinodes                                      storage.k8s.io                false        CSINode
storageclasses                    sc          storage.k8s.io                false        StorageClass
volumeattachments                              storage.k8s.io                false        VolumeAttachment
=API Reference=
{{External|https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.14/}}

Revision as of 23:08, 30 August 2019

External

Internal

TODO

Deplete Kubernetes Concepts TO DEPLETE.

Overview

Kubernetes is an Apache 2.0 Open Source container orchestration platform, or a container orchestrator. To understand how Kubernetes works is to understand a set of high level concepts, briefly mentioned here. More details on individual concepts are available on their respective pages.

A high level abstraction often used for Kubernetes is "data center OS". The primary target of Kubernetes are containerized cloud-native applications, which are applications that are made from a set of small autonomous services (microservices) that communicate with each other. Kubernetes help deploying, scaling up, scaling down, performing updates and rollbacks of these services, handled as containers. In the process, it abstracts out details such as what specific compute nodes or physical storage volumes are allocated to applications.

Kubernetes instances are known as clusters. All interactions with a Kubernetes cluster are performed by sending REST requests into an API Server. The API Server is responsible with managing and exposing the state of the cluster. The state of the cluster is internally stored by a Cluster Store component, which is currently etcd. The control loops essential to the declarative model implemented by Kubernetes are driven by the controller manager. The workloads are dispatched by the scheduler. All these components (API Server, cluster store, controllers, scheduler, cloud controller manager) are collectively known as the control plane. Externally, the state can be accessed and modified most commonly via a command line client named kubectl. The cluster consists in a set of nodes. There are master nodes and worker nodes. Each node runs a container runtime, usually Docker. However, support for other container runtimes is available, via Container Runtime Interface (CRI).

Worker nodes are used to run workloads, as Pods - pods are scheduled to nodes and closely monitored. A pod is a wrapper that allows containers to run on Kubernetes and it is the atomic unit of deployment in Kubernetes. A pod may include one one or more containers. Pods come and go - if a pod dies, it is not resurrected, but another pod might be scheduled as replacement. In consequence, the IP address of an individual Pod cannot be relied on. To provide a stable access point to a set of equivalent pods - which is how applications are deployed on Kubernetes, Kubernetes uses the concept of Service, which can be thought of as stable networking for a continuously changing set of pods. A Service's IP address and port can be relied on to be stable for the life of the service. All live pods represented by a service at a moment in time are known as the service's endpoint. There are several types of services: ClusterIP, NodePort and LoadBalancer. The association between services and pods they expose is loose, established logically by the service's Selector, which is a label-based mechanism: a pod "belongs" to a service if the service's selector matches the pod's labels. A layer 5 alternative to service, named Ingress is available.

A pod by itself has no built-in resilience: if it fails for any reason, it is gone. A higher level primitive - the Deployment - is used to manage a set of pods from a high availability perspective: the Deployment insures that a specific number of equivalent pods is always running, and if one of more pods fail, the Deployment brings up replacement pods. The deployment relies on an intermediary concept - the ReplicaSet. Deployments are used to implement rolling updates and rollbacks. There are higher-level pod controllers that manage sets of pods in different ways: DaemonSets and StatefulSets. Individual pods can be managed as Jobs or CronJobs.

Networking. kube-proxy. Pod network. The DNS Service. All in Networking Concepts.

Storage. Storage Concepts

Security. Security Concepts

Cluster Configuration.

Subjects

Declarative versus Imperative Approach

The preferred style while operating Kubernetes is to use a declarative model: Kubernetes likes to manage application declaratively, where we describe how we want our application to look in a set of YAML files, named manifests, POST these files into the Kubernetes API Server and wait for the changes to be applied. The controller manager insures that the current state matches the desired state. Step-by-step, the declarative model works as follows:

  1. The desired state of the application is declared in the manifest file.
  2. The manifest file is POSTed into the API Server, usually with kubectl command.
  3. The API server authenticates and authorizes the request and then validates the manifest.
  4. The API server stores the state - as desired state - in the cluster store.
  5. The API server identifies the controller responsible with enforcing and monitoring the state.
  6. The controller in charge implements the desired state, by adjusting the current state to match it.
  7. The controller manager's control loops monitor the current state and make sure that it does not diverge from the desired state.
  8. If the current state of the cluster diverges from the desired state, the cluster control plane will perform whatever tasks are necessary to bring those states in sync.

This model is the opposite of the traditional imperative model, where a precise sequence of specific commands are issued to explicitly adjust the state. In other words, in the declarative model we tell the cluster how things should look, as opposite to telling it how to adjust the state.

The declarative model is essential to how Kubernetes operates.