我们专注攀枝花网站设计 攀枝花网站制作 攀枝花网站建设
成都网站建设公司服务热线:400-028-6601

网站建设知识

十年网站开发经验 + 多家企业客户 + 靠谱的建站团队

量身定制 + 运营维护+专业推广+无忧售后,网站问题一站解决

centos7下的k8s+dashboard集群部署---(2)k8s部署

一.k8s部署

1.各节点安装kubectl,kubelet,kubeadm,需要通过yum安装,所以还是先配置yum源。

创新互联专注于企业全网整合营销推广、网站重做改版、涟源网站定制设计、自适应品牌网站建设、HTML5购物商城网站建设、集团公司官网建设、成都外贸网站建设公司、高端网站制作、响应式网页设计等建站业务,价格优惠性价比高,为涟源等各大城市提供网站开发制作服务。

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=0
repo_gpgcheck=0
gpgkey=https://mirrors.aliyun.com/kubernetes/yum/doc/yum-key.gpg   https://mirrors.aliyun.com/kubernetes/yum/doc/rpm-package-key.gpg

2.安装k8s要注意版本匹配,不然会在初始化的时候提示你kubeadm版本和kubernets版本不对,或高或低,所以安装完成后查看下版本,最好yum安装时带版本号安装
kubeadm version
kubectl version
输出如下:

[root@localhost kubernetes]# kubeadm version
kubeadm version: &version.Info{Major:"1", Minor:"13", GitVersion:"v1.13.1", GitCommit:"eec55b9ba98609a46fee712359c7b5b365bdd920", GitTreeState:"clean", BuildDate:"2018-12-13T10:36:44Z", GoVersion:"go1.11.2", Compiler:"gc", Platform:"linux/amd64"}

开机启动,初始化要保证开启
systemctl enable kubelet.service
开始安装,镜像下载网上有很多不多说,现在完成后改名为如下:

k8s.gcr.io/kube-proxy                v1.13.1             fdb321fd30a0        7 months ago        80.2MB
k8s.gcr.io/kube-scheduler            v1.13.1             ab81d7360408        7 months ago        79.6MB
k8s.gcr.io/kube-apiserver            v1.13.1             40a63db91ef8        7 months ago        181MB
k8s.gcr.io/kube-controller-manager   v1.13.1             26e6f1db2a52        7 months ago        146MB
k8s.gcr.io/coreDNS                   1.2.6               f59dcacceff4        9 months ago        40MB
k8s.gcr.io/etcd                      3.2.24              3cab8e1b9802        10 months ago       220MB
k8s.gcr.io/pause                     3.1                 da86e6ba6ca1        19 months ago       742kB

然后master节点执行初始化
kubeadm init --kubernetes-version=v1.15.0 --pod-network-cidr=10.244.0.0/16
注意版本要匹配自己的版本,后面pod网段要匹配fannel插件安装时候的yaml.
初始化完成会显示以下内容:这里的东西很重要,颜色表明的要按自己的去复制


Your Kubernetes control-plane 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/

Then you can join any number of worker nodes by running the following on each as root:

kubeadm join 172.16.32.10:6443 --token x8gdiq.sbcj8g4fmoocd5tl \

--discovery-token-ca-cert-hash sha256:0b48e70fa8a268f8b88cd69b02cf87d8a2bf2efe519bb88dfa558de20d4a9993

安装网络插件fannel
kubectl apply -f https://raw.githubusercontent.com/coreos/flannel/a70459be0084506e4ec919aa1c114638878db11b/Documentation/kube-flannel.yml
*也是要注意版本问题,kube-fannel.yaml里面是有镜像版本配置的,同时注意修改里面的网段和初始化一致。全部running状态。

[root@localhost kubernetes]# kubectl get pods -n kube-system
NAME                                            READY   STATUS    RESTARTS   AGE
coredns-86c58d9df4-jt4pd                        1/1     Running   0          25h
coredns-86c58d9df4-m6bzt                        1/1     Running   0          25h
etcd-localhost.localdomain                      1/1     Running   0          25h
kube-apiserver-localhost.localdomain            1/1     Running   0          25h
kube-controller-manager-localhost.localdomain   1/1     Running   0          25h
kube-flannel-ds-amd64-qfqr4                     1/1     Running   20         24h
kube-flannel-ds-amd64-xjk6v                     1/1     Running   0          25h
kube-proxy-p226l                                1/1     Running   0          24h
kube-proxy-qq4j4                                1/1     Running   0          25h
kube-scheduler-localhost.localdomain            1/1     Running   0          25h
kubernetes-dashboard-7d77666777-2l68j           1/1     Running   0          5h38m

从节点加入:
从节点需要安装kube-proxy pause
使用master初始化时候结果的kubeadm join来加入主节点
kubeadm join 172.16.32.10:6443 --token x8gdiq.sbcj8g4fmoocd5tl \

--discovery-token-ca-cert-hash sha256:0b48e70fa8a268f8b88cd69b02cf87d8a2bf2efe519bb88dfa558de20d4a9993

从节点加完后记得从主节点拷贝admin.yaml


分享标题:centos7下的k8s+dashboard集群部署---(2)k8s部署
URL链接:http://shouzuofang.com/article/jcddpp.html

其他资讯