摘要:虚拟机以及环境准备环境发行版版本阿里云下载地址安装虚拟机设置核数大于设置禁用防火墙禁用设置执行如下命令使修改生效安装选择你想要得版本,我使用了最新版本设置自启动安装启动设
虚拟机以及linux环境准备
发行版 centos
版本 7(x86_64-Minimal-1810)
阿里云os下载地址
VirtualBox 安装虚拟机, cpu 设置核数大于2
设置hosts
# vim /etc/hosts 192.168.1.77 master 192.168.1.223 node1
禁用防火墙
# systemctl stop firewalld # systemctl disable firewalld
禁用SELINUX
# setenforce 0 # vim /etc/selinux/config # 设置 SELINUX=disabled
k8s.conf
vim /etc/sysctl.d/k8s.conf net.bridge.bridge-nf-call-ip6tables = 1 net.bridge.bridge-nf-call-iptables = 1
执行如下命令使修改生效
# modprobe br_netfilter # sysctl -p /etc/sysctl.d/k8s.conf
cd /etc/yum.repos.d && wget https://mirrors.aliyun.com/do...
yum list docker-ce.x86_64 --showduplicates | sort -r
# Loading mirror speeds from cached hostfile # Loaded plugins: branch, fastestmirror, langpacks # docker-ce.x86_64 17.03.1.ce-1.el7.centos docker-ce-stable # docker-ce.x86_64 17.03.1.ce-1.el7.centos @docker-ce-stable # docker-ce.x86_64 17.03.0.ce-1.el7.centos docker-ce-stable # Available Packages
选择你想要得版本,我使用了最新版本
# yum -y install docker-ce
设置自启动
# systemctl enable docker && systemctl start docker
安装 kubeadm、kubelet、kubectl K8S_VERSION=v1.15.3
# cat </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 EOF # yum install -y kubeadm kubelet kubectl # kubelet --version //v1.15.3
kubelet启动设置
# vim /etc/sysconfig/kubelet KUBELET_EXTRA_ARGS="--fail-swap-on=false" # systemctl daemon-reloadmaster节点设置
下载相关镜像
#!/bin/bash # master 节点 shell K8S_VERSION=v1.15.3 ETCD_VERSION=3.3.10 DNS_VERSION=1.3.1 PAUSE_VERSION=3.1 FLANNEL_VERSION=v0.11.0-amd64 DASHBOARD_VERSION=v1.10.1 // 下载镜像 docker pull registry.cn-hangzhou.aliyuncs.com/google_containers/kube-apiserver:$K8S_VERSION docker pull registry.cn-hangzhou.aliyuncs.com/google_containers/kube-controller-manager:$K8S_VERSION docker pull registry.cn-hangzhou.aliyuncs.com/google_containers/kube-scheduler:$K8S_VERSION docker pull registry.cn-hangzhou.aliyuncs.com/google_containers/kube-proxy:$K8S_VERSION docker pull registry.cn-hangzhou.aliyuncs.com/google_containers/pause:$PAUSE_VERSION docker pull registry.cn-hangzhou.aliyuncs.com/google_containers/etcd:$ETCD_VERSION docker pull registry.cn-hangzhou.aliyuncs.com/google_containers/coredns:$DNS_VERSION docker pull jmgao1983/flannel:$FLANNEL_VERSION docker pull siriuszg/kubernetes-dashboard-amd64:$DASHBOARD_VERSION # 修改tag docker tag registry.cn-hangzhou.aliyuncs.com/google_containers/kube-apiserver:$K8S_VERSION k8s.gcr.io/kube-apiserver:$K8S_VERSION docker tag registry.cn-hangzhou.aliyuncs.com/google_containers/kube-controller-manager:$K8S_VERSION k8s.gcr.io/kube-controller-manager:$K8S_VERSION docker tag registry.cn-hangzhou.aliyuncs.com/google_containers/kube-scheduler:$K8S_VERSION k8s.gcr.io/kube-scheduler:$K8S_VERSION docker tag registry.cn-hangzhou.aliyuncs.com/google_containers/kube-proxy:$K8S_VERSION k8s.gcr.io/kube-proxy:$K8S_VERSION docker tag registry.cn-hangzhou.aliyuncs.com/google_containers/pause:$PAUSE_VERSION k8s.gcr.io/pause:$PAUSE_VERSION docker tag registry.cn-hangzhou.aliyuncs.com/google_containers/etcd:$ETCD_VERSION k8s.gcr.io/etcd:$ETCD_VERSION docker tag registry.cn-hangzhou.aliyuncs.com/google_containers/coredns:$DNS_VERSION k8s.gcr.io/coredns:$DNS_VERSION docker tag jmgao1983/flannel:$FLANNEL_VERSION quay.io/coreos/flannel:$FLANNEL_VERSION docker tag siriuszg/kubernetes-dashboard-amd64:$DASHBOARD_VERSION k8s.gcr.io/kubernetes-dashboard-amd64:$DASHBOARD_VERSION #删除冗余的images docker rmi registry.cn-hangzhou.aliyuncs.com/google_containers/kube-apiserver:$K8S_VERSION docker rmi registry.cn-hangzhou.aliyuncs.com/google_containers/kube-controller-manager:$K8S_VERSION docker rmi registry.cn-hangzhou.aliyuncs.com/google_containers/kube-scheduler:$K8S_VERSION docker rmi registry.cn-hangzhou.aliyuncs.com/google_containers/kube-proxy:$K8S_VERSION docker rmi registry.cn-hangzhou.aliyuncs.com/google_containers/pause:$PAUSE_VERSION docker rmi registry.cn-hangzhou.aliyuncs.com/google_containers/etcd:$ETCD_VERSION docker rmi registry.cn-hangzhou.aliyuncs.com/google_containers/coredns:$DNS_VERSION docker rmi jmgao1983/flannel:$FLANNEL_VERSION docker rmi siriuszg/kubernetes-dashboard-amd64:$DASHBOARD_VERSION
集群安装初始化
# kubeadm init --kubernetes-version=v1.15.3 --pod-network-cidr=10.244.0.0/16 --ignore-preflight-errors=Swap # 出现如下信息安装成功 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 192.168.1.16:6443 --token 981it6.k4kqs2i73e1bfd1p --discovery-token-ca-cert-hash sha256:5cc5c1c2ace7b720a178840c951b2a05c679d26b8d6a1cfc81aa7e006e6a6ef9
查看集群健康状况
# kubectl get cs
集群安装过程中遇到问题,重置操作
# kubeadm reset
安装网络插件
# kubectl apply -f https://raw.githubusercontent.com/coreos/flannel/master/Documentation/kube-flannel.yml
查看集群中的组件运行状态
# kubectl get pods --all-namespacesnode节点设置
下载镜像
#!/bin/bash # node 节点 shell K8S_VERSION=v1.15.3 ETCD_VERSION=3.3.10 DNS_VERSION=1.3.1 PAUSE_VERSION=3.1 FLANNEL_VERSION=v0.11.0-amd64 DASHBOARD_VERSION=v1.10.1 ## node 安装插件 docker pull registry.cn-hangzhou.aliyuncs.com/google_containers/kube-proxy:$K8S_VERSION docker pull registry.cn-hangzhou.aliyuncs.com/google_containers/pause:$PAUSE_VERSION docker pull jmgao1983/flannel:v0.11.0-amd64 docker pull siriuszg/kubernetes-dashboard-amd64:$DASHBOARD_VERSION docker tag registry.cn-hangzhou.aliyuncs.com/google_containers/kube-proxy:$K8S_VERSION k8s.gcr.io/kube-proxy:$K8S_VERSION docker tag registry.cn-hangzhou.aliyuncs.com/google_containers/pause:$PAUSE_VERSION k8s.gcr.io/pause:$PAUSE_VERSION docker tag jmgao1983/flannel:$FLANNEL_VERSION quay.io/coreos/flannel:$FLANNEL_VERSION docker tag siriuszg/kubernetes-dashboard-amd64:$DASHBOARD_VERSION k8s.gcr.io/kubernetes-dashboard-amd64:$DASHBOARD_VERSION docker rmi jmgao1983/flannel:$FLANNEL_VERSION docker rmi registry.cn-hangzhou.aliyuncs.com/google_containers/pause:$PAUSE_VERSION docker rmi registry.cn-hangzhou.aliyuncs.com/google_containers/kube-proxy:$K8S_VERSION docker rmi siriuszg/kubernetes-dashboard-amd64:$DASHBOARD_VERSION
加入节点
# kubeadm join 192.168.1.77:6443 --token 5oi47o.stqe7c5w1qo7wcr0 --discovery-token-ca-cert-hash sha256:2387b0db19fa83e57ac094bf27a870a0381082c47c0f08bf9ef6277e24593fcd --ignore-preflight-errors=Swap #出现下面就ok了, master节点, kubectl get nodes This node has joined the cluster: * Certificate signing request was sent to master and a response was received. * The Kubelet was informed of the new secure connection details. Run "kubectl get nodes" on the master to see this node join the cluster.安装 dashboard组件
集群配置,生成浏览器证书
# 生成client-certificate-data grep "client-certificate-data" ~/.kube/config | head -n 1 | awk "{print $2}" | base64 -d >> kubecfg.crt # 生成client-key-data grep "client-key-data" ~/.kube/config | head -n 1 | awk "{print $2}" | base64 -d >> kubecfg.key # 生成p12 openssl pkcs12 -export -clcerts -inkey kubecfg.key -in kubecfg.crt -out kubecfg.p12 -name "kubernetes-client" # 导入证书后浏览器重启
创建admin-user账号,并放在kube-system名称空间下
# vim admin-user.yaml apiVersion: v1 kind: ServiceAccount metadata: name: admin-user namespace: kube-system #kubectl create -f admin-user.yaml
绑定角色
# vim admin-user-role-binding.yaml apiVersion: rbac.authorization.k8s.io/v1beta1 kind: ClusterRoleBinding metadata: name: admin-user roleRef: apiGroup: rbac.authorization.k8s.io kind: ClusterRole name: cluster-admin subjects: - kind: ServiceAccount name: admin-user namespace: kube-system # kubectl create -f admin-user-role-binding.yaml
获取Token
# kubectl -n kube-system describe secret $(kubectl -n kube-system get secret | grep admin-user | awk "{print $1}")
登录dashboard
https://192.168.255.130:6443/api/v1/namespaces/kube-system/services/https:kubernetes-dashboard:/proxy/
文章版权归作者所有,未经允许请勿转载,若此文章存在违规行为,您可以联系管理员删除。
转载请注明本文地址:https://www.ucloud.cn/yun/110637.html
摘要:代表的解决方案为。虽然官网列出的部署方式很多,但也不用被这么多种部署方式搞糊涂了。虽然只是一条命令,但其实执行了很多步骤命令执行后输出如下可以看到,主要做了这些事创建了名为的虚拟机,并在虚拟机中安装了容器运行时。 综述 Kubernetes集群的组件众多,要部署一套符合生产环境的集群不是一件容易的事。好在随着社区的快速发展,特别是在它成为事实上的容器编排标准以后,基本所有的主流云平台都...
摘要:代表的解决方案为。虽然官网列出的部署方式很多,但也不用被这么多种部署方式搞糊涂了。虽然只是一条命令,但其实执行了很多步骤命令执行后输出如下可以看到,主要做了这些事创建了名为的虚拟机,并在虚拟机中安装了容器运行时。 综述 Kubernetes集群的组件众多,要部署一套符合生产环境的集群不是一件容易的事。好在随着社区的快速发展,特别是在它成为事实上的容器编排标准以后,基本所有的主流云平台都...
摘要:是系统提供的容器化技术,简称,它结合和技术为用户提供了更易用的接口来实现容器化。公司结合和以下列出的技术实现了容器引擎,相比于,具备更加全面的资源控制能力,是一种应用级别的容器引擎。 showImg(https://segmentfault.com/img/bVbtPbG?w=749&h=192); 题外话 最近对Docker和Kubernetes进行了一番学习,前两天做了一次技术...
摘要:是系统提供的容器化技术,简称,它结合和技术为用户提供了更易用的接口来实现容器化。公司结合和以下列出的技术实现了容器引擎,相比于,具备更加全面的资源控制能力,是一种应用级别的容器引擎。 showImg(https://segmentfault.com/img/bVbtPbG?w=749&h=192); 题外话 最近对Docker和Kubernetes进行了一番学习,前两天做了一次技术...
摘要:有些人将其称为容器编排平台,而并非唯一的此类平台。但是在中,您可以快速扩展出多个实例你看看使用扩展你的网站是何其便捷。当你指向群集的地址和节点的端口号时,你就已经可见浏览器中正在运行的程序了。 showImg(https://segmentfault.com/img/remote/1460000017838786?w=1120&h=757); Laravel 是开发 PHP 应用程序的...
阅读 559·2021-11-19 09:40
阅读 1453·2019-08-30 12:51
阅读 542·2019-08-29 17:30
阅读 3504·2019-08-29 15:17
阅读 732·2019-08-28 18:10
阅读 2826·2019-08-27 14:20
阅读 1084·2019-08-26 17:08
阅读 2011·2019-08-26 12:16