Kubernetes Flashcards
What is Kubernetes?
an open-source system for automating deployment, scaling, and management of containerized applications.
What is container orchestration?
Follow-up: How does Kubernetes help with container orchestration?
Container orchestration is the automation of the operational effort to run containerized workloads and services. This includes provisioning, deployment, scaling (up and down), networking, load balancing, etc.
Kubernetes provides a framework to run distributed, containerized systems easily.
What is a cluster?
A cluster is a Kubernetes deployment. Each cluster consists of a set of worker machines, called nodes, that run containerized applications. Every cluster has a control plane and at least one worker node.
What is a Pod?
Follow-up: Write an example of a pod.yml
A unit of deployment for Kubernetes. Required for running containers, and provides a shared execution environment of components the app may need to run.
Follow-up: Hello-pod example
apiVersion: v1 # if in the core group, no need to add the group name kind: Pod # kind of Kubernetes object metadata: name: hello-pod labels: app: hello-demo spec: # restartPolicy: Never containers: - name: hello image: kth844/hello-demo # resources: # limits: # memory: "128Mi" # cpu: "500m" ports: - containerPort: 8080 #has to match ports from the application
What is a Service?
Follow-up: Write an example of a service.yml
An abstract way to expose an application running on a set of Pods as a network service.
With Kubernetes, you don’t need to modify your application to use an unfamiliar service discovery mechanism.
Follow-up: hello-service example
apiVersion: v1 kind: Service metadata: name: hello-service spec: type: NodePort selector: app: hello-demo ports: - port: 80 # what service is listening on, in cluster that is tied to cluster ip, if we're using dns (access via name) targetPort: 8080 # match port for application nodePort: 31000 # port is usually (30000-32767), accessible from outside of the cluster
What is a deployment?
Follow-up: Write a deployment.yml example
A Deployment provides declarative updates for Pods and ReplicaSets.
By describing the desired state in a Deployment, the Deployment Controller changes the actual state to the desired state at a controlled rate. They also can create new ReplicaSets, or remove existing Deployments and adopt all their resources with new Deployments.
Follow-up: hello-deployment example apiVersion: apps/v1 kind: Deployment metadata: name: hello-deployment labels: app: hello # NOT RELATED TO THE PODS THEMSELVES, used for grouping and such in other tools spec: # spec for deployment object replicas: 5 selector: matchLabels: app: hello-demo # to know which pod to work on, has to match labels in the template template: # describes to the pods to be created metadata: labels: app: hello-demo spec: # spec for the pod containers: - name: hello image: kth844/hello-demo imagePullPolicy: Always ports: - containerPort: 8080 #has to match ports from the application
What is a replicaSet?
ReplicaSets maintain a stable set of replica Pods running at any given time. It is in charge of replicating pods to match the criteria defined. Fields include:
- selector(specifies how to identify pods to acquire)
- number of replicas it should be maintaining
- pod template(info on the data for new pods it creates)
What is the difference between a pod and a node
Pods are the smallest deployable units of computing that you can create and manage in Kubernetes. A pod is is a group of one or more containers, with shared storage and network resources, and a specification for how to run the containers.
Nodes are managed by the control plane and contain the services necessary to run Pods.
Nodes contain Pods.
True/False: When grouping resources, containers with different resources should be placed in the same pod?
False, containers should only be grouped together in a pod if they need to share the same resources.
What is the purpose of the Control Plane(Head Node/Master Node) in Kubernetes?
Follow-up: What about the worker nodes?
Bonus: What are the components of the Control Plane?
The Control plane is in charge of the cluster and generally has 3 nodes, up to 5.
Usually, only 1 node is actually making changes to a cluster, dubbed the “leader”.
Follow-up:
Handles work, or pods, that is coming from the scheduler.
Composed of kubelet, container runtime, and a kube-proxy.
Bonus:
Kube-API: receiving communication for the control plane, sends .yml manifests to the API server
Kube-Control Manager: Controls the controllers(node controller, deployment controller) and ensures the observed state of the cluster matches the desired one.
Kube-Scheduler: watches the apiserver for new work/applications and assigns work to cluster nodes
What is the Kubernetes API Server?
The core of Kubernetes’ control plane is the API server. The API exposes an HTTP API that lets end-users, different parts of your cluster, and external components communicate.
Kubernetes API lets you query and manipulate the state of API objects in Kubernetes (i.e. Pods, Namespaces, ConfigMaps, and Events).
What are the different components that make up a Control Plane?
Bonus: Define some of their uses/purposes
kube-apiserver: exposes the Kubernetes API. The API server is the front end of the Kubernetes control plane.
etcd: store all its data – its configuration data, its state, and its metadata.
scheduler: watches for newly created Pods with no assigned node, and selects a node for them to run on.
controller manager: runs controller processes.
cloud controller manager: cloud-specific control logic. The cloud controller manager lets you link your cluster into your cloud provider’s API.
What are the components that make up a worker node?
Bonus: define some of their uses/ purposes
Kubelet: An agent that runs on each node in the cluster. It makes sure that containers are running in a Pod.
Kube-proxy: Kube-proxy is a network proxy that runs on each node in your cluster, it maintains network rules on nodes.
container runtime: Software that is responsible for running containers.
What are the different types of services?
Bonus Points: Define what a service object is.
ClusterIp: creates stable ip address within a cluster and allows a request to reach a set of pods once inside of the cluster.
NodePort: external access via nodes.
LoadBalancer: built on top of clusterip and nodeport, seamlessly integrates with cloud providers and their load balancers.
Service object: An abstract way to expose an application running on a set of Pods as a network service.
How would you use K8 to deploy a Spring Boot Application?
https://www.section.io/engineering-education/spring-boot-kubernetes/