Minikube 入门基础:基础操作命令

Posted 沛沛老爹

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Minikube 入门基础:基础操作命令相关的知识,希望对你有一定的参考价值。

启动停止操作

启动集群

minikube start
  •  升级集群
minikube start --kubernetes-version=latest
  • 停止集群
minikube stop
  • 删除集群
minikube delete
  • 删除本地所有的集群和配置
minikube delete --all
  • 服务相关命令

  • 创建服务

当你启动了 minikube 后,你可以像操作其他k8s集群一样,通过kubectl 进行集群管理,比如创建一个服务:

kubectl create deployment hello-minikube --image=k8s.gcr.io/echoserver:1.4
  • 以 NodePort 的形式暴露一个服务
kubectl expose deployment hello-minikube --type=NodePort --port=8000
  • 以LoadBalancer的形式暴露端口
kubectl expose deployment hello-minikube1 --type=LoadBalancer --port=8000
  • 使用minikube在浏览器中快速打开服务放出的endpoint
minikube service hello-minikube
  • 控制面板

  • 访问 minikube中的 k8s控制面板
minikube dashboard

这将会开启 dashboard 插件,并自动在默认浏览器中开启代理的 endpoint,同样,这也需要在终端中保持进程运行,使用Ctrl + C 结束命令后,页面 dashboard 不能继续使用。

  • 获取 dashboard 的URL

如果你不想直接在浏览器中打开代理,也可以执行以下命令,这会只返回可访问的URL地址:

minikube dashboard --url
  • 界面使用

minikube 的 dashboard,即 Kubernetes 默认的 dashboard,具体可见: dashboard官方文档

  • Minikube 的配置项

minikube 的大多户配置已做成了参数接口,具体可以查看,可以执行以下命令:

minikube start --help

 这里展示一部分命令

Usage:
  minikube start [flags]

Flags:
      --apiserver-name string           The apiserver name which is used in the generated certificate for localkube/kubernetes.  This can be used if you want to make the apiserver available from outside the machine (default "minikubeCA")
      --container-runtime string        The container runtime to be used
      --cpus int                        Number of CPUs allocated to the minikube VM (default 2)
      --disk-size string                Disk size allocated to the minikube VM (format: <number>[<unit>], where unit = b, k, m or g) (default "20g")
      --dns-domain string               The cluster dns domain name used in the kubernetes cluster
      --docker-env stringArray          Environment variables to pass to the Docker daemon. (format: key=value)
      --docker-opt stringArray          Specify arbitrary flags to pass to the Docker daemon. (format: key=value)
      --extra-config ExtraOption        A set of key=value pairs that describe configuration that may be passed to different components.
		The key should be '.' separated, and the first part before the dot is the component to apply the configuration to.
		Valid components are: kubelet, apiserver, controller-manager, etcd, proxy, scheduler.
      --feature-gates string            A set of key=value pairs that describe feature gates for alpha/experimental features.
      --host-only-cidr string           The CIDR to be used for the minikube VM (only supported with Virtualbox driver) (default "192.168.99.1/24")
      --hyperv-virtual-switch string    The hyperv virtual switch name. Defaults to first found. (only supported with HyperV driver)
      --insecure-registry stringSlice   Insecure Docker registries to pass to the Docker daemon
      --iso-url string                  Location of the minikube iso (default "https://storage.googleapis.com/minikube/iso/minikube-v0.18.0.iso")
      --keep-context                    This will keep the existing kubectl context and will create a minikube context.
      --kubernetes-version string       The kubernetes version that the minikube VM will use (ex: v1.2.3) 
 OR a URI which contains a localkube binary (ex: https://storage.googleapis.com/minikube/k8sReleases/v1.3.0/localkube-linux-amd64) (default "v1.6.0")
      --kvm-network string              The KVM network name. (only supported with KVM driver) (default "default")
      --memory int                      Amount of RAM allocated to the minikube VM (default 2048)
      --network-plugin string           The name of the network plugin
      --registry-mirror stringSlice     Registry mirrors to pass to the Docker daemon
      --vm-driver string                VM driver is one of: [virtualbox xhyve vmwarefusion] (default "virtualbox")
      --xhyve-disk-driver string        The disk driver to use [ahci-hd|virtio-blk] (only supported with xhyve driver) (default "ahci-hd")

以上是关于Minikube 入门基础:基础操作命令的主要内容,如果未能解决你的问题,请参考以下文章

Minikube 基础操作2:应用操作

Minikube 基础操作2:应用操作

LAMMPS入门操作基础:Linux基础命令

Containerd 入门基础操作

cmd 与 bash 基础命令入门

Linux基础命令快速入门