docker & kubernetes 环境搭建

此文环境为阿里云服务器(使用了部分阿里镜像加速)

官方地址:

https://developer.aliyun.com/article/110806

 

安装Docker(ubuntu 16.4)

# step 1: 安装必要的一些系统工具
sudo apt-get update && apt-get -y install apt-transport-https ca-certificates curl software-properties-common
# step 2: 安装GPG证书
curl -fsSL http://mirrors.aliyun.com/docker-ce/linux/ubuntu/gpg | sudo apt-key add -
# Step 3: 写入软件源信息
sudo add-apt-repository "deb [arch=amd64] http://mirrors.aliyun.com/docker-ce/linux/ubuntu $(lsb_release -cs) stable"
# Step 4: 更新并安装Docker-CE
sudo apt-get -y update && apt-get -y install docker-ce

# 安装指定版本的Docker-CE:
# Step 1: 查找Docker-CE的版本:
# apt-cache madison docker-ce
# docker-ce | 17.03.1~ce-0~ubuntu-xenial | http://mirrors.aliyun.com/docker-ce/linux/ubuntu xenial/stable amd64 Packages
# docker-ce | 17.03.0~ce-0~ubuntu-xenial | http://mirrors.aliyun.com/docker-ce/linux/ubuntu xenial/stable amd64 Packages
# Step 2: 安装指定版本的Docker-CE: (VERSION例如上面的17.03.1~ce-0~ubuntu-xenial)
# sudo apt-get -y install docker-ce=[VERSION]

 


安装k8s测试环境Minikube (ubuntu 16.4)
# 安装 kubectl
# step 1:通过snap安装
sudo apt update && apt -y install snapd
# step 2:安装 kubectl
sudo snap install kubectl --classic
# 验证kubectl ,Ubuntu需要重启后才能验证成功 ,验证命令:kubectl version
# step 3:安装 minikube
curl -Lo minikube http://kubernetes.oss-cn-hangzhou.aliyuncs.com/minikube/releases/v0.30.0/minikube-linux-amd64 && chmod +x minikube && sudo mv minikube /usr/local/bin/
# step 4:启动 minikube
# 安装失败时先执行移除 rm -r ~/.minikube & minikube delete
minikube start --registry-mirror=https://registry.docker-cn.com --vm-driver=none
# step 5:启动 minikube
minikube dashboard

 

# 如果dashboard services的Type为ClusterIP,外网无法访问,需要修改为NodePort
kubectl -n kube-system edit service kubernetes-dashboard
# 将 type: ClusterIP 改为 type: NodePort ,:wq 退出保存,会提示修改成功
# 再次查看验证
kubectl -n kube-system get service kubernetes-dashboard

 

#根据自己的登录名来修改对应参数
$ sudo docker login --username=tbhtest@aliyun.com registry.cn-hangzhou.aliyuncs.com
$ sudo docker tag [ImageId] registry.cn-hangzhou.aliyuncs.com/tom/kluas:[镜像版本号]
$ sudo docker push registry.cn-hangzhou.aliyuncs.com/tom/kluas:[镜像版本号]

 

posted @ 2018-12-12 15:54  tomkluas  阅读(777)  评论(0编辑  收藏  举报