GoConqr has a new look! Let us know what you think.

Flashcards

Aron Midgård - Architecture

Assar Pettersson English 18 cards

Cards in this deck (18)

  1. 1Main components of KubernetesMaster and worker nodes
    Controllers
    Services
    Pods of containers
    Namespaces and quotas
    Network and policies
    Storage
  2. 2Components of the master nodekube-apiserver
    kube-scheduler
    etcd database
    other agents
  3. 3kube-apiserverThe kube-apiserver is central to the operation of the Kubernetes cluster. All calls, both internal and external traffic, are handled via this agent. All actions are accepted and validated by this agent, and it is the only connection to the etcd database. It validates and configures data for API objects, and services REST operations. As a result, it acts as a master process for the entire cluster, and acts as a frontend of the cluster's shared state.
    Starting as an alpha feature in v1.16 is the ability to separate user-initiated traffic from server-initiated traffic. Until these features are developed, most network plugins commingle the traffic, which has performance, capacity, and security ramifications.
  4. 4kube-schedulerThe kube-scheduler uses an algorithm to determine which node will host a Pod of containers. The scheduler will try to view available resources (such as volumes) to bind, and then try and retry to deploy the Pod based on availability and success. There are several ways you can affect the algorithm, or a custom scheduler could be used instead. You can also bind a Pod to a particular node, though the Pod may remain in a pending state due to other settings. One of the first settings referenced is if the Pod can be deployed within the current quota restrictions. If so, then the taints and tolerations, and labels of the Pods are used along with those of the nodes to determine the proper placement.
  5. 5etcd databaseThe state of the cluster, networking, and other persistent information is kept in an etcd database, or, more accurately, a b+tree key-value store. Rather than finding and changing an entry, values are always appended to the end. Previous copies of the data are then marked for future removal by a compaction process. It works with curl and other HTTP libraries, and provides reliable watch queries.
    Simultaneous requests to update a value all travel via the kube-apiserver, which then passes along the request to etcd in a series. The first request would update the database. The second request would no longer have the same version number, in which case the kube-apiserver would reply with an error 409 to the requester. There is no logic past that response on the server side, meaning the client needs to expect this and act upon the denial to update.
    There is a master database along with possible followers. They communicate with each other on an ongoing basis to determine which will be master, and determine another in the event of failure. While very fast and potentially durable, there hav
  6. 6Other agentsKube-controller-manager which is a core control loop. daemon that interacts with the Kube-apiserver to determine state of cluster.
    If state does not match it will contact the necessary controller to match the desired state. Several controllers are used such as endpoints, namespaces and replication.
  7. 7Worker NodesAll worker nodes run the kubelet and kube-proxy, as well as the container engine, such as Docker or rkt. Other management daemons are deployed to watch these agents or provide services not yet included with Kubernetes.
    The kubelet interacts with the underlying Docker Engine also installed on all the nodes, and makes sure that the containers that need to run are actually running. The kube-proxy is in charge of managing the network connectivity to the containers. It does so through the use of iptables entries. It also has the userspace mode, in which it monitors Services and Endpoints using a random port to proxy traffic and an alpha feature of ipvs.
    You can also run an alternative to the Docker engine: cri-o or rkt. To learn how you can do that, you should check the documentation. In future releases, it is highly likely that Kubernetes will support additional container runtime engines.
    Supervisord is a lightweight process monitor used in traditional Linux environments to monitor and notify about other processes. In the cluster, this daemon monitors both the kubelet and docker proce
  8. 8kubeletThe kubelet agent is the heavy lifter for changes and configuration on worker nodes. It accepts the API calls for Pod specifications (a PodSpec is a JSON or YAML file that describes a pod). It will work to configure the local node until the specification has been met.
    Should a Pod require access to storage, Secrets or ConfigMaps, the kubelet will ensure access or creation. It also sends back status to the kube-apiserver for eventual persistence. ​
    Uses PodSpec
    Mounts volumes to Pod
    Downloads secrets
    Passes request to local container engine
    Reports status of Pods and node to cluster.
    Kubelet calls other components such as the Topology Manager, which uses hints from other components to configure topology-aware resource assignments such as for CPU and hardware accelerators. As an alpha feature, it is not enabled by default.
  9. 9kube-proxyThe kube-proxy is in charge of managing the network connectivity to the containers. It does so through the use of iptables entries. It also has the userspace mode, in which it monitors Services and Endpoints using a random port to proxy traffic and an alpha feature of ipvs.
  10. 10ServicesWith every object and agent decoupled we need a flexible and scalable agent which connects resources together and will reconnect, should something die and a replacement is spawned. Each Service is a microservice handling a particular bit of traffic, such as a single NodePort or a LoadBalancer to distribute inbound requests among many Pods.
    A Service also handles access policies for inbound requests, useful for resource control, as well as for security.
    Connect Pods together
    Expose Pods to Internet
    Decouple settings
    Define Pod access policy.
    We can use a service to connect one pod to another, or to outside of the cluster
  11. 11ControllersAn important concept for orchestration is the use of controllers. Various controllers ship with Kubernetes, and you can create your own, as well. A simplified view of a controller is an agent, or Informer, and a downstream store. Using a DeltaFIFO queue, the source and downstream are compared. A loop process receives an obj or object, which is an array of deltas from the FIFO queue. As long as the delta is not of the type Deleted, the logic of the controller is used to create or modify some object until it matches the specification.
    The Informer which uses the API server as a source requests the state of an object via an API call. The data is cached to minimize API server transactions. A similar agent is the SharedInformer; objects are often used by multiple other objects. It creates a shared cache of the state for multiple requests.
    A Workqueue uses a key to hand out tasks to various workers. The standard Go work queues of rate limiting, delayed, and time queue are typically used.
    The endpoints, namespace, and serviceaccounts controllers each manage the eponymous resources for
  12. 12PodsThe whole point of Kubernetes is to orchestrate the lifecycle of a container. We do not interact with particular containers. Instead, the smallest unit we can work with is a Pod. Some would say a pod of whales or peas-in-a-pod. Due to shared resources, the design of a Pod typically follows a one-process-per-container architecture.
    Containers in a Pod are started in parallel. As a result, there is no way to determine which container becomes available first inside a pod. The use of InitContainers can order startup, to some extent. To support a single process running in a container, you may need logging, a proxy, or special adapter. These tasks are often handled by other containers in the same pod.
    There is only one IP address per Pod, for almost every network plugin. If there is more than one container in a pod, they must share the IP. To communicate with each other, they can either use IPC, the loopback interface, or a shared filesystem.
    While Pods are often deployed with one application container in each, a common reason to have multiple containers in a Pod is for logging. You may
  13. 13ContainersWhile Kubernetes orchestration does not allow direct manipulation on a container level, we can manage the resources containers are allowed to consume.
    In the resources section of the PodSpec you can pass parameters which will be passed to the container runtime on the scheduled node:
    resources:
    limits:
    cpu: "1"
    memory: "4Gi"
    requests:
    cpu: "0.5"
    memory: "500Mi"
    Another way to manage resource usage of the containers is by creating a ResourceQuota object, which allows hard and soft limits to be set in a namespace. The quotas allow management of more resources than just CPU and memory and allows limiting several objects.
    A beta feature in v1.12 uses the scopeSelector field in the quota spec to run a pod at a specific priority if it has the appropriate priorityClassName in its pod spec.
  14. 14Init containerNot all containers are the same. Standard containers are sent to the container engine at the same time, and may start in any order. LivenessProbes, ReadinessProbes, and StatefulSets can be used to determine the order, but can add complexity. Another option can be an Init container, which must complete before app containers can be started. Should the init container fail, it will be restarted until completion, without the app container running.
    The init container can have a different view of the storage and security settings, which allows us to use utilities and commands that the application would not be allowed to use. Init containers can contain code or utilities that are not in an app. It also has an independent security from app containers.
    The code below will run the init container until the ls command succeeds; then the database container will start.
    spec:
    containers:
    - name: main-app
    image: databaseD
    - name: wait-fatabase
    image: busybox
    command: ['sh', '-c', 'until ls /db/dir ; do sleep 5; done; ']
  15. 15NodeA node is an API object created outside the cluster representing an instance. While a master must be Linux, worker nodes can also be Microsoft Windows Server 2019. Once the node has the necessary software installed, it is ingested into the API server.
    At the moment, you can create a master node with kubeadm init and worker nodes by passing join. In the near future, secondary master nodes and/or etcd nodes may be joined.
    If the kube-apiserver cannot communicate with the kubelet on a node for 5 minutes, the default NodeLease will schedule the node for deletion and the NodeStatus will change from ready. The pods will be evicted once a connection is re-established. They are no longer forcibly removed and rescheduled by the cluster.
    Each node object exists in the kube-node-lease namespace. To remove a node from the cluster, first use kubectl delete node to remove it from the API server. This will cause pods to be evacuated. Then, use kubeadm reset to remove cluster-specific information. You may also need to remove iptables information, depending on if you plan on re-using t
  16. 16Single IP per PodA pod represents a group of co-located containers with some associated data volumes. All containers in a pod share the same network namespace
  17. 17CNI Network Configuration FileTo provide container networking, Kubernetes is standardizing on the Container Network Interface (CNI) specification. Since v1.6.0, the goal of kubeadm (the Kubernetes cluster bootstrapping tool) has been to use CNI, but you may need to recompile to do so.
    CNI is an emerging specification with associated libraries to write plugins that configure container networking and remove allocated resources when the container is deleted. Its aim is to provide a common interface between the various networking solutions and container runtimes. As the CNI specification is language-agnostic, there are many plugins from Amazon ECS, to SR-IOV, to Cloud Foundry, and more.
    With CNI, you can write a network configuration file:
    {
    "cniVersion": "0.2.0",
    "name": "mynet",
    "type": "bridge",
    "bridge": "cni0",
    "isGateway": true,
    "ipMasq": true,
    "ipam": {
    "type": "host-local",
    "subnet": "10.22.0.0/16",
    "routes": [
    { "dst": "0.0.0.0/0" }
    ]
    }
    }
    This configuration defines a standard Linux bridge named cni0, which will give out
  18. 18Pod-to-Pod CommunicationWhile a CNI plugin can be used to configure the network of a pod and provide a single IP per pod, CNI does not help you with pod-to-pod communication across nodes.
    The requirement from Kubernetes is the following:
    All pods can communicate with each other across nodes.
    All nodes can communicate with all pods.
    No Network Address Translation (NAT).
    Basically, all IPs involved (nodes and pods) are routable without NAT. This can be achieved at the physical network infrastructure if you have access to it (e.g. GKE). Or, this can be achieved with a software defined overlay with solutions like:
    Weave
    Flannel
    Calico
    Romana

Information

Description
Flashcards on Aron Midgård - Architecture, created by Assar Pettersson on 07/05/2020.
Views
3
Rating

Feedback

What is it about?

What do you think of the new look?

How do you like it?