Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
SlideShare a Scribd company logo
Kubernetes from the ground up
Through the looking glass of the Kubernetes
internals
Skyworkz - https://skyworkz.nl
Sander Knape - https://sanderknape.com
Hello, I’m Sander Knape
Cloud Engineer @ Skyworkz
Quick history
Hardware → Virtualization → Containerization
Container use cases
● Run X amount of containers
○ Autoscaling
○ Distributed on different nodes / AZs / Regions
● Rolling updates
● Schedule containers (cron)
● ...
Kubernetes from the ground up
Kubernetes is big
● Ninth place in commits at GitHub on March 6, 2018 https://en.wikipedia.org/wiki/Kubernetes
● First CNCF graduated project https://www.cncf.io/blog/2018/03/06/kubernetes-first-cncf-project-graduate/
Why build it yourself?
● Learn more about the Kubernetes components
● Gives you more knowledge, helpful when debugging Kubernetes
● It’s fun!
Disclaimer
● What we’ll build today is not production-ready
Kubernetes the hard way
https://github.com/kelseyhightower/kubernetes-the-hard-way
Building Kubernetes from the ground up
1. Infrastructure
2. Certificates
3. Control plane
4. Workers
5. Networking
6. Test!
Infrastructure
VPC / Subnet
Infrastructure
AWS
Load balancer
Controller 1 Controller 2 Controller 3
Autoscaling group
Worker NWorker NWorker N
S3
Bucket
Demo
Certificates
Controller
Infrastructure
kube-apiserver
kube-controller-
manager
kube-scheduler
etcd
Worker
kubelet
kube-proxy
1
2
3
4
5
6
7
Demo
Control plane
VPC / Subnet
Infrastructure
AWS
Load balancer
Autoscaling group
Worker NWorker NWorker N
S3
Bucket
Controller 1 Controller 2 Controller 3
Controller 1
Control plane
kube-apiserver
kube-controller-
manager
kube-scheduler
etcd
1
2
3
4
Controller 2
kube-apiserver
kube-controller-
manager
kube-scheduler
etcd
1
2
3
4
Controller 3
kube-apiserver
kube-controller-
manager
kube-scheduler
etcd
API server
● Gateway into the cluster
● Handles authentication, authorization
Kubernetes changes
https://kubernetes.io/blog/2019/03/21/a-guide-to-kubernetes-admission-controllers/
while(true) {
if(currentState() != desiredState() {
updateState();
}
}
Controller manager
Controller manager: manages controllers
1. Node Controller: Responsible for noticing and responding when nodes go down.
2. Replication Controller: Responsible for maintaining the correct number of pods for every
replication controller object in the system.
3. Endpoints Controller: Populates the Endpoints object (that is, joins Services & Pods).
4. Service Account & Token Controllers: Create default accounts and API access tokens for
new namespaces.
https://kubernetes.io/docs/concepts/overview/components/#kube-controller-manager
Scheduler
https://medium.com/@dominik.tornow/the-kubernetes-scheduler-cd429abac02f
etcd
Controller 1
Control plane
kube-apiserver
kube-controller-
manager
kube-scheduler
etcd
1
2
3
4
Controller 2
kube-apiserver
kube-controller-
manager
kube-scheduler
etcd
1
2
3
4
Controller 3
kube-apiserver
kube-controller-
manager
kube-scheduler
etcd
Demo
Workers
VPC / Subnet
Infrastructure
AWS
Load balancer
Controller 1 Controller 2 Controller 3
S3
Bucket
Autoscaling group
Worker NWorker NWorker N
Infrastructure
Worker
kubelet
kube-proxy
Demo
Networking
Kubernetes Networking Model
1. All Pods can communicate with all other Pods without using network address
translation (NAT).
2. All Nodes can communicate with all Pods without NAT.
3. The IP that a Pod sees itself as is the same IP that others see it as.
https://sookocheff.com/post/kubernetes/understanding-kubernetes-networking-model/
Kubernetes Networking Model
● Same network: https://github.com/aws/amazon-vpc-cni-k8s
● Overlay network: https://github.com/coreos/flannel
https://sookocheff.com/post/kubernetes/understanding-kubernetes-networking-model/
VPC / Subnet
Same network
EC2 InstanceEC2 Instance
EC2 Instance
VPC / Subnet
Overlay network
EC2 InstanceEC2 Instance
flannel
(10.200.0.0/24)
flannel
(10.200.1.0/24)
Container Network Interface
● Pluggable networking layer
https://kubedex.com/kubernetes-network-plugins/
Infrastructure
Worker
kubelet
kube-proxy
Demo
Let’s test!
Deployment
Rolling updates
Rollbacks
Containers in Kubernetes
Replicaset
Number of replicas
Restarts failed containers
Pod
At least one container
Annotations
Metadata
Container
Deployment
Accessing containers in Kubernetes
Replicaset
Pod
Service Container
Pod
Container
Demo
Building Kubernetes from the ground up
● Infrastructure
● Certificates
● Control plane
● Workers
● Networking
● Test!
What’s next? (1)
● Improve certificate management
● High availability
○ Multi-AZ / Multi-Region / Multi-Cloud
○ Cluster Autoscaler / Pod Autoscaler
● DNS
○ CoreDNS (https://coredns.io)
● Cloud Controller Manager
● Networking plugin
What’s next? (2)
● Service mesh
○ Istio (https://istio.io) / Consul Connect (https://www.consul.io)
● Secret management
○ https://kubernetes.io/docs/tasks/administer-cluster/encrypt-data / Vault https://www.vaultproject.io
● Application deployments
○ E.g. Helm (https://helm.sh)
● Observability
● ...
“Managed” Kubernetes
● Google Kubernetes Engine (GKE) - Google Cloud
● Elastic Container Service for Kubernetes (EKS) - Amazon Web Services
● Azure Kubernetes Service (AKS) - Azure
● DigitalOcean Kubernetes - DigitalOcean
● ...
Thank you!
Questions?
Skyworkz - https://skyworkz.nl
Sander Knape - https://sanderknape.com - @SanderKnape

More Related Content

Kubernetes from the ground up

Editor's Notes

  1. This is also the goal of this talk: teach you more about the inner workings of Kubernets
  2. This is also the goal of this talk: teach you more about the inner workings of Kubernets