-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnotes
More file actions
145 lines (109 loc) · 4.14 KB
/
Copy pathnotes
File metadata and controls
145 lines (109 loc) · 4.14 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
etcd
=====
kubectl exec etcd-master -n kube-system etcdctl get / --prefix -keys-only
*********** MASTER NODE ************
kube-apiserver (on Master)
==============
kubectl --> talks to kube-apiserver
can also use API directly --> curl -X POST /api/v1/namespaces/default/pods ...[other]
can be downloaded as a binary from k8s release
kube-apiserver.service
kubectl get pods -n kube-system
kube-apiserver-master (on master node)
cat /etc/kubernets/manifests/kube-apiserver.yaml
cat /etc/systemd/system/kube-apiserver.service
ps -aux | grep kube-apiserver
kube-controller-manager
=======================
1. Watch Status
2. Remediate Situations
-- Node-Controller----->(5sec)---->kube-apiserver------->[nodes]
(wait for 40 seconds once node goes down and marks are unreachable - then waits for 5 mins to come back up - if not, then it starts evacuating the pods and run them on available nodes)
POD Eviction Timeout = 5m
-- replication-controllers
monitor is desired number of pods are running at all times
many more controllers available
kube-controller-manager.service
kubectl get pods -n kube-system
cat /etc/kubernetes/manifests/kube-controller-manager.yaml
cat /etc/systemd/system/kube-controller-manager.service
ps -aux | grep kube-controller-manager
kube-scheduler
===============
decides what pods go to which node (doesn't do it himself, that's kubelet job)
1. Filter Nodes (eg: based on resource requirements, affinity rules, etc.)
2. Rank Nodes (eg: how many resources will be left after placing a pod - higher wins)
cat /etc/kubernetes/manifests/kube-scheduler.yaml
cat /etc/systemd/
ps -aux
*********** WORKER NODE ************
Kubelet:
=========
kubeadm does not deploy kubelet
ps -aux | grep kubelet
kube-proxy
===========
every pod can reach every pod - using virtual network - all pods connect to this network
many solution available for deploying this
uses iptables rules on every node to tell where the traffic needs to go for particular services
can download from k8s release page
kubectl get pods -n kube-system
deployed as deamonset (every node will have at least 1 pod)
kubectl get deamonset -n kube-system
PODs
=======
containers are encapsulated inside pods in k8s
do not add containers in the same pod to scale application
YAML
=====
(indention matters - should be consistent)
mandatory fields:
------------------
apiVersion: --> version of k8s api of what we are creating
kind: --> Pod (e.g.: ReplicaSet, Deployment, etc.)
metadata:
name: myapp-pod
labels:
app: myapp
type: front-end --> (to make it easier to find pods based on their function)
spec:
containers: --> List/Array
- name: nginx-container ("-" to tell this is first item in the list)
image: nginx
kubectl describe pod myapp-pod
PODS Demo
=========
- writing pod.yaml file
Generate pod yaml:
==================
kubectl run nginx --image=nginx --dry-run -o yaml
Generate deployment YAML:
=========================
kubectl create deployment --image=httpd:2.4-alpine httpd-frontend --dry-run -o yaml > deployment-httpd-frontend.yaml
master $ history
1 clear
2 RED='\033[0;31m'
3 NC='\033[0m'
4 trap 'rm -rf /tmp/load-quiz.sh ; rm -rf /tmp/wait-script.sh' SIGINT SIGQUIT ERR SIGTSTP
5 clear
6 while [ ! -f /tmp/wait-script.sh ] ; do clear; echo "Waiting for environment to load"; sleep .2; done
7 chmod 755 /tmp/wait-script.sh; /tmp/wait-script.sh
8 clear
9 kubectl get pods
10 kubectl get rs
11 kubectl get deployments
12 kubectl get rs
13 kubectl get pods
14 kubectl describe pod frontend-deployment-55c859888c-hxk4b
15 kubectl create -f deployment-definition-1.yaml
16 vim deployment-definition-1.yaml
17 kubectl create -f deployment-definition-1.yaml
18 kubectl get deployments
19 kubectl create deployment --image=httpd:2.4-alpine httpd-frontend --dry-run -o yaml > deployment-httpd-frontend.yaml
20 cat deployment-httpd-frontend.yaml
21 vim deployment-httpd-frontend.yaml
22 kubectl create deployment -f deployment-httpd-frontend.yaml
23 kubectl create -f deployment-httpd-frontend.yaml
24 kubectl get deployment
25 kubectl run nginx --image=nginx --dry-run -o yaml
26 history