systemctl stop firewalld && systemctl disable firewalld
swapoff -a
setenforce 0
cat <<EOF > /etc/sysctl.d/k8s.conf
net.bridge.bridge-nf-call-ip6tables = 1
net.bridge.bridge-nf-call-iptables = 1
EOF
setenforce 0
curl -Lo minikube http://kubernetes.oss-cn-hangzhou.aliyuncs.com/minikube/releases/v1.3.1/minikube-linux-amd64 && chmod +x minikube && sudo mv minikube /usr/local/bin/
或者手动获取代码了
git clone https://github.com/AliyunContainerService/minikube
cd minikube
git checkout aliyun-v1.3.1
make
sudo cp out/minikube /usr/local/bin/
[root@xuxingyue-test-01 ~]# minikube --help
Minikube is a CLI tool that provisions and manages single-node Kubernetes clusters optimized for development workflows.
Basic Commands:
start Starts a local kubernetes cluster
status Gets the status of a local kubernetes cluster
stop Stops a running local kubernetes cluster
delete Deletes a local kubernetes cluster
dashboard Access the kubernetes dashboard running within the minikube cluster
Images Commands:
docker-env Sets up docker env variables; similar to '$(docker-machine env)'
cache Add or delete an image from the local cache.
Configuration and Management Commands:
addons Modify minikube's kubernetes addons
config Modify minikube config
profile Profile gets or sets the current minikube profile
update-context Verify the IP address of the running cluster in kubeconfig.
Networking and Connectivity Commands:
service Gets the kubernetes URL(s) for the specified service in your local cluster
tunnel tunnel makes services of type LoadBalancer accessible on localhost
Advanced Commands:
mount Mounts the specified directory into minikube
ssh Log into or run a command on a machine with SSH; similar to 'docker-machine ssh'
kubectl Run kubectl
Troubleshooting Commands:
ssh-key Retrieve the ssh identity key path of the specified cluster
ip Retrieves the IP address of the running cluster
logs Gets the logs of the running instance, used for debugging minikube, not user code.
update-check Print current and latest version number
version Print the version of minikube
Other Commands:
completion Outputs minikube shell completion for the given shell (bash or zsh)
Use "minikube <command> --help" for more information about a given command.
[root@test-01 ~]# minikube start --vm-driver=none --registry-mirror=https://docker.mirrors.ustc.edu.cn
* minikube v1.3.1 on Centos 7.6.1810
* Using image repository registry.cn-hangzhou.aliyuncs.com/google_containers
* Running on localhost (CPUs=4, Memory=3789MB, Disk=25587MB) ...
* OS release is CentOS Linux 7 (Core)
* Preparing Kubernetes v1.15.2 on Docker 19.03.0 ...
* Downloading kubeadm v1.15.2
* Downloading kubelet v1.15.2
* 拉取镜像 ...
* 正在启动 Kubernetes ...
* Configuring local host environment ...
*
! The 'none' driver provides limited isolation and may reduce system security and reliability.
! For more information, see:
- https://minikube.sigs.k8s.io/docs/reference/drivers/none/
*
! kubectl and minikube configuration will be stored in /root
! To use kubectl or minikube commands as your own user, you may
! need to relocate them. For example, to overwrite your own settings:
*
- sudo mv /root/.kube /root/.minikube $HOME
- sudo chown -R $USER $HOME/.kube $HOME/.minikube
*
* This can also be done automatically by setting the env var CHANGE_MINIKUBE_NONE_USER=true
[root@test-01 ~]# kubectl run kube-nginx --image=nginx:latest --port=80
kubectl run --generator=deployment/apps.v1 is DEPRECATED and will be removed in a future version. Use kubectl run --generator=run-pod/v1 or kubectl create instead.
修改为如下命令
[root@test-01 ~]# kubectl run --generator=run-pod/v1 kube-nginx --image=nginx:latest --port=80
pod/kube-nginx created
[root@test-01 ~]# kubectl get pods
NAME READY STATUS RESTARTS AGE
kube-nginx-7c765ffd95-rszh4 1/1 Running 0 20m
[root@test-01 ~]# kubectl cluster-info
Kubernetes master is running at https://10.10.40.5:8443
KubeDNS is running at https://10.10.40.5:8443/api/v1/namespaces/kube-system/services/kube-dns:dns/proxy
To further debug and diagnose cluster problems, use 'kubectl cluster-info dump'.
[root@test-01 ~]# minikube logs
* ==> Docker <==
* -- Logs begin at 四 2019-08-29 11:28:07 CST, end at 四 2019-08-29 15:10:53 CST. --
* 8月 29 13:43:19 test-01 dockerd[19819]: time="2019-08-29T13:43:19.670690663+08:00" level=info msg="Attempting next endpoint for pull after error: Get https://k8s.gcr.io/v2/: net/http: request canceled while waiting for connection (Client.Timeout exceeded while awaiting headers)"
* 8月 29 13:43:19 test-01 dockerd[19819]: time="2019-08-29T13:43:19.670742179+08:00" level=error msg="Handler for POST /v1.40/images/create returned error: Get https://k8s.gcr.io/v2/: net/http: request canceled while waiting for connection (Client.Timeout exceeded while awaiting headers)"
[root@test-01 ~]# kubectl run kube-nginx --image=nginx:latest --port=80 --image-pull-policy=IfNotPresent
kubectl run --generator=deployment/apps.v1 is DEPRECATED and will be removed in a future version. Use kubectl run --generator=run-pod/v1 or kubectl create instead.
Error from server (AlreadyExists): deployments.apps "kube-nginx" already exists
[root@test-01 ~]# kubectl expose deployment kube-nginx --type=NodePort
service/kube-nginx exposed
[root@test-01 ~]# kubectl get deployment
NAME READY UP-TO-DATE AVAILABLE AGE
kube-nginx 1/1 1 1 13m
[root@test-01 ~]# minikube service kube-nginx --url
* http://10.10.40.5:30017

dashboard管理后台是kubernetes提供的容器管理后台,可以用来进行机器负载,集群管理,镜像扩展,配置参数等相关操作
[root@xuxingyue-test-01 ~]# minikube dashboard --url
* Verifying dashboard health ...
* Launching proxy ...
* Verifying proxy health ...
http://127.0.0.1:5154/api/v1/namespaces/kube-system/services/http:kubernetes-dashboard:/proxy/
[root@test-01 ~]# kubectl apply -f https://raw.githubusercontent.com/kubernetes/dashboard/v2.0.0-beta1/aio/deploy/recommended.yaml
namespace/kubernetes-dashboard created
serviceaccount/kubernetes-dashboard created
service/kubernetes-dashboard created
secret/kubernetes-dashboard-certs created
secret/kubernetes-dashboard-csrf created
secret/kubernetes-dashboard-key-holder created
configmap/kubernetes-dashboard-settings created
role.rbac.authorization.k8s.io/kubernetes-dashboard created
clusterrole.rbac.authorization.k8s.io/kubernetes-dashboard created
rolebinding.rbac.authorization.k8s.io/kubernetes-dashboard created
clusterrolebinding.rbac.authorization.k8s.io/kubernetes-dashboard created
deployment.apps/kubernetes-dashboard created
service/dashboard-metrics-scraper created
deployment.apps/kubernetes-metrics-scraper created
[root@test-01 ~]# kubectl proxy --address='0.0.0.0' --accept-hosts='^*$'
Starting to serve on [::]:8001
