-
Kubernetes
-
Overview
- Platform for managing container workloads
- Groups containers into logical units for easy discovery and management
- Handles deployment, auto-scaling, updates, load balancing, auto-recovery
- Invented by Google, used internally and open sourced in 2014
-
Features
- Cloud Infrastructure provisioing
- CA and TLS certificate generation
- TLS client bootstrap and RBAC authentication
- Highly available etcd cluster
- Highly available Kubernetes Control Plane
- Cluster of Worker nodes
- Kubernetes client for remote access
- Managing the Container Network Routes
- Deploying cluster DNS Add-on
-
Master
- Runs the Kubernetes control plane processes
- API server, scheduler, and core controller resources
-
Nodes
- Worker machines that run containerized applications and other workloads
- Each node is a compute engine VM instance that GKE creates when a cluster is created
- Containers are hosted on VMs
- Multiple containers/pods on single node
-
Node pool
- Group of nodes
- Managed instance group
-
Cluster
- Foundation of GKE
- Consists of one Cluster Master and one or more worker machines called Nodes
-
Node image
- Node-level OS image
- Container Optimized OS/Ubuntu
- Different from the container image
-
Pods
- Smallest deployable unit
- Pods contain one or more containers
- One or more pods are deployed to nodes
- Stateful applications (Pods) save data to persistent disk storage
- Stateless applications (Pods) do not save state
- Updating and scaling/autoscaling statefulset pod is more deliberate
-
Container Image
- Base image used in container (not node)
- Smaller deployment and less security surface
- To avoid unnecessary reinstalls, do not copy source files before installing dependencies
- Tag different versions of container deployments with version number, not just "latest"
- Skip pulling image if it already exists vs forcing a pull regardless
- Set pull policy to "IfNotPresent" not "Always"
- Use Alphine Linux for super slim container image
-
Administration
- gcloud/kubectl command line or YAML/JSON configuration files
- gcloud command used to interact with GCP resources (GKE cluster/nodes, disks, APIs)
- kubectl used to interact with applications on nodes (Pods) - deploy, scale, update pods
-
Workload
-
Containers
- Bundles entire runtime environment in one package
- Runtime environment includes dependencies, libraries and config files
- Operating system and infrastructure concerns are abstracted away
- Containers are more lightweight and use fewer resources than an entire VM
- Portable, self-contained package that can be run virtually anywhere
-
Cloud Build
- Create Docker container image from source code
- Push created images stored in Container Registry
- Pulls code from Google Cloud Storage, Source Repositories, GitHub, BitBucket
-
Container Registry
- Private Docker repository
- Integrate with Google cloud and external container services
- Supports CI/CD model
- Can deploy to Kubernetes Engine, Compute engine or AppEngine (Flexible), Cloud Run
-
Networking
-
Label
- Arbitrary key/value pair attached to an object
-
Service
- Groups multiple related pods into a logical unit using labels
- Stable IP address, DNS entry and ports
- Provides load balancing among the set of Pods
- All the labels defined in the label selector must match pod labels
-
kube-proxy
- Component running on each node
- Manages connectivity between pods and services
- Egress based load balancer controller
- Continually maps the cluster IP to healthy pods at random
-
Namespace
- Useful for environments with multiple teams or projects
- Partitions cluster resources between multiple users
- Unique name within a cluster