Kubernetes学习 — Macos安装Kubernetes
Kubernetes
安装
macos
检查环境
sysctl -a | grep machdep.cpu.features | grep VMX
安装VirtualBox
http://download.virtualbox.org/virtualbox/5.1.26/Oracle_VM_VirtualBox_Extension_Pack-5.1.26-117224.vbox-extpack
安装minikube
curl -Lo minikube https://storage.googleapis.com/minikube/releases/v0.21.0/minikube-darwin-amd64 && chmod +x minikube && sudo mv minikube /usr/local/bin/
创建集群
默认使用virtualbox。
主机的ip是192.168.31.186
, 1087
是proxy的端口。需要将ss的http代理监听地址从127.0.0.1
改为主机的ip。
#启动
minikube start
#使用私有库
minikube start --insecure-registry="192.168.31.34"
#使用proxy,用于获取镜像
minikube start --docker-env HTTP_PROXY="192.168.31.186:1087" --docker-env HTTPS_PROXY="192.168.31.186:1087" --docker-env NO_PROXY=192.168.99.0/24
安装kubectl
curl -Lo kubectl http://storage.googleapis.com/kubernetes-release/release/v1.7.3/bin/darwin/amd64/kubectl && chmod +x kubectl && sudo mv kubectl /usr/local/bin/
oh-my-zsh tab completion
vi ~/.zshrc
添加到plugin部分
plugins=(git zsh-completions kubectl)
使用
minikube
检查版本
minikube version
#minikube version: v0.21.0
kubectl version
#Client Version: version.Info{Major:"1", Minor:"3", GitVersion:"v1.3.0", GitCommit:"283137936a498aed572ee22af6774b6fb6e9fd94", GitTreeState:"clean", BuildDate:"2016-07-01T19:26:38Z", GoVersion:"go1.6.2", Compiler:"gc", Platform:"darwin/amd64"}
#Server Version: version.Info{Major:"1", Minor:"7", GitVersion:"v1.7.0", GitCommit:"d3ada0119e776222f11ec7945e6d860061339aad", GitTreeState:"clean", BuildDate:"2017-07-26T00:12:31Z", GoVersion:"go1.8.3", Compiler:"gc", Platform:"linux/amd64"}
获取集群地址
minikube ip
192.168.99.100
获取服务列表
minikube service list
打开dashboard
minikube dashboard
kubectl
部署Dashboard UI
默认minikube会自动部署dashboard
kubectl create -f https://rawgit.com/kubernetes/dashboard/master/src/deploy/kubernetes-dashboard.yaml
启动proxy
kubectl proxy
#Starting to serve on 127.0.0.1:8001
获取pod信息
kubectl get pods --namespace kube-system
NAME READY STATUS RESTARTS AGE
kube-addon-manager-minikube 0/1 Running 0 1h
kubernetes-dashboard-3313488171-90s64 0/1 Running 0 20m
如果STATUS一直处于ContainerCreating状态,应该是pull image失败。默认是去gcr.io拉镜像,被墙了。需要在启动minikube的时候设置docker使用的代理。
获取pod详细信息
kubectl describe pod kubernetes-dashboard-3313488171-90s64 --namespace kube-system
查看log
kubectl logs -f kubernetes-dashboard-3313488171-90s64