Kodedkloud Instalation Hardway
Kodedkloud Instalation Hardway
Kodedkloud Instalation Hardway
Core Concepts
Scheduling
Logging Monitoring
Storage
Networking
DESIGN A
KUBERNETES
CLUSTER
Objectives
• Node Considerations
• Resource Requirements
• Network Considerations
Ask
• Purpose
• Education
• Development & Testing
• Hosting Production Applications
• Cloud or OnPrem?
• Workloads
• How many?
• What kind?
• Web
• Big Data/Analytics
• Application Resource Requirements
• CPU Intensive
• Memory Intensive
• Traffic
• Heavy traffic
• Burst Traffic
Purpose
• Education
• Minikube
• Single node cluster with kubeadm/GCP/AWS
M M
W W
Course Objectives
Core Concepts
Scheduling
Logging Monitoring
Storage
Networking
Choosing
Kubernetes
Infrastructure
Linux Windows
KUBEADM
Minikube
W W
Course Objectives
Core Concepts
Scheduling
Logging Monitoring
Storage
Networking
Chose a
Networking
Solution
GCE
Our Design
W W
Course Objectives
Core Concepts
Scheduling
Logging Monitoring
Storage
Networking
HA Kubernetes
Cluster
M W W
API API
ETCD ETCD
Server Server
Controller M Controller M
Scheduler Scheduler
Manager Manager
https://load-balancer:6443
Active Active
https://master1:6443 https://master2:6443
API API
Server Server
M M
Controller Controller
ETCD Scheduler ETCD Scheduler
Manager Manager
Active Standby
Controller Controller
Scheduler Scheduler
Manager Manager
M M
API API
ETCD ETCD
Server Server
Kube-controller-manager
Endpoint
master1
Active Standby
Controller Controller
Manager Manager
Scheduler Scheduler
M M
API API
ETCD ETCD
Server Server
ETCD ETCD
M M
✓ Easier to setup
✓ Easier to manage
✓ Fewer Servers
❖ Risk during failures
External ETCD Topology
ETCD ETCD
M M
✓ Less Risky
❖ Harder to Setup
❖ More Servers
cat /etc/systemd/system/kube-apiserver.service
[Service]
ExecStart=/usr/local/bin/kube-apiserver \\
--advertise-address=${INTERNAL_IP} \\
--allow-privileged=true \\
--apiserver-count=3 \\
--etcd-cafile=/var/lib/kubernetes/ca.pem \\
--etcd-certfile=/var/lib/kubernetes/kubernetes.pem \\
--etcd-keyfile=/var/lib/kubernetes/kubernetes-key.pem \\
--etcd-servers=https://10.240.0.10:2379,https://10.240.0.11:2379
ETCD ETCD
M M
ETCD ETCD
M M
W W
Course Objectives
Core Concepts
Scheduling
Logging Monitoring
Storage
Networking
ETCD
In HA
Objectives
• What is ETCD?
• What is a Key-Value Store?
• How to get started quickly?
• How to operate ETCD?
• What is a distributed system?
• How ETCD Operates
• RAFT Protocol
• Best practices on number of nodes
ETCD is a distributed
reliable key-value store
that is Simple, Secure &
Fast
key-value store Tabular/Relational Databases
Age 45 Age 34
{ { {
"name": "Aryan Kumar", "name": "Lily Oliver", "name": "Lauren Rob",
"age": 10, "age": 15, "age": 13,
"location": "New York", "location": "Bangalore", "location": "Bangalore",
"Grade": "A" "Grade": "B" "Grade": "C"
} } }
ETCD is a distributed
reliable key-value store
that is Simple, Secure &
Fast
distributed
2379 2379 2379
Consistent
WRITE WRITE
Name John
Joe
Leader Election - RAFT
L
L
Age 10
Name John
WRITE
Age 10
Name John
Instances Quorum Fault
Tolerance
1 1 0
Majority = N/2 + 1
Quorum
2 2 0
3 2 1
Quorum of 2 = 2/2 + 1 = 2
4 3 1
Quorum of 3 = 3/2 + 1 = 2.5 ~= 2
5 3 2
Quorum of 5 = 5/2 + 1 = 3.5 ~= 3
6 4 2
7 4 3
Odd or even?
1 1 0
Quorum - 4
2 2 0
3 2 1
4 3 1 Quorum - 4
Quorum - 4 Quorum - 4
5 3 2
6 4 2
7 4 3
Getting Started
wget -q --https-only \
"https://github.com/coreos/etcd/releases/download/v3.3.9/etcd-v3.3.9-linux-amd64.tar.gz"
mv etcd-v3.3.9-linux-amd64/etcd* /usr/local/bin/
name
john
name
Number of Nodes
Instances Quorum Fault
Tolerance
1 1 0 ETCD ETCD
2 2 0
3 2 1 M M
4 3 1
API Controller API Controller
Scheduler Scheduler
Server Manager Server Manager
5 3 2
6 4 2
7 4 3
Our Design
LB
ETCD ETCD
M M
W W
65
DEMO
Pre-Requisites
Course Objectives
Core Concepts
Scheduling
Logging Monitoring
Storage
Networking
Provision
Infrastructure
Our Design
LB
ETCD ETCD
M M
W W
vagrant up
• Deploys 5 VMs - 2 Master, 2 Worker and 1 Loadbalancer with the name 'kubernetes-ha-* ‘
• Set's IP addresses in the range 192.168.5
• Add's a DNS entry to each of the nodes to access internet
• Install's Docker on the nodes
72
DEMO
Provision Infrastructure
74
DEMO
Install Client Tools
Course Objectives
Core Concepts
Scheduling
Logging Monitoring
Storage
Networking
DEMO
Secure Cluster
Communication
78
79
DEMO
Kube Config Files
80
81
DEMO
Data Encryption
Course Objectives
Core Concepts
Scheduling
Logging Monitoring
Storage
Networking
Kubernetes
Release Binaries
wget https://github.com/kubernetes/kubernetes/releases/download/v1.13.3/kubernetes.tar.gz
kubernetes.tar.gz
cd kubernetes; ls
client cluster docs hack LICENSES platforms README.md
server version
cluster/get-kube-binaries.sh
client/kubernetes-client-linux-amd64.tar.gz
server/kubernetes-server-linux-amd64.tar.gz
ls kubernetes/server/bin
apiextensions-apiserver kubeadm kube-proxy.docker_tag mounter
cloud-controller-manager kube-apiserver kube-controller-manager.tar kube-proxy.tar
kubectl kube-scheduler cloud-controller-manager.tar kube-apiserver.tar
kubelet kube-scheduler.docker_tag
hyperkube kube-controller-manager kube-proxy kube-scheduler.tar
91
DEMO
Download Release Binaries
Course Objectives
Core Concepts
Scheduling
Logging Monitoring
Storage
Networking
Install Master
Our Design HAPRoxy
LB
Scheduler Scheduler
W W
96
97
DEMO
Install ETCD Cluster
98
99
DEMO
Install Control-plane
Components
100
101
DEMO
Install Load Balancer
102
Course Objectives
Core Concepts
Scheduling
Logging Monitoring
Storage
Networking
Install Worker
Nodes
Our Design HAPRoxy
LB
M M
Controller Controller
Manager Manager
Scheduler Scheduler
DEMO
Install Worker-1
107
Course Objectives
Core Concepts
Scheduling
Logging Monitoring
Storage
Networking
TLS Bootstrap
Kubelet
Our Design HAPRoxy
LB
M M
Controller Controller
Manager Manager
Scheduler Scheduler
M W
Client Certs
kubelet.service
ExecStart=/usr/local/bin/kubelet \\
--config=/var/lib/kubelet/kubelet-config.yaml \\
--image-pull-progress-deadline=2m \\
--kubeconfig=/var/lib/kubelet/kubeconfig \\
--tls-cert-file=/var/lib/kubelet/worker-1.crt \\
--tls-private-key-file=/var/lib/kubelet/worker-1.key \\
--network-plugin=cni \\
--register-node=true \\
--v=2
system:bootstrappers system:nodes
M
Submit CSR? system:node-bootstrapper
DEMO
TLS Bootstrap Kubelet
118
119
DEMO
Configure KubeConfig File
120
121
DEMO
Provision Networking
122
123
DEMO
KubeApi Server to Kubelet
Connectivity
124
125
DEMO
Deploy DNS - CoreDNS
126
Course Objectives
Core Concepts
Scheduling
Logging Monitoring
Storage
Networking
Node end-to-end
Tests
Test - Manual
kubectl get nodes
NAME STATUS ROLES AGE VERSION
worker-1 Ready <none> 8d v1.13.0
worker-2 Ready <none> 8d v1.13.0
curl http://worker-1:31850
...
<h1>Welcome to nginx!</h1>
...
kubetest
kubetest - Tests
e2e: ~1000
sig-api-machinery sig-apps sig-auth sig-cli
My-kubeadm.sh
Kubetest - Tests
e2e: ~1000
conformance: ~160
Kubetest - Tests
e2e: ~1000
conformance: ~160
Kubetest - Time
Scheduling
Logging Monitoring
Storage
Networking
cd kubernetes
export KUBE_MASTER_IP=“192.168.26.10:6443”
export KUBE_MASTER=kube-master
cat testout.txt
Client Version: version.Info{Major:"1", Minor:"11", GitVersion:"v1.11.8",
GitCommit:"4e209c9383fa00631d124c8adcc011d617339b3c", GitTreeState:"clean", BuildDate:"2019-02-28T18:49:34Z",
GoVersion:"go1.10.8", C
ompiler:"gc", Platform:"linux/amd64"}
Server Version: version.Info{Major:"1", Minor:"11", GitVersion:"v1.11.8",
GitCommit:"4e209c9383fa00631d124c8adcc011d617339b3c", GitTreeState:"clean", BuildDate:"2019-02-28T18:40:05Z",
GoVersion:"go1.10.8", C
ompiler:"gc", Platform:"linux/amd64"}
Setting up for KUBERNETES_PROVIDER="skeleton".
Mar 14 11:16:12.419: INFO: Overriding default scale value of zero to 1
Mar 14 11:16:12.419: INFO: Overriding default milliseconds value of zero to 5000
I0314 11:16:12.674596 20093 e2e.go:333] Starting e2e run "933b1eae-464a-11e9-81ea-02f0aa2d49f4" on Ginkgo node 1
Running Suite: Kubernetes e2e suite
===================================
Random Seed: 1552562172 - Will randomize all specs
Will run 167 of 1008 specs
kubetest- Run
/workspace/anago-v1.11.8-
beta.0.41+4e209c9383fa00/src/k8s.io/kubernetes/_output/dockerized/go/src/k8s.io/kubernetes/test/e2e/common/empty_dir.g
o:40
should support (root,0777,tmpfs) [NodeConformance] [Conformance]
/workspace/anago-v1.11.8-
beta.0.41+4e209c9383fa00/src/k8s.io/kubernetes/_output/dockerized/go/src/k8s.io/kubernetes/test/e2e/framework/framewor
k.go:684
------------------------------
SSMar 14 13:01:15.397: INFO: Running AfterSuite actions on all node
Mar 14 13:01:15.397: INFO: Running AfterSuite actions on node 1
Summarizing 2 Failures:
[Fail] [sig-network] DNS [It] should provide DNS for services [Conformance]
/workspace/anago-v1.11.8-
beta.0.41+4e209c9383fa00/src/k8s.io/kubernetes/_output/dockerized/go/src/k8s.io/kubernetes/test/e2e/network/dns_common
.go:497
[Fail] [sig-network] DNS [It] should provide DNS for the cluster [Conformance]
/workspace/anago-v1.11.8-
beta.0.41+4e209c9383fa00/src/k8s.io/kubernetes/_output/dockerized/go/src/k8s.io/kubernetes/test/e2e/network/dns_common
.go:497
DEMO
Run Smoke Test
152
153
DEMO
Run End-to-End Tests