锅炉信息网 > 锅炉知识 > 锅炉百科

K8S 环境安装

发布时间:

安装0 准备三台安装好docker的机器并配置hosts 如果需要手动指定固定ip  可以nmtui 打开界面设置ip (镜像:CentOS-8.4.2105-x86_64)1

安装

0 准备三台安装好docker的机器并配置hosts 如果需要手动指定固定ip 可以nmtui 打开界面设置ip (镜像:CentOS-8.4.2105-x86_64)

192.168.9.132 k8s-mastern192.168.9.133 k8s-node1n192.168.9.134 k8s-node2

1 关闭防火墙

systemctl stop firewalld nsystemctl disable firewalld

  1. 关闭Swap

swapoff -a # 临时关闭 nvim /etc/fstab # 永久关闭n#注释掉swap这行n# /dev/mapper/centos‐swap swap swap defaults 0 0n# 或者nsed -i 's/.*swap.*/#&/' /etc/fstab

  1. 关闭selinux

sed ‐i 's/enforcing/disabled/' /etc/selinux/config # 永久关闭nsetenforce 0 # 临时关闭nnsed -i "s/^SELINUX=enforcing/SELINUX=disabled/g" /etc/sysconfig/selinuxnsed -i "s/^SELINUX=enforcing/SELINUX=disabled/g" /etc/selinux/confignsed -i "s/^SELINUX=permissive/SELINUX=disabled/g" /etc/sysconfig/selinuxnsed -i "s/^SELINUX=permissive/SELINUX=disabled/g" /etc/selinux/config

  1. 吧桥接的ipv4流量转到iptables

cat > /etc/sysctl.d/k8s.conf << EOFn> net.bridge.bridge‐nf‐call‐ip6tables = 1n> net.bridge.bridge‐nf‐call‐iptables = 1n> EOFnn#执行使命令生效:nmodprobe br_netfilternsysctl -p /etc/sysctl.d/k8s.conf

  1. 添加k8s配置源

cat /etc/yum.repos.d/kubernetes.repo n[kubernetes]nname=Kubernetesnbaseurl=https://mirrors.aliyun.com/kubernetes/yum/repos/kubernetes-el7-x86_64/nenabled=1ngpgcheck=0nrepo_gpgcheck=0ngpgkey=https://mirrors.aliyun.com/kubernetes/yum/doc/yum-key.gpg <https://mirrors.aliyun.com/kubernetes/yum/doc/rpm-package-key.gpg>

  1. 查看可以安装的k8s版本

yum list kubelet --showduplicates | sort -r

  1. 安装kubelet,kubeadm,kubectl

yum install -y kubelet-1.20.8-0 kubeadm-1.20.8-0 kubectl-1.20.8-0

  1. 设置开机启动

systemctl enable kubeletnsystemctl start kubelet

9 master节点初始化

kubeadm init --image-repository=registry.aliyuncs.com/google_containers --apiserver-advertise-address=192.168.9.135 --kubernetes-version=v1.20.8 --service-cidr=10.96.0.0/12 --pod-network-cidr=10.244.0.0/16n# 192.168.9.135 设置成当前主机IP

10 .安装网络插件

kubectl apply ‐f <https://docs.projectcalico.org/manifests/calico.yaml>n# 如果上面这个calico网络插件安装不成功可以试下下面这个 n# kubectl apply ‐f <https://raw.githubusercontent.com/coreos/flannel/mast> er/Documentation/kubeflannel.yml

11.检测安装情况

[root@localhost kubernetes]# kubectl get pods -AnNAMESPACE NAME READY STATUS RESTARTS AGEnkube-system calico-kube-controllers-85c867d48-5c6pr 0/1 Pending 0 35snkube-system calico-node-6tjlk 0/1 Init:2/3 0 36snkube-system coredns-7f89b7bc75-rbxwv 0/1 Pending 0 5m58snkube-system coredns-7f89b7bc75-v2nvs 0/1 Pending 0 5m58snkube-system etcd-k8s-node4 1/1 Running 0 6m4snkube-system kube-apiserver-k8s-node4 1/1 Running 0 6m4snkube-system kube-controller-manager-k8s-node4 1/1 Running 0 6m4snkube-system kube-proxy-h8bcn 1/1 Running 0 5m58snkube-system kube-scheduler-k8s-node4 1/1 Running 0 6m4s

12 .如果执行显示Unhealthy

修改/etc/kubernetes/manifests 下,

vim kube-controller-manager.yaml vim kube-scheduler.yaml

将port=0注掉

执行结果

快捷键支持:

https://kubernetes.io/zh/docs/tasks/tools/included/optional-kubectl-configs-bash-linux/

yum install bash-completionnsource /usr/share/bash-completion/bash_completionnkubectl completion bash >/etc/bash_completion.d/kubectlnecho 'alias k=kubectl' >>~/.bashrcnecho 'complete -F __start_kubectl k' >>~/.bashrcnsource ~/.bashrcnn则可以执行 k get cs n[root@localhost manifests]# k get csnWarning: v1 ComponentStatus is deprecated in v1.19+nNAME STATUS MESSAGE ERRORncontroller-manager Healthy ok nscheduler Healthy ok netcd-0 Healthy {"health":"true"}

上一篇:SDS检测报告

下一篇:k8s集群搭建

精选推荐

  • 711关东煮供应商
    711关东煮供应商

    今天给大家介绍三位,奶粉,全家、罗森这些便利店里关东煮的供应商。店里卖三四块钱一串的关东煮,在网上买不到,一块钱就搞定。首先关东

  • 健康日历|高压锅容易爆炸的4个原因
    健康日历|高压锅容易爆炸的4个原因

    来源:医药养生保健报设计:李雅琴医学审核:姜峰出品人:胡丽丽

  • 高炉
    高炉

    今天这活却是个白事,等到了时辰,那家人便准备火化,本来准备送普炉,我却心中一动,便对那家人说道:“这老人走也不要省,还是送高炉吧。”

  • 高压锅和电压力锅的区别,推荐几款点压力锅
    高压锅和电压力锅的区别,推荐几款点压

    记得之前有一次去朋友家玩,他正在用高压锅煮小米粥,是的,高压锅压小米粥,大概煮了半小时,高压锅突然爆炸了,现场惨不忍睹啊,幸好厨房里没

0