rancher下的kubernetes之构建标准化vmware镜像的方法步骤
author:一佰互联 2019-04-22   click:138

学习kubernetes的时候,我们需要在kubernetes环境下实战操作,然而kubernetes环境安装并不容器,现在通过rancher可以简化安装过程,咱们来实战rancher下的kubernetes吧;

整个实战分为两章:《构建标准化vmware镜像》和《安装部署rancher、kubernetes》

前提条件

由于要用到谷歌的服务,所以要求您的网络环境可以科学上网,具体的方案就不在这里说了;

实战环境

本次实战用的电脑是win10家庭版,通过vmware运行三个ubuntu16.04的虚拟机,一个作为rancher server,在上面创建kubernetes环境,另外两台作为节点加入到这个kubernetes环境中;

标准化vmware镜像是什么?

本次实战要用三个ubuntu虚拟机,如果都从安装ubuntu开始显然很费时,所以我们只装一次ubuntu系统,在这个系统上做一些通用的设置,装上通用的应用,然后把这个虚拟机的文件作为标准化镜像,复制三份,就可以启动三个虚拟机了;

安装操作系统

在ubuntu官网下载Ubuntu Server 16.04.3 LTS的安装文件ubuntu-16.04.3-server-amd64.iso

用下载好的ubuntu-16.04.3-server-amd64.iso文件在vmware上安装一个虚拟机,我用的是VMware® Workstation 12 Player,版本号12.5.6 build-5528349,虚拟机硬盘设置为60G,内存2G;

远程连接到虚拟机

装好系统后,用SecureCRT工具远程连接到虚拟机上,如下图:

登录后用su -命令切换到root账号;

设置允许远程root账号登录

打开/etc/ssh/sshd_config文件,找到下面这一行:

PermitRootLogin prohibit-password

改成下面这样:

PermitRootLogin yes

然后执行命令service ssh restart重启ssh服务,以后就可以在SecureCRT上通过root账号直接登录虚拟机了;

更新源

root账号登录虚拟机,打开/etc/apt/sources.list文件,将内容全部删除,然后增加以下内容(阿里云的源,目前速度较快):

# deb cdrom:[Ubuntu 16.04 LTS _Xenial Xerus_ - Release amd64 (20160420.1)]/ xenial main restricteddeb-src http://archive.ubuntu.com/ubuntu xenial main restricted #Added by software-propertiesdeb http://mirrors.aliyun.com/ubuntu/ xenial main restricteddeb-src http://mirrors.aliyun.com/ubuntu/ xenial main restricted multiverse universe #Added by software-propertiesdeb http://mirrors.aliyun.com/ubuntu/ xenial-updates main restricteddeb-src http://mirrors.aliyun.com/ubuntu/ xenial-updates main restricted multiverse universe #Added by software-propertiesdeb http://mirrors.aliyun.com/ubuntu/ xenial universedeb http://mirrors.aliyun.com/ubuntu/ xenial-updates universedeb http://mirrors.aliyun.com/ubuntu/ xenial multiversedeb http://mirrors.aliyun.com/ubuntu/ xenial-updates multiversedeb http://mirrors.aliyun.com/ubuntu/ xenial-backports main restricted universe multiversedeb-src http://mirrors.aliyun.com/ubuntu/ xenial-backports main restricted universe multiverse #Added by software-propertiesdeb http://archive.canonical.com/ubuntu xenial partnerdeb-src http://archive.canonical.com/ubuntu xenial partnerdeb http://mirrors.aliyun.com/ubuntu/ xenial-security main restricteddeb-src http://mirrors.aliyun.com/ubuntu/ xenial-security main restricted multiverse universe #Added by software-propertiesdeb http://mirrors.aliyun.com/ubuntu/ xenial-security universedeb http://mirrors.aliyun.com/ubuntu/ xenial-security multiverse

更新完毕后,执行apt-get update命令,用最新的源进行更新;

安装docker

安装依赖应用:

apt-get install -y   apt-transport-https   ca-certificates   curl   software-properties-common

下载软件包密钥,并添加到本地trusted数据库中:

curl -fsSL https://download.daocloud.io/docker/linux/ubuntu/gpg | sudo apt-key add -

添加 ppa 源:

add-apt-repository   "deb [arch=$(dpkg --print-architecture)] https://download.daocloud.io/docker/linux/ubuntu   $(lsb_release -cs)   stable"

做一次更新

apt-get update

安装docker

apt-get install -y -q docker-ce=17.03.2*

启动docker

service docker start

查看docker状态

service docker status

启动成功后状态信息如下图:

备份镜像文件

关闭虚拟机,找到对应的文件夹,把整个文件夹作为标准化的镜像备份起来,后续我们安装rancher的server和node节点的时候,直接复制这些文件夹然后打开就可以了;

下一章,我们将安装rancher的server,再把node节点加入到server环境中,然后体验kubernetes;

以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持网页设计。