前言:
话不多说,跟着操作走,No problem!
一、配置环境
系统:Linux 7.2
环境:VMware 10
开启 虚拟化
关闭 Firewall
关闭 Selinux
二、安装步骤
———以下操作均在Root下执行,所有源都用阿里云
1.安装Dokcer
(1)配置yum源
vim /etc/yum.repos.d/docker.repo
[docker-repo]
name=Docker Repository
baseurl=https://yum.dockerproject.org/repo/main/centos/7/
enabled=1
gpgcheck=1
gpgkey=https://yum.dockerproject.org/gpg
(2)下载Docker
yum -y install docker-engine
(3)启动并设置开机启动
systemctl start docker.service
systemctl enable docker.service
2.下载Minikube --单机版的K8s,用来在本机运行K8s集群
curl -Lo minikube http://kubernetes.oss-cn-hangzhou.aliyuncs.com/minikube/releases/v1.2.0/minikube-linux-amd64 && chmod +x minikube && sudo mv minikube /usr/local/bin/
3.下载VirtualBox --类似Vmware的工具,可以选择不安装
(1)配置yum源
vim /etc/yum.repos.d/virtualbox.repo
[virtualbox]
name=Oracle Linux / RHEL / CentOS-$releasever / $basearch - VirtualBox
baseurl=http://download.virtualbox.org/virtualbox/rpm/el/$releasever/$basearch
enabled=1
gpgcheck=1
repo_gpgcheck=1
gpgkey=https://www.virtualbox.org/download/oracle_vbox.asc
(2)清除yum缓存
yum clean all
yum makecache
(3)下载VirtualBox
yum install VirtualBox-5.2
4.下载Kubectl --单机版的K8s,用来在本机运行K8s集群
curl -LO http://kubernetes.oss-cn-hangzhou.aliyuncs.com/kubernetes-release/release/`curl -s http://kubernetes.oss-cn-hangzhou.aliyuncs.com/kubernetes-release/release/stable.txt`/bin/linux/amd64/kubectl && chmod +x kubectl && sudo mv kubectl /usr/local/bin/kubectl
5.启动minikube
minikube start
**如果启动很卡的话,就不用Box创建:**
(minikube start --vm-driver=none --memory 4096 --registry-mirror=registry.aliyuncs.com/google_containers)
6.使用dashboard
minikube dashboard
窗口使用Minikube
(1) 使用minikube ssh进入Box
(2)查看容器的状态
(3)创建一个Pod “myweb”
kubectl run myweb --image=daocloud.io/nginx --port=80
(4)端口映射
kubectl expose deployment myweb --port=80 --type=NodePort
(5)查看deployment状态
(6)查看映射的端口
kubectl get service
(7)在真机访问Pod