在mac上安装minikube

学习k8s,最烦的就是安装环境,minikube可以方便快速地在本地启动一个kubernetes环境,又能提供docker环境,是本地学习测试的好工具。

安装前准备

  • virtualbox
  • kubectl

安装

# 代理、你懂的
export http_proxy=http://192.168.99.1:1087;
export https_proxy=http://192.168.99.1:1087;
brew install kubernetes-cli
brew cask install minikube

启动

minikube start  \
    --memory=4096 --cpus=2 --kubernetes-version=v1.9.4 \
    --extra-config=controller-manager.cluster-signing-cert-file="/var/lib/localkube/certs/ca.crt" \
    --extra-config=controller-manager.cluster-signing-key-file="/var/lib/localkube/certs/ca.key" \
    --extra-config=apiserver.admission-control="NamespaceLifecycle,LimitRanger,ServiceAccount,PersistentVolumeLabel,DefaultStorageClass,DefaultTolerationSeconds,MutatingAdmissionWebhook,ValidatingAdmissionWebhook,ResourceQuota" \
    --vm-driver=virtualbox \
    --registry-mirror=https://registry.docker-cn.com \
    --docker-env HTTP_PROXY=http://192.168.99.1:1087 \
    --docker-env HTTPS_PROXY=http://192.168.99.1:1087 \
    --docker-env NO_PROXY=localhost,127.0.0.1,.docker.io,.docker-cn.com,.aliyuncs.com

kubectl taint nodes --all node-role.kubernetes.io/master-
minikube dashboard
# 执行docker
➜ eval $(minikube docker-env)
➜ minikube ip
192.168.99.101
# 另一种在浏览器打开已部署的dashboard方式
➜ minikube service kubernetes-dashboard -n kube-system

minikube service可以在流里流气打开service地址,其实就是打开http:// minikube-ip: service-nodePort。所以,service的部署需要使用NodePort模式,可以使用类似命令修改: kubectl get svc serviceName -n istio-system -o yaml| sed "s/ClusterIP/NodePort/g"|kubectl apply -f -

➜ kubectl get pod -n kube-system
NAME                                    READY     STATUS    RESTARTS   AGE
etcd-minikube                           1/1       Running   0          5h
kube-addon-manager-minikube             1/1       Running   0          5h
kube-apiserver-minikube                 1/1       Running   5          5h
kube-controller-manager-minikube        1/1       Running   0          5h
kube-dns-6f4fd4bdf-m862l                3/3       Running   0          5h
kube-proxy-497lx                        1/1       Running   0          5h
kube-scheduler-minikube                 1/1       Running   0          5h
kubernetes-dashboard-77d8b98585-c6wrs   1/1       Running   0          5h
storage-provisioner                     1/1       Running   0          5h

好啦,到这儿就安装成功了

安装istio

随带安装istio。

curl -L https://git.io/getLatestIstio | sh -
cd istio-0.2.10 
export ISTIO_HOME=$PWD
export PATH=$PATH:${ISTIO_HOME}/bin
kubectl apply -f ${ISTIO_HOME}/install/kubernetes/istio-demo.yaml
CONTENTS