3 build local node kubernetes

kubernetes build local versions of selected

  • CentOS Linux release 7.7.1908
  • kubernetesVersion: v1.17.0
  • weave: 2.6.0
  • ceph/ceph:v14.2.6

CentOS environment ready

3 Check the machine environment

  • master memory at least 4GiB

  • Disable swap partition master
sudo swapoff -a
  • Permanently disabled
sudo vi /etc/fstab
把/dev/mapper/centos-swap swap这行注释掉
  • sysctl arrangement
cat > /etc/sysctl.d/k8s.conf <<EOF
net.bridge.bridge-nf-call-ip6tables = 1
net.bridge.bridge-nf-call-iptables = 1
vm.swappiness=0
EOF

sysctl --system

  • free secret key

See Network Other articles

  • hostname

hostnamectl set-hostname xx

  • hostname and ip mapping
cat >> /etc/hosts <<EOF 
172.16.225.129 k8s-02
172.16.225.130 k8s-03
172.16.225.200 k8s-01
EOF

yum source and installation

  • Configuring kubernetes yum source
# k8s yum源
cat > /etc/yum.repos.d/kubernetes.repo <<EOF
[kubernetes]
name=kubernetes
baseurl=https://mirrors.aliyun.com/kubernetes/yum/repos/kubernetes-el7-x86_64/
gpgcheck=0
enable=1
EOF
>>
  • Configuring docker yum source

cd /etc/yum.repos.d

wget https://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo

yum clean all

yum repolist

  • 安装 Rocker, kubeadm, omelets and kubectl

yum install -y docker-ce kubeadm kubelet kubectl

  • Check the docker and kubelet

systemctl enable --now docker && systemctl enable --now kubelet

  • Check the log

systemctl status kubelet

journalctl -xeu kubelet

kubernetes environment to build

Installation k8s master

  • Installation master, a method:
    query list
    kubeadm config images list

  • Installation master, Act II:
  1. 生成 kubaeadm.yaml

kubeadm config print init-defaults > kubeadm.yaml

  1. Use kubeadm.yaml file (1.15.X version)
cat <<EOF > kubeadm.yaml
apiVersion: kubeadm.k8s.io/v1beta2
kind: InitConfiguration
nodeRegistration: # 去掉master污点
  taints:
  - effect: PreferNoSchedule
    key: node-role.kubernetes.io/master
---
apiVersion: kubeadm.k8s.io/v1beta2
kind: ClusterConfiguration
imageRepository: registry.aliyuncs.com/google_containers # images地址
kubernetesVersion: v1.17.0 # version
EOF
  1. Initialization cluster
    kubeadm init --config kubeadm.yaml | tee kubeadmin.log
  • Creating again tocken (option)
    token expired The
    kubeadm token create --print-join-command

return a token
kubeadm join 172.17.55.202:6443 --token 4xv6eq.5kygve4g6uy1smat \ --discovery-token-ca-cert-hash sha256:3ab287132d40f511925d0e416a6a0bd1fba47697c447b6c05f421b12029b8766

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

  • Uninstall (selected)
kubeadm reset
iptables -F && iptables -t nat -F && iptables -t mangle -F && iptables -X
rm -rf $HOME/.kube/config
systemctl stop docker
systemctl stop kubelet
yum remove kubelet
iptables -tnat --flush # iptables 一定要刷新
  1. Adjust the master server environments
mkdir -p $HOME/.kube
sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
sudo chown $(id -u):$(id -g) $HOME/.kube/config

Initialize the network plug-in

Start worker nodes

  1. System Settings

  2. Configuration k8s, docker yum source

  3. Download docker kubelet kubeadm

  4. By tocken cluster. Note tocken is valid for 24 hours

Complement other plug-ins

Add dashboard

kubectl patch svc -n kube-system kubernetes-dashboard -p '{"spec":{"type":"NodePort"}}'

  • Users create dashboard management

kubectl create serviceaccount dashboard-admin -n kube-system

  • Bind user cluster management users

kubectl create clusterrolebinding dashboard-cluster-admin --clusterrole=cluster-admin --serviceaccount=kube-system:dashboard-admin

  • Get tocken

kubectl describe secret -n kube-system dashboard-admin

Adding storage

View installation

kubectl get pods -n rook-ceph-system
kubectl get pods -n rook-ceph

Build process issues

# coredns readiness 一直unhealthy
coredns dial tcp 10.96.0.1:443: connect: no route to host

# 问题
iptables混乱导致

# 解决办法
systemctl stop kubelet
systemctl stop docker
iptables --flush
iptables -tnat --flush
systemctl start kubelet
systemctl start docker
kubectl delete pod weave -n kube-system

Guess you like

Origin www.cnblogs.com/showmycode/p/12290035.html
Recommended