此文環境為阿里雲服務器(使用了部分阿里鏡像加速)
安裝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:[鏡像版本號]
