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

发布时间:2020-08-02 10:27:42 作者:天王星人
来源:网络 阅读:467
一.k8s部署

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

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

推荐阅读:
  1. Redis 集群部署
  2. nacos集群部署-k8s环境

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

k8s docker 7下

上一篇:servlet基本问题

下一篇:ntp服务器搭建

相关阅读

您好,登录后才能下订单哦!

密码登录
登录注册
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》