当前位置: 首页 > 工具软件 > kube-bench > 使用案例 >

kube

司马彦
2023-12-01

Kubernetes

  • https://kubernetes.io/zh/docs/setup/learning-environment/minikube/

使用 Minikube 安装 Kubernetes

  • https://kubernetes.io/docs/tasks/tools/install-minikube/

步骤

  • 安装virtualBox

      brew search virtualBox
      brew cask intall virtualBox 
    
  • Install Minikube

    brew install minikube

  • Confirm Installation

    minikube 在启动的时候我们可以配置比较多的参数,比如执行镜像源,配置docker 加速
    配置主机内存的大小

    minikube start --help

    minikube start --image-mirror-country=cn --driver=virtualbox

    使用阿里云的镜像 virtualbox 驱动程序,运行结果:

     Darwin 10.15.4 上的 minikube v1.10.1
    ✨ 根据用户配置使用 virtualbox 驱动程序
    ✅ 正在使用镜像存储库 registry.cn-hangzhou.aliyuncs.com/google_containers
     正在下载 VM boot image…
    > minikube-v1.10.0.iso.sha256: 65 B / 65 B [-------------] 100.00% ? p/s 0s
    > minikube-v1.10.0.iso: 174.99 MiB / 174.99 MiB [] 100.00% 3.58 MiB p/s 49s
     Starting control plane node minikube in cluster minikube
     Creating virtualbox VM (CPUs=2, Memory=4000MB, Disk=20000MB) …
     正在 Docker 19.03.8 中准备 Kubernetes v1.18.2…
    > kubelet.sha256: 65 B / 65 B [--------------------------] 100.00% ? p/s 0s
    > kubeadm.sha256: 65 B / 65 B [--------------------------] 100.00% ? p/s 0s
    > kubectl.sha256: 65 B / 65 B [--------------------------] 100.00% ? p/s 0s
    > kubeadm: 37.97 MiB / 37.97 MiB [---------------] 100.00% 1.02 MiB p/s 38s
    > kubectl: 41.99 MiB / 41.99 MiB [---------------] 100.00% 1.08 MiB p/s 39s
    > kubelet: 108.03 MiB / 108.03 MiB [-------------] 100.00% 2.06 MiB p/s 53s
     Verifying Kubernetes components…
     Enabled addons: default-storageclass, storage-provisioner
     完成!kubectl 已经配置至 “minikube”

    ❗ /usr/local/bin/kubectl is v1.15.5, which may be incompatible with Kubernetes v1.18.2.
     You can also use ‘minikube kubectl – get pods’ to invoke a matching version

  • check the status of the cluster

    minikube status

    result:

    minikube
    type: Control Plane
    host: Running
    kubelet: Running
    apiserver: Running
    kubeconfig: Configured
    
  • stop your cluster

    minikube stop

Clean up local state

If you have previously installed Minikube, and run:

 minikube start

and minikube start returned an error:

 machine does not exist

then you need to clear minikube’s local state:

minikube delete

##创建一个服务

kubectl create deployment hello-minikube --image=k8s.gcr.io/echoserver:1.10

kubectl expose deployment hello-minikube --type=NodePort --port=8080
这里只能是8080,其他端口访问不了

kubectl get pod

minikube service hello-minikube --url

访问得到的url:

Hostname: hello-minikube-64b64df8c9-fw5b9

Pod Information:
	-no pod information available-

Server values:
	server_version=nginx: 1.13.3 - lua: 10008

Request Information:
	client_address=172.17.0.1
	method=GET
	real path=/
	query=
	request_version=1.1
	request_scheme=http
	request_uri=http://192.168.99.101:8080/

Request Headers:
	accept=text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9
	accept-encoding=gzip, deflate
	accept-language=zh-CN,zh;q=0.9
	connection=keep-alive
	host=192.168.99.101:30709
	upgrade-insecure-requests=1
	user-agent=Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.138 Safari/537.36

Request Body:
	-no body in request-

打开仪表盘

  minikube dashboard
  正在开启 dashboard ...
樂  正在验证 dashboard 运行情况 ...
  Launching proxy ...
樂  正在验证 proxy 运行状况 ...
  Opening http://127.0.0.1:52810/api/v1/namespaces/kubernetes-dashboard/services/http:kubernetes-dashboard:/proxy/ in your default browser...    

删除服务,删除本地集群

删除服务
kubectl delete services hello-minikube
删除deployment
kubectl delete deployment hello-minikube

minikube stop
✋  Stopping "minikube" in virtualbox ...
  Node "minikube" stopped.
 minikube delete
  正在删除 virtualbox 中的“minikube”…
  Removed all traces of the "minikube" cluster.
 类似资料: