forked from kubeedge/kubeedge
-
Notifications
You must be signed in to change notification settings - Fork 0
/
docker_pavan
222 lines (161 loc) · 7.47 KB
/
docker_pavan
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
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
SETTING UP KUBERNETES CLUSTER USING KUBEADM:
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Machine details:
------------------
# lsb_release -a
Distributor ID: Ubuntu
Description: Ubuntu 16.04.1 LTS
Release: 16.04
Codename: xenial
# docker version
Client:
Version: 1.13.1
API version: 1.26
Go version: go1.6.2
Git commit: 092cba3
Built: Thu Nov 2 20:40:23 2017
OS/Arch: linux/amd64
Server:
Version: 1.13.1
API version: 1.26 (minimum version 1.12)
Go version: go1.6.2
Git commit: 092cba3
Built: Thu Nov 2 20:40:23 2017
OS/Arch: linux/amd64
Experimental: false
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
########################################################################################################################################################
Setting up environment
########################################################################################################################################################
1. Configure the nameserver
*****************************
Note: This file will get overwritten in every reboot. So if you are rebooting your machine anytime, then do this step again.
vi /etc/resolv.conf
nameserver 10.20.6.45
nameserver 10.98.48.39
nameserver 10.72.255.100
nameserver 10.72.55.82
search huawei.com
2. Configure apt.conf
*************************
vi /etc/apt/apt.conf
Acquire::http::Proxy "http://username:[email protected]:8080";
Acquire::https::Proxy "https://username:[email protected]:8080";
########################################################################################################################################################
Installing Docker
########################################################################################################################################################
1. Install docker (Skip this step if already installed)
*********************************************************
i) Set proxy in environment
------------------------------
$ export http_proxy=http://username:[email protected]:8080
$ export https_proxy=https://username:[email protected]:8080
ii) Install docker.io
------------------------
$ sudo apt install docker.io
iii) Unset proxy from environment
------------------------------------
$ unset http_proxy https_proxy
2. Configure docker to run behind proxy
*****************************************
$ sudo mkdir -p /etc/systemd/system/docker.service.d
ii) Create http_proxy configuration
------------------------------------
$ sudo vim /etc/systemd/system/docker.service.d/http-proxy.conf
[Service]
Environment="HTTP_PROXY=http://username:[email protected]:8080"
iii) Create https proxy configuration
---------------------------------------
$ sudo vim /etc/systemd/system/docker.service.d/https-proxy.conf
[Service]
Environment="HTTPS_PROXY=http://username:[email protected]:8080"
iv) Restart the Docker service and reload the docker daemon
-------------------------------------------------------------
$ sudo systemctl daemon-reload
$ sudo systemctl restart docker
v) Confirm the docker Environment Variables
---------------------------------------------
$ systemctl show --property=Environment docker
3. Verify docker installation
*******************************
$ sudo docker run hello-world
########################################################################################################################################################
Setting up kubernetes cluster
########################################################################################################################################################
1. Set proxy in environment
****************************
$ sudo -i
# export http_proxy=http://username:[email protected]:8080
# export https_proxy=https://username:[email protected]:8080
2. Install kubectl
*********************
# curl -LO https://storage.googleapis.com/kubernetes-release/release/$(curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt)/bin/linux/amd64/kubectl
# chmod +x ./kubectl
# mv ./kubectl /usr/local/bin/kubectl
3. Configure apt to skip verification of https://packages.cloud.google.com
****************************************************************************
# vi /etc/apt/apt.conf
Acquire::https::packages.cloud.google.com::Verify-Peer "false";
3. Install Kubeadm and Kubelet
**********************************
# apt-get update && apt-get install -y apt-transport-https
# wget --no-check-certificate https://packages.cloud.google.com/apt/doc/apt-key.gpg
# apt-key add apt-key.gpg
# cat <<EOF >/etc/apt/sources.list.d/kubernetes.list
deb http://apt.kubernetes.io/ kubernetes-xenial main
EOF
# apt-get update
# apt-get install -y kubelet kubeadm
Create Kubernetes clusetr:
*****************************
Unset proxy from environment
----------------------------------
# unset http_proxy https_proxy
Make swap off
-----------------
# swapoff -a
Check for kubeadm version
----------------------------
# kubeadm version
e.g: kubeadm version: &version.Info{Major:"1", Minor:"9", GitVersion:"v1.9.0", GitCommit:"925c127ec6b946659ad0fd596fa959be43f0cc05", GitTreeState:"clean", BuildDate:"2017-12-15T20:55:30Z", GoVersion:"go1.9.2", Compiler:"gc", Platform:"linux/amd64"}
Use the same kubeadm version (GitVersion) to create the cluster
-----------------------------------------------------------------
# kubeadm init --pod-network-cidr=10.244.0.0/16 --kubernetes-version=v1.9.0
Run these commands to enable kubectl to work
-----------------------------------------------
# mkdir -p $HOME/.kube
# sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
# sudo chown $(id -u):$(id -g) $HOME/.kube/config
Verify the docker processes are running for k8s components
-----------------------------------------------------------
# docker ps
Verify respective pods are running for the k8s components
-----------------------------------------------------------
# kubectl get pods --all-namespaces
Install cni plugin
--------------------
https://raw.githubusercontent.com/coreos/flannel/master/Documentation/kube-flannel.yml
write the content of this url into a file.
# vi kube-flannel.yaml
# kubectl create -f kube-flannel.yaml
Untaint master node so that new pods can schedule there
----------------------------------------------------------
# kubectl taint nodes --all node-role.kubernetes.io/master-
Resetting kubeadm
-------------------
#kubeadm reset
########################################################################################################################################################
Basic Kubectl commands:
########################################################################################################################################################
Note1: Below commands will work for all types of kubernetes object like pod, deployment, node, replicaset, etc.
Note2: If the object is present in a namespace other than default, then add flag: --namespace=<namespace_name>
Create pod:
# kubectl create -f pod.yaml
Delete pod:
# kubectl delete -f pod.yaml
or
#kubectl delete pod <pod_name>
Describe pod:
# kubectl describe pod <pod_name>
Edit pod:
# kubectl edit pod <pod_name>