K8S cluster installation and deployment

Reference article:
https://www.kubernetes.org.cn/3773.html

Set static IP address
BOOTPROTO="static" #dhcp to static
ONBOOT="yes" #Enable this configuration at boot
IPADDR=192.168.7.106 #Static IP
GATEWAY=192.168.7.1 #Default gateway
NETMASK=255.255.255.0 #Subnet mask

service network restart

set yum source

yum install wget -y
echo Backup the current yum source
mv /etc/yum.repos.d /etc/yum.repos.d.backup4comex
echo Create an empty yum source setting directory
mkdir /etc/yum.repos.d
echo Download Ali Cloud's yum source configuration
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
yum clean all
yum makecache

yum install dos2unix

scp -r /etc/etcd/ssl [email protected]:/etc/etcd/
scp -r /etc/etcd/ssl [email protected]:/etc/etcd/
source /etc/profile

etcdctl --endpoints=https://192.168.1.223:2379 --ca-file=/etc/etcd/ssl/ca.pem --cert-file=/etc/etcd/ssl/etcd.pem --key-file=/etc/etcd/ssl/etcd-key.pem cluster-health

sed -i "s/--selinux-enabled/--selinux-enabled=false/g" /etc/sysconfig/docker
sed -i '9a\Environment=”KUBELET_EXTRA_ARGS=--pod-infra-container-image=registry.cn-hangzhou.aliyuncs.com/osoulmate/pause-amd64:3.0″' /etc/systemd/system/kubelet.service.d/10-kubeadm.conf

sudo mkdir -p /etc/docker
sudo tee /etc/docker/daemon.json <<-'EOF'
{
"registry-mirrors": ["https://w8qazxxa.mirror.aliyuncs.com"]
}
EOF

kubeadm init --config config.yaml

To start using your cluster, you need to run the following as a regular user:

mkdir -p $HOME/.kube
sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
sudo chown $(id -u):$(id -g) $HOME/.kube/config

You should now deploy a pod network to the cluster.
Run "kubectl apply -f [podnetwork].yaml" with one of the options listed at:
https://kubernetes.io/docs/concepts/cluster-administration/addons/

You can now join any number of machines by running the following on each node
as root:

kubeadm join 192.168.1.224:6443 --token b33a99.a244ef77531e4354 --discovery-token-ca-cert-hash sha256:7822cbc317a1feb2550eb7033e5f60a7b4ed6577fbe431304ccb408f4d1d0cf6

scp -r / etc / kubernetes / pki [email protected] : / etc / kubernetes /
scp -r / etc / kubernetes / pki [email protected] : / etc / kubernetes /

systemctl restart keepalived
systemctl restart etcd
systemctl daemon-reload
systemctl restart docker
systemctl restart kubelet

systemctl status keepalived
systemctl status etcd
systemctl status docker
systemctl status kubelet

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325189329&siteId=291194637