点击这个 链接关注 Linux公社官方微信,关注后回复数字150442。即可得到网友的分享密码。
如果取消关注Linux公社公众号,即使再次关注,也将无法提供本服务!
链接:https://pan.baidu.com/s/1kXgQSzd 密码:获得见上面的方法,地址失效请在下面留言。
或者到Linux公社1号FTP服务器下载
------------------------------------------分割线------------------------------------------
FTP地址:ftp://ftp1.linuxidc.com
用户名:ftp1.linuxidc.com
密码:
在 2018年LinuxIDC.com/1月/使用 kubeadm 在 CentOS 7 搭建 Kubernetes 集群/
------------------------------------------分割线------------------------------------------
可以下载下来上传到虚拟机中。然后执行如下命令,完成组件的安装。
# yum 安装 rpm 包 $ yum install -y *.rpm # 设置开机启动 $ systemctl enable kubelet安装完毕后,我们还需要配置一下 kubelet,主要修改配置文件 /etc/systemd/system/kubelet.service.d/10-kubeadm.conf 中的 KUBELET_CGROUP_ARGS 配置。
vim /etc/systemd/system/kubelet.service.d/10-kubeadm.conf [Service] Environment="KUBELET_KUBECONFIG_ARGS=--kubeconfig=/etc/kubernetes/kubelet.conf --require-kubeconfig=true" Environment="KUBELET_SYSTEM_PODS_ARGS=--pod-manifest-path=/etc/kubernetes/manifests --allow-privileged=true" Environment="KUBELET_NETWORK_ARGS=--network-plugin=cni --cni-conf-dir=/etc/cni/net.d --cni-bin-dir=/opt/cni/bin" Environment="KUBELET_DNS_ARGS=--cluster-dns=10.96.0.10 --cluster-domain=cluster.local" Environment="KUBELET_AUTHZ_ARGS=--authorization-mode=Webhook --client-ca-file=/etc/kubernetes/pki/ca.crt" Environment="KUBELET_CGROUP_ARGS=--cgroup-driver=systemd" ExecStart=/usr/bin/kubelet $KUBELET_KUBECONFIG_ARGS $KUBELET_SYSTEM_PODS_ARGS $KUBELET_NETWORK_ARGS $KUBELET_DNS_ARGS $KUBELET_AUTHZ_ARGS $KUBELET_CGROUP_ARGS $KUBELET_EXTRA_ARGS这里说明一下,kubelet 默认的 cgroup 的驱动为 cgroupfs,而 Docker 默认的 cgroup 的驱动为 systemd,所有这里可以将 kubectl 的默认驱动改为同 Docker 的一样,否则下边执行 kubeadm init 的时候会报错。当然也可以修改 Docker 的驱动为 cgroupfs。
修改完成之后,需要重新 reload 一下 kubelet 服务。
$ systemctl daemon-reload好了,通过以上安装配置就完成了 Master 节点环境的初始化工作了,Node 节点机器初始化就简单了,因为我使用的是虚拟机,那么只需要将配置好的主机环境复制一份就好了。当然如果你是实体机的话,那就按照上边初始化的操作步骤来一遍就可以了。最后不要忘记修改 Node 节点的 hostname 哈。
# Node 节点 $ echo "node0.localdomain" > /etc/hostname $ echo "10.236.65.135 node0.localdomain" >> /etc/hosts $ sysctl kernel.hostname=node0.localdomain # 不重启情况下使内核修改生效4、初始化启动 Master
配置完主机后,我们可以启动 Master 节点了。在执行初始化 init 时,kubernetes 并没有选择默认的 Pod Network,它支持很多种,这里我们选择 Flannel 作为 Pod Network,按照文档说明,执行 init 时,需要带上参数 --pod-network-cidr,即指定网络区间,同时我们也可以通过 --kubernetes-version 指定选择 kubernetes 的版本号,因为我们镜像以及 rpm 包都是指定 1.6.2 的版本,所以最终执行命令如下:
$ kubeadm init --kubernetes-version=v1.6.2 --pod-network-cidr=10.96.0.0/12 [kubeadm] WARNING: kubeadm is in beta, please do not use it for production clusters. [init] Using Kubernetes version: v1.6.2 [init] Using Authorization mode: RBAC [preflight] Running pre-flight checks [preflight] Starting the kubelet service [certificates] Generated CA certificate and key. [certificates] Generated API server certificate and key. [certificates] API Server serving cert is signed for DNS names [master.localdomain kubernetes kubernetes.default kubernetes.default.svc kubernetes.default.svc.cluster.local] and IPs [10.96.0.1 10.236.65.125] [certificates] Generated API server kubelet client certificate and key. [certificates] Generated service account token signing key and public key. [certificates] Generated front-proxy CA certificate and key. [certificates] Generated front-proxy client certificate and key. [certificates] Valid certificates and keys now exist in "/etc/kubernetes/pki" [kubeconfig] Wrote KubeConfig file to disk: "/etc/kubernetes/kubelet.conf" [kubeconfig] Wrote KubeConfig file to disk: "/etc/kubernetes/controller-manager.conf" [kubeconfig] Wrote KubeConfig file to disk: "/etc/kubernetes/scheduler.conf" [kubeconfig] Wrote KubeConfig file to disk: "/etc/kubernetes/admin.conf" [apiclient] Created API client, waiting for the control plane to become ready [apiclient] All control plane components are healthy after 16.577867 seconds [apiclient] Waiting for at least one node to register [apiclient] First node has registered after 4.004669 seconds [token] Using token: 3aaf19.8e758a48f2050bd1 [apiconfig] Created RBAC rules [addons] Created essential addon: kube-proxy [addons] Created essential addon: kube-dns Your Kubernetes master has initialized successfully! To start using your cluster, you need to run (as a regular user): sudo cp /etc/kubernetes/admin.conf $HOME/ sudo chown $(id -u):$(id -g) $HOME/admin.conf export KUBECONFIG=$HOME/admin.conf You should now deploy a pod network to the cluster. Run "kubectl apply -f [podnetwork].yaml" with one of the options listed at: You can now join any number of machines by running the following on each node as root: kubeadm join --token 3aaf19.8e758a48f2050bd1 10.236.65.125:6443