美文网首页
使用kubeadm快速搭建Kubernetes 1.18(一)

使用kubeadm快速搭建Kubernetes 1.18(一)

作者: devLiao | 来源:发表于2020-08-19 15:05 被阅读0次

参考官网https://kubernetes.io/docs/setup/production-environment/tools/kubeadm/install-kubeadm/

网络环境根据官方设置就没问题

开始操作

yum 阿里的源

vim /etc/yum.repos.d/kubernetes.repo
[kubernetes]
name=Kubernetes
baseurl=http://mirrors.aliyun.com/kubernetes/yum/repos/kubernetes-el7-x86_64
enabled=1
gpgcheck=0
repo_gpgcheck=0
gpgkey=http://mirrors.aliyun.com/kubernetes/yum/doc/yum-key.gpg
        http://mirrors.aliyun.com/kubernetes/yum/doc/rpm-package-key.gpg

安装 kubelet kubeadm kubectl

sudo setenforce 0
sudo sed -i 's/^SELINUX=enforcing$/SELINUX=permissive/' /etc/selinux/config

sudo yum install -y kubelet kubeadm kubectl --disableexcludes=kubernetes

sudo systemctl enable --now kubelet

初始化

vim kubeadm.conf  //新建

apiVersion: kubeadm.k8s.io/v1beta2
kind: InitConfiguration
localAPIEndpoint:
  advertiseAddress: 172.16.81.197
  bindPort: 6443
---
apiServer:
  timeoutForControlPlane: 4m0s
  certSANs:
  - 121.196.50.89
apiVersion: kubeadm.k8s.io/v1beta2
certificatesDir: /etc/kubernetes/pki
clusterName: kubernetes
controllerManager: {}
dns:
  type: CoreDNS
etcd:
  local:
    dataDir: /var/lib/etcd
    serverCertSANs:
    - 121.196.50.89
imageRepository: registry.aliyuncs.com/google_containers
kind: ClusterConfiguration
kubernetesVersion: v1.18.0
networking:
  dnsDomain: cluster.local
  serviceSubnet: 10.1.0.0/16
  podSubnet: 10.244.0.0/16
---
apiVersion: kubeproxy.config.k8s.io/v1alpha1
kind: KubeProxyConfiguration
mode: ipvs

加载

kubeadm init --config kubeadm.conf --ignore-preflight-errors=Swap
image.png

执行上述的命令copy config到.kube下

mkdir -p $HOME/.kube
sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
sudo chown $(id -u):$(id -g) $HOME/.kube/config
kubectl get nodes
image.png

单master安装完成,基本新手入门按照这个流程配合官网的解释是没有问题的,下一篇讲加入集群

相关文章

网友评论

      本文标题:使用kubeadm快速搭建Kubernetes 1.18(一)

      本文链接:https://www.haomeiwen.com/subject/omqrjktx.html