aboutsummaryrefslogtreecommitdiffstats
path: root/recipes-containers/kubernetes/kubernetes/k8s-init
blob: 586a3b73ed0ae68e563a65fa3c9935b5af9c276a (plain)
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
#!/bin/sh
#
# Copyright (C) 2021 Bruce Ashfield
#
# SPDX-License-Identifier: Apache-2.0

# cleanup the iptables
cp /etc/sysconfig/iptables /etc/sysconfig/iptables.ORIG && iptables --flush && iptables --flush && iptables-save > /etc/sysconfig/iptables
systemctl restart iptables.service

# Load/Enable br_netfilter kernel module
modprobe br_netfilter
modprobe overlay

echo '1' > /proc/sys/net/bridge/bridge-nf-call-iptables
echo '1' > /proc/sys/net/bridge/bridge-nf-call-ip6tables
echo 'net.bridge.bridge-nf-call-iptables=1' >> /etc/sysctl.d/k8s.conf
echo 'net.bridge.bridge-nf-call-ip6tables=1' >> /etc/sysctl.d/k8s.conf
echo 'net.ipv4.ip_forward=1' >> /etc/sysctl.d/k8s.conf

systemctl restart systemd-sysctl.service

kubeadm init

# Copy the cluster configuration to the regular users home directory
mkdir -p $HOME/.kube
cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
chown $(id -u):$(id -g) $HOME/.kube/config