Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
K
kubernetes_on-prim
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Package registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Peter Toth
kubernetes_on-prim
Commits
5c2015e8
Commit
5c2015e8
authored
2 years ago
by
Peter Toth
Browse files
Options
Downloads
Patches
Plain Diff
setup shell for kubectl, kubeadm, kubelet, containerd
parent
764bb4db
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
kube8s-containerd/k8s-setup-master.sh
+86
-0
86 additions, 0 deletions
kube8s-containerd/k8s-setup-master.sh
with
86 additions
and
0 deletions
kube8s-containerd/k8s-setup-master.sh
0 → 100644
+
86
−
0
View file @
5c2015e8
#!/usr/bin/env bash
#set -Eeuo pipefail
#trap cleanup SIGINT SIGTERM ERR EXIT
IFNAME
=
$1
ADDRESS
=
"
$(
ip
-4
addr show
$IFNAME
|
grep
"inet"
|
head
-1
|awk
'{print $2}'
|
cut
-d
/
-f1
)
"
sed
-e
"s/^.*
${
HOSTNAME
}
.*/
${
ADDRESS
}
${
HOSTNAME
}
${
HOSTNAME
}
.local/"
-i
/etc/hosts
# remove ubuntu-jammy entry
sed
-e
'/^.*ubuntu-jammy.*/d'
-i
/etc/hosts
sed
-i
-e
's/#DNS=/DNS=8.8.8.8/'
/etc/systemd/resolved.conf
# Update /etc/hosts about other hosts
cat
>>
/etc/hosts
<<
EOF
192.168.56.9 hapr-node
192.168.56.10 master-node
192.168.56.11 worker-node1
192.168.56.12 worker-node2
EOF
# the following package are used by kubeadm and are not part of jammy
apt-get update
&&
apt-get
install
-y
socat conntrack
#containerd
curl
-fsSL
https://download.docker.com/linux/ubuntu/gpg |
sudo
gpg
--dearmor
-o
/etc/apt/keyrings/docker.gpg
echo
\
"deb [arch=
$(
dpkg
--print-architecture
)
signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu
\
$(
lsb_release
-cs
)
stable"
|
sudo tee
/etc/apt/sources.list.d/docker.list
>
/dev/null
apt-get update
apt-get
install
-y
containerd.io
#runc is part of containerd.io
# the following package are used by kubeadm and are not part of jammy
apt-get
install
-y
socat conntrack net-tools
mkdir
-p
/etc/containerd
# if config.toml exists kubeadm will not work (doc is wrong)
# containerd config default > /etc/containerd/config.toml
# details about cgroup change https://kubernetes.io/docs/setup/production-environment/container-runtimes/#containerd-systemd
# sed -i -e 's/SystemdCgroup = false/SystemdCgroup = true/' /etc/containerd/config.toml
curl
-fsSLo
/etc/apt/keyrings/kubernetes-archive-keyring.gpg https://packages.cloud.google.com/apt/doc/apt-key.gpg
echo
"deb [signed-by=/etc/apt/keyrings/kubernetes-archive-keyring.gpg] https://apt.kubernetes.io/ kubernetes-xenial main"
|
sudo tee
/etc/apt/sources.list.d/kubernetes.list
#install kubectl ...
apt-get update
apt-get
install
-y
kubelet kubeadm kubectl bash-completion
apt-mark hold kubelet kubeadm kubectl bash-completion
# install plugins for container network interface (CNI)
cd
/opt/cni/bin/
wget https://github.com/containernetworking/plugins/releases/download/v1.1.1/cni-plugins-linux-amd64-v1.1.1.tgz
tar
-zxvf
cni-plugins-linux-amd64-v1.1.1.tgz
rm
cni-plugins-linux-amd64-v1.1.1.tgz
echo
'source <(kubectl completion bash)'
>>
~/.bashrc
#source /usr/share/bash-completion/bash_completion
kubectl completion bash
>
/etc/bash_completion.d/kubectl
# Set modules to load during boot
cat
<<
EOF
| sudo tee /etc/modules-load.d/k8s.conf
overlay
br_netfilter
EOF
# Set iptables bridging
cat
<<
EOF
| sudo tee /etc/sysctl.d/k8s.conf
net.bridge.bridge-nf-call-iptables = 1
net.bridge.bridge-nf-call-ip6tables = 1
net.ipv4.ip_forward = 1
EOF
#load a couple of necessary modules
sudo
modprobe overlay
sudo
modprobe br_netfilter
sudo
sysctl
--system
#disable swaping
sudo
swapoff
-a
sed
's/# /swap.*/#swap.img/'
/etc/fstab
service systemd-resolved restart
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment