# 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