-
Notifications
You must be signed in to change notification settings - Fork 13
Expand file tree
/
Copy pathKubernetes Configuration
More file actions
202 lines (138 loc) · 6.84 KB
/
Kubernetes Configuration
File metadata and controls
202 lines (138 loc) · 6.84 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
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
# download ubuntu from https://ubuntu.com/download/desktop
# Ubuntu 20.10 - Version used
#Enabling SSH on Ubuntu -- > https://linuxize.com/post/how-to-enable-ssh-on-ubuntu-18-04/
#The latest version of the Ubuntu operating system for desktop PCs and laptops --- >https://ubuntu.com/download/desktop
#Install Docker Engine on Ubuntu ---> https://docs.docker.com/engine/install/ubuntu/
#Installing kubeadm ---->https://kubernetes.io/docs/setup/production-environment/tools/kubeadm/install-kubeadm/
#Creating a cluster with kubeadm --->https://v1-18.docs.kubernetes.io/docs/setup/production-environment/tools/kubeadm/create-cluster-kubeadm/
#Introducing Weave Net|Integrating Kubernetes via the Addon --- > https://www.weave.works/docs/net/latest/kubernetes/kube-addon/
-----> sudo apt update
-----> apt install net-tools
*******Install SSH for Putty******* #FROM <https://askubuntu.com/questions/760378/can-not-install-openssh-server-on-ubuntu-16-04>
sudo apt install openssh-server <------ Install SSHD
---> systemctl status sshd
---> sudo ufw allow ssh ----For firewall enable on port 22
1) Disable Swap
## By disabling swapping, you will also prevent memory algorithms from doing unnecessary operation - moving data from RAM to swap and vice versa - in case of SSD this will prevent excessive wear. And in any case this will improve the performance by eliminating unnecessary operations
https://superuser.com/questions/810170/should-i-disable-swap-file-if-i-have-lots-of-ram-or-should-i-move-it-to-a-virtua#:~:text=By%20disabling%20swapping%2C%20you%20will,performance%20by%20eliminating%20unnecessary%20operations.
============
---> sudo swapoff -a
#(put sign # at the beginning on the UUID of swap partition)
----> sudo nano /etc/fstab
2) Letting iptables see bridged traffic (br_netfilter module should be loaded)
Make sure that the br_netfilter module is loaded. This can be done by running lsmod | grep br_netfilter. To load it explicitly call sudo modprobe br_netfilter.
As a requirement for your Linux Node's iptables to correctly see bridged traffic, you should ensure net.bridge.bridge-nf-call-iptables is set to 1 in your sysctl config, e.g.
===========================================================================
---> lsmod | grep br_netfilter
---> modprobe br_netfilter
---> lsmod | grep br_netfilter
---> cat <<EOF | sudo tee /etc/sysctl.d/k8s.conf
net.bridge.bridge-nf-call-ip6tables = 1
net.bridge.bridge-nf-call-iptables = 1
EOF
----> sudo sysctl --system
#sysctl is a software utility of some Unix-like operating systems that reads
#and modifies the attributes of the system kernel such as its version number,
#maximum limits, and security settings.
3) Container runtime (Docker)
==========================
Reference:
# https://v1-18.docs.kubernetes.io/docs/setup/production-environment/container-runtimes/
# https://docs.docker.com/engine/install/ubuntu/
---------
# (Install Docker CE)
## Set up the repository:
### Install packages to allow apt to use a repository over HTTPS
-----------------------------------------------------------------
#Uninstall old versions
sudo apt-get remove docker docker-engine docker.io containerd runc
#SET UP THE REPOSITORY
-------------------------
sudo apt-get update
$ sudo apt-get install \
apt-transport-https \
ca-certificates \
curl \
gnupg-agent \
software-properties-common
# Add Docker’s official GPG key:
--------------------------------
sudo curl -fsSL https://download.docker.com/linux/ubuntu/gpg | apt-key add -
# Add the Docker apt repository: Use the following command to set up the stable repository.
-------------------------------
sudo add-apt-repository \
"deb [arch=amd64] https://download.docker.com/linux/ubuntu \
$(lsb_release -cs) \
stable"
#INSTALL DOCKER ENGINE
___________________
$ sudo apt-get update
$ sudo apt-get install docker-ce docker-ce-cli containerd.io
# Set up the Docker daemon
---------------------------
cat > /etc/docker/daemon.json <<EOF
{
"exec-opts": ["native.cgroupdriver=systemd"],
"log-driver": "json-file",
"log-opts": {
"max-size": "100m"
},
"storage-driver": "overlay2"
}
EOF
mkdir -p /etc/systemd/system/docker.service.d
# Restart Docker
----------------
systemctl daemon-reload
systemctl enable docker
systemctl restart docker
systemctl status docker
4) Installing kubeadm, kubelet and kubectl
=======================================
sudo apt-get update && sudo apt-get install -y apt-transport-https curl
sudo curl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo apt-key add -
cat <<EOF | sudo tee /etc/apt/sources.list.d/kubernetes.list
deb https://apt.kubernetes.io/ kubernetes-xenial main
EOF
sudo apt-get update
sudo apt-cache policy kubeadm | grep 1.18
sudo apt-get install -y kubelet=1.18.8-00 kubeadm=1.18.8-00 kubectl=1.18.8-00
sudo apt-mark hold kubelet kubeadm kubectl
Note: For latest version, use sudo apt-get install -y kubelet kubeadm kubectl
----
5) Initialized time synchronization
sudo timedatectl
sudo timedatectl list-timezones | grep " Whatever your city and state is"
sudo timedatectl set-timezone America/Los_Angeles
shutdown now
*************************************************************************
To initialize the control-plane node run:
-----> sudo kubeadm init
####- To Check if the nodes are available ##
---> kubectl cluster-info
---> kubectl get nodes
*****************Integrating Kubernetes via the Addon------> Weave Net creates a virtual network*****
#https://www.weave.works/docs/net/latest/kubernetes/kube-addon/
Weave Net creates a virtual network that connects Docker containers across multiple hosts and enables their automatic discovery.
With Weave Net, portable microservices-based applications consisting of multiple containers can run anywhere:
on one host, multiple hosts or even across cloud providers and data centers.
Applications use the network just as if the containers were all plugged into the same network switch, without having to configure port mappings, ambassadors or links.
----> kubectl apply -f "https://cloud.weave.works/k8s/net?k8s-version=$(kubectl version | base64 | tr -d '\n')"
***************Misc..Command****to troubleshoot network error***
cat /etc/network/interfaces ****
*********************************************
# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).
source /etc/network/interfaces.d/*
# The loopback network interface
# The primary network interface
auto enp0s8
iface enp0s8 inet static
address XXX.XXX.XXX.XXX
netmask 255.255.255.0
*********************************
FORExample:
kubeadm join XXX.XXX.XXX.XXX2:6443 --token ******** --discovery-token-ca-cert-hash sha256:58ee813e3f24029d6af2ef8c4f73200d402089c2ad61e7925e8904bd2eef39dc
kubeadm token list
kubeadm token delete "token number"
kubeadm token create --print-join-command