kubeadm on centos7

博客介绍了Kubernetes的安装与配置过程,包括开放端口、安装kubeadm和证书、关闭交换空间、配置代理设置等步骤。初始化成功后,需为集群部署Pod网络,还可安装flannel,最后涉及节点加入和更改主节点主机名等内容。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

# vi /etc/hosts    // add the hostname
# hostname knodex
# yum install -y docker
# systemctl enable docker && systemctl restart docker

开放端口

systemctl stop firewalld
systemctl disable firewalld
setenforce 0
vi /etc/selinux/config
SELINUX=disabled

edit /etc/sysctl.d/k8s.conf:
net.bridge.bridge-nf-call-ip6tables = 1
net.bridge.bridge-nf-call-iptables = 1
net.ipv4.ip_forward = 1
vm.swappiness=0


modprobe br_netfilter
sysctl -p /etc/sysctl.d/k8s.conf

Install kubeadm

cat <<EOF > /etc/yum.repos.d/kubernetes.repo
[kubernetes]
name=Kubernetes
baseurl=https://packages.cloud.google.com/yum/repos/kubernetes-el7-x86_64
enabled=1
gpgcheck=1
repo_gpgcheck=1
gpgkey=https://packages.cloud.google.com/yum/doc/yum-key.gpg
        https://packages.cloud.google.com/yum/doc/rpm-package-key.gpg
EOF

Install certificate

/etc/pki/ca-trust/source/anchors/Your-company.crt
update-ca-trust force-enable
[root@localhost ~]# update-ca-trust extract
[root@localhost ~]# vi /etc/yum.repos.d/kubernetes.repo  (You can turn SSL off in .crt is not available)

Install kubeadm

yum makecache fast
yum install -y kubelet kubeadm kubectl

Turn off swap

swapoff -a
/etc/fstab, comment out the line of swap

Or remove the limitation

/etc/sysconfig/kublet, add
KUBELET_EXTRA_ARGS=--fail-swap-on=false

Configure proxy settings

Set the noproxy
copy /etc/environment file
source /etc/environment
systemctl enable kubelet.service
kubeadm init \
  --kubernetes-version=v1.14.2 \
  --pod-network-cidr=10.244.0.0/16 \
  --apiserver-advertise-address=MasterIP

Your Kubernetes control-plane has initialized successfully!

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

# useradd -d /home/xyz -m xyz
#usermod -aG wheel YOUR_NAME
# passwd xyz
  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/

$ kubectl get cs
NAME                 STATUS    MESSAGE             ERROR
controller-manager   Healthy   ok                  
scheduler            Healthy   ok                  
etcd-0               Healthy   {"health":"true"} 

Install flannel

 mkdir -p ~/k8s/ cd ~/k8s wget https://raw.githubusercontent.com/coreos/flannel/master/Documentation/kube-flannel.yml 
 kubectl apply -f kube-flannel.yml
 
kubectl taint nodes node1 node-role.kubernetes.io/master-

Join

kubeadm join masterip:6443 --token blahblah \
    --discovery-token-ca-cert-hash sha256:yadayada

Change master host name

# kubeadm reset
# kubeadm init   --kubernetes-version=v1.14.2 \
  --pod-network-cidr=10.244.0.0/16 \
  --apiserver-advertise-address=MasterIP
 
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值