[k8s]minikube安裝配置-使用

Ubuntu17.04安裝minikube

安裝成功後結果

root@node1:~# minikube start
Starting local Kubernetes v1.7.5 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.

root@node1:~# virsh list --all
 Id    Name                           State
----------------------------------------------------
 1     minikube                       running
 virsh list --all
 Id    Name                           State
----------------------------------------------------
 1     minikube                       running

1.安裝kvm

參考:
https://github.com/kubernetes/minikube/blob/master/docs/drivers.md#kvm-driver

apt-get install libvirt-bin qemu-kvm -y
usermod -a -G libvirt $(whoami)
newgrp libvirt


apt-get install qemu-kvm qemu-system libvirt-bin  bridge-utils -y
apt-get install virt-manager -y

2.安裝二進制minikube&&kubectl

參考:https://github.com/kubernetes/minikube

curl -Lo minikube https://storage.googleapis.com/minikube/releases/v0.22.2/minikube-linux-amd64 && chmod +x minikube && sudo mv minikube /usr/local/bin/

curl -LO 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 && mv ./kubectl /usr/local/bin/kubectl

注:v0.22.2現在好像minikubev0.22.3了.

3.安裝二進制docker-machine-kvm

參考:https://github.com/dhiltgen/docker-machine-kvm

https://github.com/dhiltgen/docker-machine-kvm/releases
https://github.com/dhiltgen/docker-machine-kvm/releases/download/v0.10.0/docker-machine-driver-kvm-ubuntu16.04
  • 注: 我on個的Ubuntu17.06,這裏二進制包依舊用u16的.

  • 注:關於以上二進制安裝,包放在/usr/local/bin.並+x

4.設置使用kvm驅動

minikube config set vm-driver kvm

支持安裝完畢,minikube start即可.

附錄

  • 修改Ubuntu17.04源
cp /etc/apt/sources.list /etc/apt/sources.list_backup
cat >> /etc/apt/sources.list <<EOF
deb http://mirrors.163.com/ubuntu/ zesty main restricted universe multiverse
deb http://mirrors.163.com/ubuntu/ zesty-security main restricted universe multiverse
deb http://mirrors.163.com/ubuntu/ zesty-updates main restricted universe multiverse
deb http://mirrors.163.com/ubuntu/ zesty-proposed main restricted universe multiverse
deb http://mirrors.163.com/ubuntu/ zesty-backports main restricted universe multiverse
deb-src http://mirrors.163.com/ubuntu/ zesty main restricted universe multiverse
deb-src http://mirrors.163.com/ubuntu/ zesty-security main restricted universe multiverse
deb-src http://mirrors.163.com/ubuntu/ zesty-updates main restricted universe multiverse
deb-src http://mirrors.163.com/ubuntu/ zesty-proposed main restricted universe multiverse
deb-src http://mirrors.163.com/ubuntu/ zesty-backports main restricted universe multiverse
EOF
  • 安裝docker
sudo add-apt-repository    "deb [arch=amd64] https://download.docker.com/linux/ubuntu \
   $(lsb_release -cs) \
   stable"
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
apt-get update
apt-get install docker-ce -y
  • 一些所需的image

版本可以搞成最新的,我下面的有點老了

$ docker pull registry.cn-hangzhou.aliyuncs.com/google-containers/kube-addon-manager-amd64:v6.3
$ docker tag registry.cn-hangzhou.aliyuncs.com/google-containers/kube-addon-manager-amd64:v6.3 gcr.io/google-containers/kube-addon-manager:v6.3

$ docker pull registry.cn-hangzhou.aliyuncs.com/google-containers/kubernetes-dashboard-amd64:v1.5.1
$ docker tag registry.cn-hangzhou.aliyuncs.com/google-containers/kubernetes-dashboard-amd64:v1.5.1 gcr.io/google_containers/kubernetes-dashboard-amd64:v1.5.1

$ docker pull registry.cn-hangzhou.aliyuncs.com/google_containers/kubedns-amd64:1.9
$ ocker tag registry.cn-hangzhou.aliyuncs.com/google-containers/kubedns-amd64:1.9 gcr.io/google_containers/kubedns-amd64:1.9

$ docker pull registry.cn-hangzhou.aliyuncs.com/google-containers/kube-dnsmasq-amd64:1.4
$ docker tag registry.cn-hangzhou.aliyuncs.com/google-containers/kube-dnsmasq-amd64:1.4 gcr.io/google_containers/kube-dnsmasq-amd64:1.4

$ docker pull registry.cn-hangzhou.aliyuncs.com/google-containers/exechealthz-amd64:1.2
$ docker tag registry.cn-hangzhou.aliyuncs.com/google-containers/exechealthz-amd64:1.2 gcr.io/google_containers/exechealthz-amd64:1.2

$ docker pull registry.cn-hangzhou.aliyuncs.com/google-container/echoserver:1.4
$ docker tag  registry.cn-hangzhou.aliyuncs.com/google-container/echoserver:1.4 gcr.io/google_containers/echoserver:1.4

$ docker pull registry.cn-hangzhou.aliyuncs.com/google-containers/pause-amd64:3.0
$ docker tag registry.cn-hangzhou.aliyuncs.com/google-containers/pause-amd64:3.0 gcr.io/google_containers/pause-amd64:3.0
  • minikube一條蛇使用
$ minikube status  #查看minikube的狀態
$ minikube stop    #關閉cluster
$ minikube delete  #刪除集羣
$ minikube dashboard #minikube自帶dashboard,開啓命令


啓動一個echoserver pod
$ kubectl run hello-minikube --image=gcr.io/google_containers/echoserver:1.4 --port=8080

通過NodePort暴露的服務
$ kubectl expose deployment hello-minikube --type=NodePort

檢查pod是否啓動並運行
$ kubectl get pod

通過curl測試服務是否可訪問
$ curl $(minikube service hello-minikube --url)
https://github.com/coreos/minikube-iso/releases/

minikube start \
--iso-url=file:///root/minikube-v0.0.5.iso \
--kubernetes-version v1.7.5
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章