minikube kubernetes can run a single local cluster nodes, it can very easily deploy kubernetes locally. Although only support single-node cluster kubernetes, but can support many kubernetes features, including:
-
DNS
-
NodePorts
-
ConfigMaps and Secrets
-
Dashboards
-
Container Runtime: Docker, CRI-O, and containerd
-
Enabling CNI (Container Network Interface)
-
Ingress
-
Install
Not yet installed minikube, you can read my previous article "centos install kubectl and minikube tool."
In this paper, install rabbitmq example, the use minikube to deploy a node kubernete
1. Start the Start command minikube, an article on the use of
minikube start --image-repository='registry.cn-hangzhou.aliyuncs.com/google_containers' --vm-driver=none
2. The following deployment kubernete using existing image rabbitmq
kubectl create deployment rabbitmq-minikube --image=docker.io/rabbitmq:3.8.2-management
Note: In order to facilitate the management, the proposed order last specify the version number, if not specified, the default is the latest
status = running description of the service has been up
3. rabbitmq expose a service port
kubectl expose deployment rabbitmq-minikube --type=NodePort --port=15672
4. Check the service of external exposure url details
minikube service rabbitmq-minikube --url
This address is our access rabbitmq address, enter the address in the browser, enter rabbitmq page,
5. open Dashboard
minikube dashboard
Tips are as follows:
1) Enter the failure in the browser, as shown below:
http://127.0.0.1:43584/api/v1/namespaces/kubernetes-dashboard/services/http:kubernetes-dashboard:/proxy/
View all pod, found no Dashboard
kubectl get pods --namespace kube-system
2) Create a Dashboard node, the method according to the official:
kubectl apply -f https://raw.githubusercontent.com/kubernetes/dashboard/v1.10.1/src/deploy/recommended/kubernetes-dashboard.yaml
3) Go to state pod ImagePullBackOff, mirrored pull failure. Ali cloud pull only from the mirror, the following command:
docker pull mirrorgooglecontainers/kubernetes-dashboard-amd64:v1.10.1
docker tag mirrorgooglecontainers/kubernetes-dashboard-amd64:v1.10.1 k8s.gcr.io/kubernetes-dashboard-amd64:v1.10.1
After the above command is successful, then execute 2) commands. View pod status:
kubectl get pods --all-namespaces
View pod log:
kubectl logs -f pods/kubernetes-dashboard-7c54d59f66-7tswd -n kube-system
Refer to some of the information online, this error is kube dns repeatedly restart, restart the ip rule, the following command:
systemctl stop kubelet
systemctl stop docker
iptables --flush
iptables -tnat --flush
systemctl start kubelet
systemctl start docker
After re-viewing pod state, we found a successful start up.
Enter the following URL in your browser virtual machine, you can see kubernete dashboard page
http://127.0.0.1:39780/api/v1/namespaces/kubernetes-dashboard/services/http:kubernetes-dashboard:/proxy/
6. commonly used commands
#查看kubernete集群下的pod
kubectl get pod
#查看集群下所有pod和namespace信息
kubectl get pods --all-namespaces
#删除一个pod -n后跟namespace
kubectl delete deployment dashboard-metrics-scraper -n kubernetes-dashboard
#删除service
kubectl delete services rabbitmq-minikube
#停止minikube集群
minikube stop
#删除minikube集群
minikube delete
#查看service对外暴露详情
minikube service rabbitmq-minikube
这个命令会使用默认l浏览器打开这个地址
#查看pod状态
kubectl describe -n kube-system pod/kubernetes-dashboard-65c76f6c97-htfxt
#查看pod启动日志
kubectl logs -f pods/kubernetes-dashboard-65c76f6c97-htfxt -n kube-system
minikube logs
#为rabbitmq-minikube deployment创建service,并通过Service的80端口转发至容器的8000端口上。
kubectl expose deployment rabbitmq-minikube --port=80 --target-port=8000
Reference documents:
https://kubernetes.io/docs/setup/learning-environment/minikube/
https://blog.csdn.net/shida_csdn/article/details/80028905?utm_source=blogxgwz1
Micro-channel public number