Weeks 1 - 6 Flashcards
What is Docker? What are the motivations of using Docker technology?
Docker is a set of platform as a service (PaaS) products that use OS-level virtualisation to deliver software in packages called containers.
Motivations:
- portability and speed: enables you to separate applications from infrastructure so you can deliver software quickly. Reduces time spent on back-end development.
- light-weight: as it virtualises the application instead of the OS kernel AND application layers, which VMs do and are much slower as a result.
What is a Docker Image?
Lightweight, standalone, executable package of software that had everything you need to run an application.
What is a Docker Registry?
A stateless, highly scalable server-side application that stores and lets you distribute Docker images.
What is a Docker container?
A runnable instance of an image. You can modify images in a container environment, which is a sandbox environment.
What is Dockerfile?
A text file that contains a collection of instructions and commands for building a docker image and running as a container.
RUN vs CMD?
RUN and CMD are both Dockerfile instructions. RUN lets you execute commands inside of your Docker image. CMD lets you define a default command to run when your container starts.
How to reduce Image Size?
- smaller image base
- only add necessary dependencies
- cleanup commands to remove no longer needed libraries and downloads
Describe Docker’s layer-wise architecture design?
- refers to Docker images
- Each layer is a filesystem and based on the previous image
- each layer cannot be changed (read-only) after it has been constructed
- layer-wise architecture makes reuse and customisation of images much easier (an add layers to existing images)
What are microservices?
An architectural and organisational approach to software development
where software is comprised of small independent services that communicate over well-defines APIs.
(Like splitting up a big program into specific services and functions, basic units of the service that cannot be further divided).
(extra) As opposed to monolithic architecture, microservices make up the business logic and data access layers.
Pros and cons to microservices?
Pros:
- technological freedom, language independent
- easy deployment - usable code
- agility - small teams can work on each microservice –> which can be a problem in monolithic architecture for teams
- resilience
- scalable
Cons:
- infrastructure overhead - servers and database usage
- complicated networking
What is Docker Compose?
A tool for defining and running multi-container Docker applications and running them as a single service. Used to configure applciation’s services. Single command to create a start all services (running containers) from configuration. Each container runs in isolation but can interact with each other when required.
Benefits of Docker Compose?
- single host deployment - ie. you can run everything on a single piece of hardware
- quick and easy configuration
- high productivity - reduces time it takes to perform tasks
- security - containers are isolated from each other, reducing the threat landscape
Key features of Docker Swarm
- creates multiple containers on multiple hosts (unlike M:1 for compose)
- decentralised design - easy for teams to manage and access the environment
- scalable - can scale up or down as you wish, can decide on number of tasks you want the swarm to complete, swarm master will automatically adjust
- load balancing- specification of how to distribute service containers between nodes
- highly secure - each node enforces transport layer security (TLS) mutual authentication and encryption to secure communications between itself an other nodes
- rolling updates - swarm manager lets you control delay between service deployment to different sets of nodes. Any failures occur, you can roll bac to a previous version of the service.
What is an orchestrator? Give two examples
Automated configuration, management, and coordination of computer systems, applications, and services.
Examples: Docker Swarm and Kubernetes
What is Docker Machine?
ALlows you to provision Docker machines in a variety of environments - VMs either on local systems or on cloud provider systems, and physical computers.
Used to set up as many hosts as desired, local and remote hosts.
What is Kubernetes?
Provides automatic deployment, scaling and mangement of containerised applications across multiple hosts (a cluster). It is a container orchestration system.
Follows the replica architecture.
Benefits of Kubernetes?
- Automated rollouts and rollbacks (resilience)
- Storage orchestration
- Self-healing
- Load balancing
- Horizontal scaling –> automated to create new containers, remove containers, reallocation of resources, etc.
note: The automatic creation and deletion of containers achcives rollbacks/rollouts, self-healing and, scaling operations.
Describe the Kubernetes Master Node?
Master node (control panel/plane), should have multiple masters. Contorls everything. Scheduler watches for unassigned tasks, and assigns them to available resources matching specific requirements.
Detects, and responds to cluster events.
Controller manager controls the nodes (replicaSet controller, endpoint controller, namespace controller).
All connected through an API server.
Kubernetes architecture?
- Multiple master nodes ideally
- Worker nodes controlled by master
Master node contains: - kube-scheduler, monitors new Pods with no assigned node, and selects a node for them to run on.
- kube-controller-manager, runs controller processes which are separately running for different purposes (node control, job control, enpoints control, token and service account control)
- kube-API server
- etcd - consistent and highly-available key value store used as K8s’ store for cluster data
- cloud-controller-manager, integrates cloud-specific control and config to link the cluster into cloud provider’s API. Not needed for on-premises clusters.
Each worker node contains:
- Kubelet (the brain of each worker node), which registers the node with the cluster, watches the API server (to execute task and maintain reporting channel), and reports task failure.
- Kube-proxy (network proxy maintinas network rules and communication between nodes)
- Container runtime (performs container-related tasks)
Kube-proxy?
Kube-proxy is responsible for local cluster networking, makes sure each worker node gets it own IP address, handles routing and load-balancing.
Is a part of the Kubernetes architecture.
What is a Kubernetes Pod?
- Container (Docker) = Pod (Kubernetes)
- Sandbox enviornment for hosting containers.
- Containers must always run inside of Pods.
- Mutiple containers in a Pod share the same Pod environment (networking, unique cluster IP address, storage (called ‘volumes’), container information).
- pod must be ran on a node, which the kube-Scheduler decides on
- Generally, one container per pod to keep things clean and easy.
What is the Declerative model for K8?
It is like the wishlist, or desired state, for an image to be (like a docker-compose file). It works by declaring the desired state of a microservice in a manifest file (remember MF), which is posted to the API server. This is stored in the ETCD and Kubernetes will implement the desired state to the cluster.