K8S集群安装部署
Posted abcyrf
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了K8S集群安装部署相关的知识,希望对你有一定的参考价值。
参考文章:
https://www.kubernetes.org.cn/3773.html
设置静态IP地址
BOOTPROTO="static" #dhcp改为static
ONBOOT="yes" #开机启用本配置
IPADDR=192.168.7.106 #静态IP
GATEWAY=192.168.7.1 #默认网关
NETMASK=255.255.255.0 #子网掩码
service network restart
设置yum源
yum install wget -y
echo 备份当前的yum源
mv /etc/yum.repos.d /etc/yum.repos.d.backup4comex
echo 新建空的yum源设置目录
mkdir /etc/yum.repos.d
echo 下载阿里云的yum源配置
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
以上是关于K8S集群安装部署的主要内容,如果未能解决你的问题,请参考以下文章