k8s集群搭建

tech2024-03-19  67

本文为搭建k8s集群笔记,详细搭建教程等有时间整理

使用阿里云镜像 cat < /etc/yum.repos.d/kubernetes.repo [kubernetes] name=Kubernetes baseurl=https://mirrors.aliyun.com/kubernetes/yum/repos/kubernetes-el7-x86_64 enabled=1 gpgcheck=1 repo_gpgcheck=1 gpgkey=https://mirrors.aliyun.com/kubernetes/yum/doc/yum-key.gpg https://mirrors.aliyun.com/kubernetes/yum/doc/rpm-package-key.gpg EOF

拉取需要镜像(或者init时通过–image-repository registry.aliyuncs.com/google_containers拉取) for i in kubeadm config images list --kubernetes-version v1.17.3; do imageName=KaTeX parse error: Expected '}', got '#' at position 3: {i#̲k8s.gcr.io/} …imageName docker tag registry.aliyuncs.com/google_containers/ i m a g e N a m e k 8 s . g c r . i o / imageName k8s.gcr.io/ imageNamek8s.gcr.io/imageName docker rmi registry.aliyuncs.com/google_containers/$imageName done;

master节点初始化 kubeadm init --kubernetes-version=1.17.3 –apiserver-advertise-address=192.168.42.102 –image-repository registry.aliyuncs.com/google_containers –service-cidr=10.10.0.0/16 --pod-network-cidr=10.122.0.0/16 –node-name=master.com(不用)

子节点加入master kubeadm join 192.168.42.102:6443 --token 90lios.4g0xjh0rpr25jpk2 –discovery-token-ca-cert-hash sha256:ee6bbe652fc6b8d0150f604d0b64a8f400fe88dd1d6e8171f7852a6a1bb960b3

查看日志/var/log/message

安装kubelet,kubeadm,kubectl yum install -y kubelet-1.17.3-0 kubeadm-1.17.3-0 kubectl-1.17.3-0 --disableexcludes=kubernetes systemctl enable kubelet

查看k8s版本 kubectl version

排错 journalctl -f # 当前输出日志 journalctl -f -u kubelet # 只看当前的kubelet进程日志

master查看节点 kubectl get pods --all-namespaces kubectl get nodes

安装calico网络 kubectl apply -f https://docs.projectcalico.org/manifests/calico.yaml

待解决 子节点安装calico网络报错 kubectl apply -f https://docs.projectcalico.org/manifests/calico.yaml error: Missing or incomplete configuration info. Please point to an existing, complete config file:

Via the command-line flag --kubeconfigVia the KUBECONFIG environment variableIn your home directory as ~/.kube/config

To view or setup config directly use the ‘config’ command. 解决方法 使用kubectl version --client=true命令

修改/etc/sysconfig/network-scripts/ifcfg-ens33里IPADDR, 使用service network restart重启

重置 kubeadm reset

kubectl get pods -n kube-system -owide | grep test-slave-115

查看master是否存在污点 kubectl describe node master | grep Taint

最新回复(0)