$minikube start Starting local Kubernetes v1.8.0 cluster... Starting VM... Downloading Minikube ISO 140.01 MB / 140.01 MB [============================================] 100.00% 0s Getting VM IP address... Moving files into cluster... Downloading localkube binary 148.56 MB / 148.56 MB [============================================] 100.00% 0s Setting up certs... Connecting to cluster... Setting up kubeconfig... Starting cluster components... Kubectl is now configured to use the cluster.
6,kubectl get nodes 查看nodes
####7, 部署应用前
由于墙的原因,Minitube运行需要了的一些镜像是不能被下载的。故需要先解决下gcr.io的访问
minikube ssh (登录到虚拟机,下载需要的K8S镜像)
一个比较恶心的过程,使用阿里云进行下载需要的镜像
查看缺失的镜像,可以exit退出ssh.回到本机 minikube logs 从日志里查看。
1 2 3 4 5 6 7 8 9 10 11
docker pull registry.cn-hangzhou.aliyuncs.com/google_containers/kubernetes-dashboard-amd64:v1.7.0 docker tag registry.cn-hangzhou.aliyuncs.com/google_containers/kubernetes-dashboard-amd64:v1.7.0 gcr.io/google_containers/kubernetes-dashboard-amd64:v1.7.0
docker pull registry.cn-hangzhou.aliyuncs.com/google_containers/k8s-dns-sidecar-amd64:1.14.5 docker tag registry.cn-hangzhou.aliyuncs.com/google_containers/k8s-dns-sidecar-amd64:1.14.5 gcr.io/google_containers/k8s-dns-sidecar-amd64:1.14.5
docker pull registry.cn-hangzhou.aliyuncs.com/outman_google_containers/k8s-dns-dnsmasq-nanny-amd64:1.14.5 docker tag registry.cn-hangzhou.aliyuncs.com/outman_google_containers/k8s-dns-dnsmasq-nanny-amd64:1.14.5 gcr.io/google_containers/k8s-dns-dnsmasq-nanny-amd64:1.14.5
docker pull registry.cn-hangzhou.aliyuncs.com/outman_google_containers/k8s-dns-kube-dns-amd64:1.14.5 docker tag registry.cn-hangzhou.aliyuncs.com/outman_google_containers/k8s-dns-kube-dns-amd64:1.14.5 gcr.io/google_containers/k8s-dns-kube-dns-amd64:1.14.5
以上缺失就继续从log查看pull失败原因,再从阿里云拉起镜像,用tag映射下。
docker images 可以查看下载的镜像
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
docker images REPOSITORY TAG IMAGE ID CREATED SIZE gcr.io/google_containers/k8s-dns-sidecar-amd64 1.14.5 fed89e8b4248 6 weeks ago 41.8MB registry.cn-hangzhou.aliyuncs.com/google_containers/k8s-dns-sidecar-amd64 1.14.5 fed89e8b4248 6 weeks ago 41.8MB registry.cn-hangzhou.aliyuncs.com/outman_google_containers/k8s-dns-kube-dns-amd64 1.14.5 512cd7425a73 6 weeks ago 49.4MB gcr.io/google_containers/k8s-dns-kube-dns-amd64 1.14.5 512cd7425a73 6 weeks ago 49.4MB gcr.io/google_containers/k8s-dns-dnsmasq-nanny-amd64 1.14.5 459944ce8cc4 6 weeks ago 41.4MB registry.cn-hangzhou.aliyuncs.com/outman_google_containers/k8s-dns-dnsmasq-nanny-amd64 1.14.5 459944ce8cc4 6 weeks ago 41.4MB gcr.io/google-containers/kubernetes-dashboard-amd64 v1.7.0 284ec2f8ed6c 6 weeks ago 128MB gcr.io/google_containers/kubernetes-dashboard-amd64 v1.7.0 284ec2f8ed6c 6 weeks ago 128MB registry.cn-hangzhou.aliyuncs.com/google_containers/kubernetes-dashboard-amd64 v1.7.0 284ec2f8ed6c 6 weeks ago 128MB gcr.io/google-containers/kube-addon-manager v6.4-beta.2 0a951668696f 4 months ago 79.2MB registry.cn-hangzhou.aliyuncs.com/google_containers/kube-addon-manager v6.4-beta.2 0a951668696f 4 months ago 79.2MB gcr.io/google_containers/echoserver 1.4 a90209bb39e3 17 months ago 140MB registry.cn-hangzhou.aliyuncs.com/acs/echoserver 1.4 a90209bb39e3 17 months ago 140MB gcr.io/google_containers/pause-amd64 3.0 99e59f495ffa 18 months ago 747kB registry.cn-hangzhou.aliyuncs.com/google-containers/pause-amd64 3.0 99e59f495ffa 18 months ago 747kB
8,启动一个echoserver pod
1 2
$ kubectl run hello-minikube --image=gcr.io/google_containers/echoserver:1.4 --port=8080 deployment "hello-minikube" created
通过NodePort暴露的服务
1 2
$ kubectl expose deployment hello-minikube --type=NodePort service "hello-minikube" exposed
9,查看pods状态
1 2 3 4
kubectl get pods NAME READY STATUS RESTARTS AGE hello-8649f955b6-c54tx 1/1 Running 0 22h hello-minikube-5bc754d4cd-zbrh6 1/1 Running 0 9h
mikubectl get pod -o wide –all-namespaces(查看所有命名空间)