https://blog.csdn.net/fishinhouse/article/details/80589683

GitHub minikube

Kubernetes目前最高支持Docker版本17.03

Minikube是什么?

Minikube是一种方便在本地运行Kubernetes的工具. 
Minikube 是可以在VM中运行单节点的Kubernetes集群. 
Minikube是为了开发或测试在本地启动一个节点的kubernetes集群.

特点

不能启动生产集群,没有高可用性的单节点机器. 
可以工作在Windows,Linux,MacOS下.

先决条件

需要安装VirtualBox和Minikube

安装Minikube

  • 安装minikube
  1. $curl -Lo minikube https://storage.googleapis.com/minikube/releases/latest/minikube-linux-amd64 && chmod +x minikube && sudo mv minikube /usr/local/bin/

  2. % Total % Received % Xferd Average Speed Time Time Time Current

  3. Dload Upload Total Spent Left Speed

  4. 100 82.3M 100 82.3M 0 0 4295k 0 0:00:19 0:00:19 --:--:-- 4896k

  • 安装kubectl
  1. $curl -Lo kubectl https://storage.googleapis.com/kubernetes-release/release/$(curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt)/bin/linux/amd64/kubectl && chmod +x kubectl

  2. % Total % Received % Xferd Average Speed Time Time Time Current

  3. Dload Upload Total Spent Left Speed

  4. 100 68.9M 100 68.9M 0 0 4756k 0 0:00:14 0:00:14 --:--:-- 5385k

  5. $ sudo mv kubectl /usr/local/bin/

  • 配置信息
  1. $ export MINIKUBE_WANTUPDATENOTIFICATION=false

  2. $ export MINIKUBE_WANTREPORTERRORPROMPT=false

  3. $ export MINIKUBE_HOME=$HOME

  4. $ export CHANGE_MINIKUBE_NONE_USER=true

  5. $ mkdir $HOME/.kube || true

  6. $ touch $HOME/.kube/config

  7. $ export KUBECONFIG=$HOME/.kube/config

启动Minikube

  1. $ minikube start --vm-driver=virtualbox

  2. Starting local Kubernetes v1.7.0 cluster...

  3. Starting VM...

  4. Downloading Minikube ISO

  5. 97.80 MB / 97.80 MB [==============================================] 100.00% 0s

  6. Getting VM IP address...

  7. Moving files into cluster...

  8. Setting up certs...

  9. Starting cluster components...

  10. Connecting to cluster...

  11. Setting up kubeconfig...

  12. Kubectl is now configured to use the cluster.

  1. $ kubectl get nodes

  2. NAME STATUS AGE VERSION

  3. minikube Ready 5s v1.7.0

  1. $ kubectl get pods --all-namespaces

  2. NAMESPACE NAME READY STATUS RESTARTS AGE

  3. kube-system kube-addon-manager-minikube 1/1 Running 0 2h

  4. kube-system kube-dns-910330662-pkvj6 3/3 Running 0 2h

  5. kube-system kubernetes-dashboard-mg5jt 1/1 Running 0 2h

如果minikube启动提示没有找到VboxManage,可以参考Github上的方法:

此参数告诉Kubernetes组件运行在主机上,而非VM虚拟机上。

如果运行在VM上,Docker只需要VM的驱动程序,而非管理程序。使用主机模式,请确保Docker的网络连接模拟为桥接(bridge network)。

$ minikube start --vm-driver=none

卸载Docker高版本

1、查看已安装的Docker版本

$ yum list installed | grep docker

2、卸载已安装的Docker版本

yum -y remove docker-ce.x86_64

3、查看Docker版本

 yum list docker-ce.x86_64  --showduplicates |sort -r
  1. docker-ce.x86_64 18.05.0.ce-3.el7.centos docker-ce-edge

  2. docker-ce.x86_64 18.04.0.ce-3.el7.centos docker-ce-edge

  3. docker-ce.x86_64 18.03.1.ce-1.el7.centos docker-ce-stable

  4. docker-ce.x86_64 18.03.1.ce-1.el7.centos docker-ce-edge

  5. docker-ce.x86_64 18.03.0.ce-1.el7.centos docker-ce-stable

  6. docker-ce.x86_64 18.03.0.ce-1.el7.centos docker-ce-edge

  7. docker-ce.x86_64 18.02.0.ce-1.el7.centos docker-ce-edge

  8. docker-ce.x86_64 18.01.0.ce-1.el7.centos docker-ce-edge

  9. docker-ce.x86_64 17.12.1.ce-1.el7.centos docker-ce-stable

  10. docker-ce.x86_64 17.12.1.ce-1.el7.centos docker-ce-edge

  11. docker-ce.x86_64 17.12.0.ce-1.el7.centos docker-ce-stable

  12. docker-ce.x86_64 17.12.0.ce-1.el7.centos docker-ce-edge

  13. docker-ce.x86_64 17.11.0.ce-1.el7.centos docker-ce-edge

  14. docker-ce.x86_64 17.10.0.ce-1.el7.centos docker-ce-edge

  15. docker-ce.x86_64 17.09.1.ce-1.el7.centos docker-ce-stable

  16. docker-ce.x86_64 17.09.1.ce-1.el7.centos docker-ce-edge

  17. docker-ce.x86_64 17.09.0.ce-1.el7.centos docker-ce-stable

  18. docker-ce.x86_64 17.09.0.ce-1.el7.centos docker-ce-edge

  19. docker-ce.x86_64 17.07.0.ce-1.el7.centos docker-ce-edge

  20. docker-ce.x86_64 17.06.2.ce-1.el7.centos docker-ce-stable

  21. docker-ce.x86_64 17.06.2.ce-1.el7.centos docker-ce-edge

  22. docker-ce.x86_64 17.06.1.ce-1.el7.centos docker-ce-stable

  23. docker-ce.x86_64 17.06.1.ce-1.el7.centos docker-ce-edge

  24. docker-ce.x86_64 17.06.0.ce-1.el7.centos docker-ce-stable

  25. docker-ce.x86_64 17.06.0.ce-1.el7.centos docker-ce-edge

  26. docker-ce.x86_64 17.05.0.ce-1.el7.centos docker-ce-edge

  27. docker-ce.x86_64 17.04.0.ce-1.el7.centos docker-ce-edge

  28. docker-ce.x86_64 17.03.2.ce-1.el7.centos docker-ce-stable

  29. docker-ce.x86_64 17.03.1.ce-1.el7.centos docker-ce-stable

  30. docker-ce.x86_64 17.03.0.ce-1.el7.centos docker-ce-stable

4、安装Docker 17.03.0.ce

yum install -y  docker-ce-selinux-17.03.0.ce-1.el7.centos.noarch

VirtualBox

参考资料

https://www.jianshu.com/p/b30cec4f257d

k8s之minikube搭建

本文主要介绍在mac中安装minikube,使用minikube启动k8s

安装 Minikube

  1. 首先保证你的电脑BIOS开启了VT-x或者AMD-v虚拟化支持
  2. 安装Virtual Box
> brew cask install virtualbox
  1. 安装kubectl
> brew install kubectl
> kubectl version
Client Version: version.Info{Major:"1", Minor:"9", GitVersion:"v1.9.1", GitCommit:"3a1c9449a956b6026f075fa3134ff92f7d55f812", GitTreeState:"clean", BuildDate:"2018-01-04T19:58:48Z", GoVersion:"go1.9.2", Compiler:"gc", Platform:"darwin/amd64"}
Server Version: version.Info{Major:"1", Minor:"8", GitVersion:"v1.8.0", GitCommit:"0b9efaeb34a2fc51ff8e4d34ad9bc6375459c4a4", GitTreeState:"clean", BuildDate:"2017-11-29T22:43:34Z", GoVersion:"go1.9.1", Compiler:"gc", Platform:"linux/amd64"}
#启用autocompletion,对于zsh或者使用了oh-my-zsh
> source <(kubectl completion zsh)
  1. 安装minikube
    下载minikube,在这里使用的是最新发布版本0.24.1,下载好之后,加入到path下
> mv minikube-darwin-amd64 /usr/local/bin/minikube
> chmod +x /usr/local/bin/minikube
> minikube version
minikube version: v0.24.1

5.启动
5.1
minikube start
如果正常的话,到这里已经安装成功了,可惜。。
5.2 出现的第一个错误,是提示minikube-v0.23.6.iso和localkube-v1.8.0这个文件无法下载,猜测是被墙的原因,这里的解决方式是

> wget https://storage.googleapis.com/minikube/iso/minikube-v0.23.6.iso
> mv ~/Downloads/minikube-v0.23.6.iso ~/.minikube/cache/iso
> wget https://storage.googleapis.com/minikube/k8sReleases/v1.8.0/localkube-linux-amd64
>  mv ~/Downloads/localkube-linux-amd64 .minikube/cache/localkube/localkube-v1.8.0

再重新执行启动没有报错了,输出如下

> minikube start
Starting local Kubernetes v1.8.0 cluster...
Starting VM...
Getting VM IP address...
Moving files into cluster...
Setting up certs...
Connecting to cluster...
Setting up kubeconfig...
Starting cluster components...
Kubectl is now configured to use the cluster.
Loading cached images from config file.

5.3 运行hello-minikube

> kubectl run hello-minikube --image=k8s.gcr.io/echoserver:1.4 --port=8080
deployment "hello-minikube" created
> kubectl get pod
NAME                              READY     STATUS              RESTARTS   AGE
hello-minikube-7844bdb9c6-zwcnr   0/1       ContainerCreating   0          0s

貌似看起来一切正常,可惜等了10几分钟状态依然是ContainerCreating,看了下日志

> minikube logs

这里截图没有了。。,大概的意思就是无法从https://gcr.io/v2/下载image,肯定也是墙的问题,我目前的mac环境使用的shadowsocks翻的但是终端没法直接使用它,需要配置一下,另外由于ss采用的socks5协议,所以还需要转换下,所以先安装了privoxy,并配置了下,我本机开的代理端口在1080,ip地址不要用127.0.0.1或者localhost,否则minikube起来后还是无法使用,具体配置如下

> brew install privoxy
#修改的配置
forward-socks5t   /               127.0.0.1:1080 .
listen-address  192.168.94.1:8118
#启动
> privoxy /usr/local/etc/privoxy/config

启动好之后先校验下,使用curl加代理访问之前的网址测试下

> curl -x http://192.168.94.1:8118 "https://gcr.io/v2/" -v

好了之后,更改启动命令,配置minikube使用代理,NO_PROXY的作用是对于192.168.99.0/24该网段的地址不要走代理,原因是minikube内部启动的容器使用该网段,都代理就不会通了

minikube start --docker-env HTTP_PROXY=http://192.168.94.1:8118 --docker-env HTTPS_PROXY=http://192.168.94.1:8118 --docker-env NO_PROXY=192.168.99.0/24

好,一切就绪之后,再来看看pod的状态

> kubectl get pod
NAME                              READY     STATUS    RESTARTS   AGE
hello-minikube-7844bdb9c6-zwcnr   1/1       Running   0          1h

状态已经正常
5.4 暴露端口
可以发现hello-minikube服务已经暴露

> kubectl expose deployment hello-minikube --type=NodePort
> minikube service hello-minikube --url
http://192.168.99.100:31158

5.5 测试

> curl "http://192.168.99.100:31158"
CLIENT VALUES:
client_address=172.17.0.1
command=GET
real path=/
query=nil
request_version=1.1
request_uri=http://192.168.99.100:8080/SERVER VALUES:
server_version=nginx: 1.10.0 - lua: 10001HEADERS RECEIVED:
accept=*/*
host=192.168.99.100:31158
user-agent=curl/7.43.0
BODY:
-no body in request-%

到此ok了

参考

https://blog.csdn.net/jettery/article/details/79098759

https://yq.aliyun.com/articles/221687

Centos下安装minikube相关推荐

  1. Centos下安装mysql 总结

    一.MySQL安装 Centos下安装mysql 请点开:http://www.centoscn.com/CentosServer/sql/2013/0817/1285.html 二.MySQL的几个 ...

  2. linux卸载欧朋浏览器,如何在Centos下安装opera浏览器

    如何在Centos下安装opera浏览器 ,Opera目前是Linux平台上性能最优的浏览器,而且Opera中国团队本身即定位于Opera的研发中心,主要也是负责全球Linux平台项目的开发,这个版本 ...

  3. 在CentOS下安装apche+tomcat+mysql+php

    在CentOS下安装apche+tomcat+mysql+php 本例中所用到的软件 Apache 2.2 Sun的JDK-1_5_0_12-linux-i586 MySQL: mysql-5.0.4 ...

  4. Linux(CentOs)下安装Phantomjs + Casperjs

    Linux(CentOs)下安装Phantomjs + Casperjs 是参照cnMiss's Blog http://ju.outofmemory.cn/entry/70691的博客进行安装的 1 ...

  5. CentOS下安装JDK7 转载

    转载地址:http://www.cnblogs.com/rilley/archive/2012/02/02/2335395.html CentOS下安装JDK7 下载地址:http://www.ora ...

  6. centos解压zip命令_2、centos下安装elasticsearch-head

    1.下载 https://github.com/mobz/elasticsearch-head/archive/master.zip 2.解压 unzip elasticsearch-head-mas ...

  7. CentOS 下安装

    2016年12月5日15:25:58 ----------------------------------- 通常情况下在centos下安装软件就用yum. 关键是,使用yum你要知道安装包的名字是什 ...

  8. Centos下安装mysql(二进制版)

    Centos下安装mysql(二进制版) 1.下载安装包,选择相应的平台.版本,比如,选择64位Linux平台下的MySQL二进制包"Linux-Generic (glibc 2.5)(x8 ...

  9. Linux/CentOS下安装Apache/SVN/Subversion图文详解教程

    Linux(CentOS)下安装Apache+Subversion(图文教程) 服务器版本和安装软件 服务器版本: RedHatCentOS 5.5 32 bit 安装软件: apr-1.3.5.ta ...

最新文章

  1. 智在生活 自在慵懒 科沃斯机器人X京东大牌秒杀日主题展亮相无锡
  2. 源恩教育计算机,源恩计算机二级
  3. CircleList
  4. Tomcat发布Web项目的两种方式
  5. 找不到 快速启动 ,怎么办
  6. iphone最新款手机_苹果罕见“跌停”!遭遇6年来最惨淡一夜,2019年全球股市第一颗雷引爆...
  7. 数学差、物理差、英语又烂的放牛娃,后来竟成了清华校长,还做出了诺奖级的研究成果...
  8. MacOS13系统升级动态壁纸无法安装解决方法
  9. 用循环队列模拟滑动窗口动态求最值及峰峰值
  10. ps2硬盘接linux,PS2加装硬盘详细指导
  11. 全国DNS服务器ip地址
  12. Win11无线鼠标没反应怎么办?无线鼠标不能用是什么原因?
  13. 详解木头自动填表浏览器使用方法
  14. 七夕恋人必备表白源码
  15. android 程序更换字体颜色,android改变字体的颜色的三种方法
  16. C语言基础之4:字符串和格式化输入/输出
  17. java 对接顺丰快递进行寄件操作 (使用RestTemplate 请求)
  18. 端午临中夏,时清日复长。
  19. 3.Sunday算法的一个小优化
  20. 内存映射和多功能LED控制器驱动芯片/带按键扫描的LED驱动芯片(IC)-VK16K33A/B/C,内置RC振荡器,最大16seg和8com

热门文章

  1. python编程老师岗位需求表_教师岗位需求信息表
  2. 使用Mybatis如何对Mysql进行分页功能?
  3. linux之debian自动登录
  4. Python之魔法方法详解
  5. vb6实现union数据结构_Redis数据结构与对象编码解析
  6. 一起来学SpringBoot | 第二篇:SpringBoot配置详解
  7. 新开博了,欢迎大家来做客!
  8. 【CNMP系列】CentOS7.0下安装Nginx服务
  9. 【汇编语言与计算机系统结构笔记08】如何实现循环(Loops),gcc历史上经历了多种转换模式(微体系结构角度解释),Switch语句,跳转表
  10. ulimit命令学习