189 8069 5689

在AWS云上搭建K8S集群-创新互联

  1. 新建EC2
    t2.medium
    操作系统是 CentOS 7.5.1804 (x86_64) - with AWS_CLI_SSM and HVM - ami-0229f1a332c972082
    安全组全开,能上网

    专注于为中小企业提供成都网站建设、成都做网站服务,电脑端+手机端+微信端的三站合一,更高效的管理,为中小企业惠民免费做网站提供优质的服务。我们立足成都,凝聚了一批互联网行业人才,有力地推动了1000+企业的稳健成长,帮助中小企业通过网站建设实现规模扩充和转变。
  2. 系统初始化
    yum install -y vim
    yum install -y git
    yum install -y wget
    setenforce 0
    sed -i 's/enforcing/disabled/' /etc/selinux/config

  3. 安装docker
    yum install -y docker
    systemctl enable docker.service
    systemctl start docker.service

  4. 配置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=1
    gpgkey=https://mirrors.aliyun.com/kubernetes/yum/doc/yum-key.gpg https://mirrors.aliyun.com/kubernetes/yum/doc/rpm-package-key.gpg
    EOF

  5. 安装kubeadm、kubelet、kubectl
    yum install -y kubelet-1.13.3
    yum install -y kubeadm-1.13.3
    yum install -y kubectl-1.13.3
    systemctl enable kubelet.service
    systemctl start kubelet.service

  6. 初始化master(此步骤只需要在master上执行)
    kubeadm init \
    --apiserver-advertise-address=10.44.41.236 \
    --image-repository registry.aliyuncs.com/google_containers \
    --kubernetes-version v1.13.3 \
    --service-cidr=10.96.0.0/16 \
    --pod-network-cidr=10.244.0.0/16

说明:
--apiserver-advertise-address=10.44.41.236 是master的ip地址,
--service-cidr=10.96.0.0/16 是service的地址段,可自定义
--pod-network-cidr=10.244.0.0/16 是pod的地址段,可自定义**

初始化完成之后,会有如下提示,按照提示操作即可
Your Kubernetes master has initialized successfully!

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

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

You should now deploy a pod network to the cluster.
Run "kubectl apply -f [podnetwork].yaml" with one of the options listed at:
https://kubernetes.io/docs/concepts/cluster-administration/addons/

You can now join any number of machines by running the following on each node
as root:

kubeadm join 10.44.41.236:6443 --token 7dtiw9.7ytxxxxxx89x7tr --discovery-token-ca-cert-hash sha256:c2a0b41860xxxxxxff8dcb5d3b3a460

task 2 创建pod网络,先下载yml文件,再下载docker镜像,然后把docker镜像tag成与yml文件中一致,最后apply
wget https://raw.githubusercontent.com/coreos/flannel/master/Documentation/kube-flannel.yml
sudo docker pull akinlau/flannel-v0.11.0:v0.11.0
sudo docker images
sudo docker tag ff281650a721 quay.io/coreos/flannel:v0.11.0-amd64
kubectl apply -f kube-flannel.yml

task 3 执行完命令之后在master上查看节点状态,node节点需要很久才能达到ready状态,因为下载flannel镜像很慢,可以将master上的镜像docker save保存,然后拷贝到node上执行docker load导入
[centos@ip-10-44-41-236 ~]$ kubectl get nodes
NAME STATUS ROLES AGE VERSION
ip-10-44-41-236.cn-north-1.compute.internal Ready master 90m v1.13.3
ip-10-44-41-244.cn-north-1.compute.internal Ready 27m v1.13.3
ip-10-44-41-43.cn-north-1.compute.internal Ready 27m v1.13.3

另外有需要云服务器可以了解下创新互联cdcxhl.cn,海内外云服务器15元起步,三天无理由+7*72小时售后在线,公司持有idc许可证,提供“云服务器、裸金属服务器、高防服务器、香港服务器、美国服务器、虚拟主机、免备案服务器”等云主机租用服务以及企业上云的综合解决方案,具有“安全稳定、简单易用、服务可用性高、性价比高”等特点与优势,专为企业上云打造定制,能够满足用户丰富、多元化的应用场景需求。


分享名称:在AWS云上搭建K8S集群-创新互联
网页链接:http://cdxtjz.com/article/sheic.html

其他资讯