单机部署

创建Kubernetes cluster(单机版)最简单的方法是minikube:

首先下载kubectl

  1. curl -Lo kubectl https://storage.googleapis.com/kubernetes-release/release/v1.6.4/bin/linux/amd64/kubectl
  2. chmod +x kubectl

安装minikube

  1. # install minikube
  2. $ brew cask install minikube
  3. $ brew install docker-machine-driver-xhyve
  4. # docker-machine-driver-xhyve need root owner and uid
  5. $ sudo chown root:wheel $(brew --prefix)/opt/docker-machine-driver-xhyve/bin/docker-machine-driver-xhyve
  6. $ sudo chmod u+s $(brew --prefix)/opt/docker-machine-driver-xhyve/bin/docker-machine-driver-xhyve

最后启动minikube

  1. # start minikube.
  2. # http proxy is required in China
  3. $ minikube start --docker-env HTTP_PROXY=http://proxy-ip:port --docker-env HTTPS_PROXY=http://proxy-ip:port --vm-driver=xhyve

开发版

minikube/localkube只提供了正式release版本,而如果想要部署master或者开发版的话,则可以用hack/local-up-cluster.sh来启动一个本地集群:

  1. cd $GOPATH/src/k8s.io/kubernetes
  2.  
  3. export KUBERNETES_PROVIDER=local
  4. hack/install-etcd.sh
  5. export PATH=$GOPATH/src/k8s.io/kubernetes/third_party/etcd:$PATH
  6. hack/local-up-cluster.sh

打开另外一个终端,配置kubectl:

  1. cd $GOPATH/src/k8s.io/kubernetes
  2. export KUBECONFIG=/var/run/kubernetes/admin.kubeconfig
  3. cluster/kubectl.sh

//本文由 aleen42 提供 /发布在 feisky

K8S中文社区微信公众号

原文: http://docs.kubernetes.org.cn/109.html