标签:虚拟机 idg 方案 comm Kubernete key 注意 htm 开始
master:192.168.211.150 node1: 192.168.211.151
#master 对应master node 对应node hostnamectl set-hostname master hostnamectl set-hostname node1
#修改/etc/selinux/config文件中设置SELINUX=disabled ,然后重启服务器。 vi /etc/selinux/config setenforce 0 systemctl stop firewalld systemctl disable firewalld swapoff -a vi /etc/fstab (注释最后一行) echo 1 > /proc/sys/net/bridge/bridge-nf-call-iptables echo 1 > /proc/sys/net/ipv4/ip_forward echo 1 > /proc/sys/net/bridge/bridge-nf-call-ip6tables
sudo mkdir -p /etc/docker sudo tee /etc/docker/daemon.json <<-‘EOF‘ { "exec-opts": ["native.cgroupdriver=systemd"], "log-driver": "json-file", "log-opts": { "max-size": "100m" }, "storage-driver": "overlay2", "storage-opts": [ "overlay2.override_kernel_check=true" ], "registry-mirrors": ["https://docker.mirrors.ustc.edu.cn"] } EOF sudo systemctl daemon-reload sudo systemctl restart docker
cat>>/etc/yum.repos.d/kubrenetes.repo<<EOF [kubernetes] name=Kubernetes Repo baseurl=https://mirrors.aliyun.com/kubernetes/yum/repos/kubernetes-el7-x86_64/ gpgcheck=0 gpgkey=https://mirrors.aliyun.com/kubernetes/yum/doc/yum-key.gpg EOF yum install -y kubeadm kubelet kubectl systemctl start docker.service systemctl enable docker.service systemctl enable kubelet.service
#使用kubeadm init 节点(这里最后一个环境变量k8s版本跟你安装的k8s版本要对上) kubeadm init --image-repository registry.aliyuncs.com/google_containers --pod-network-cidr=10.244.0.0/16 --ignore-preflight-errors=cri --kubernetes-version=1.15.2 #配置kubectl 环境变量conf sudo cp /etc/kubernetes/kubelet.conf $HOME/ sudo chown $(id -u):$(id -g) $HOME/kubelet.conf export KUBECONFIG=$HOME/kubelet.conf #初始化网络插件 Flannel (这里需要注意先用docker pull 链接地址配置相关的image到本地然后再执行 kubectl apply 命令) kubectl apply -f https://raw.githubusercontent.com/coreos/flannel/a70459be0084506e4ec919aa1c114638878db11b/Documentation/kube-flannel.yml #Master生成token kubeadm token create --print-join-command 生成示例:kubeadm join 192.168.211.150:6443 --token 6v6fja.dmsi0exuxl4p6fhq --discovery-token-ca-cert-hash sha256:618235581f985da7269f3f0993de8de57af263ab46b1b8b4f614e7b679c2cbb7
#根据token 加入到master 集群 kubeadm join 192.168.211.150:6443 --token 6v6fja.dmsi0exuxl4p6fhq --discovery-token-ca-cert-hash sha256:618235581f985da7269f3f0993de8de57af263ab46b1b8b4f614e7b679c2cbb7
#可能遇到的问题: 1. [preflight] Some fatal errors occurred: /proc/sys/net/bridge/bridge-nf-call-iptables contents are not set to 1 #解决方案: echo 1 > /proc/sys/net/bridge/bridge-nf-call-iptables echo 1 > /proc/sys/net/ipv4/ip_forward echo 1 > /proc/sys/net/bridge/bridge-nf-call-ip6tables #问题2: Container runtime network not ready: NetworkReady=false reason:NetworkPluginNotReady Flannel 网络插件没装好 #问题3: Failed to get system container stats for "/system.slice/docker.service":o get container info for "/system.slice/docker.service": unknown container "/system.slice/docker.service" 修改docker daemon.json
kubectl get pods --all-namespaces 获取所有的命名空间 kubectl get nodes 获取节点 kubectl get sa 获取用户 kubectl get secret kubectl describe secret 获取默认用户token journalctl -f -u kubelet #错误排查查看日志
标签:虚拟机 idg 方案 comm Kubernete key 注意 htm 开始
原文地址:https://www.cnblogs.com/chongyao/p/11409802.html