1. minikube config

修改持久化配置值

通过类似 "minikube config set driver kvm2" 的子命令设置 minikube 的配置文件

通过命令创建的配置会保存在本机的 ~/.minikube/config/config.json 配置文件中

[minikube@localhost ~]$ cat .minikube/config/config.json
{
    "cpus": 2,
    "driver": "docker",
    "kubernetes-version": "v1.22.3",
    "memory": "2G",
    "profile": "k8s2"

可配置的字段:

  • driver
  • vm-driver
  • container-runtime
  • feature-gates
  • v
  • cpus
  • disk-size
  • host-only-cidr
  • memory
  • log_dir
  • kubernetes-version
  • iso-url
  • WantUpdateNotification
  • WantBetaUpdateNotification
  • ReminderWaitPeriodInHours
  • WantNoneDriverWarning
  • WantVirtualBoxDriverWarning
  • profile
  • bootstrapper
  • insecure-registry
  • hyperv-virtual-switch
  • disable-driver-mounts
  • cache
  • EmbedCerts
  • native-ssh
minikube config SUBCOMMAND [flags]

1.1. 从父命令继承的选项

      --add_dir_header                   If true, adds the file directory to the header of the log messages
      --alsologtostderr                  log to standard error as well as files
  -b, --bootstrapper string              The name of the cluster bootstrapper that will set up the Kubernetes cluster. (default "kubeadm")
  -h, --help                             
      --log_backtrace_at traceLocation   when logging hits line file:N, emit a stack trace (default :0)
      --log_dir string                   If non-empty, write log files in this directory
      --log_file string                  If non-empty, use this log file
      --log_file_max_size uint           Defines the maximum size a log file can grow to. Unit is megabytes. If the value is 0, the maximum file size is unlimited. (default 1800)
      --logtostderr                      log to standard error instead of files
      --one_output                       If true, only write logs to their native severity level (vs also writing to each lower severity level)
  -p, --profile string                   The name of the minikube VM being used. This can be set to allow having multiple instances of minikube independently. (default "minikube")
      --skip_headers                     If true, avoid header prefixes in the log messages
      --skip_log_headers                 If true, avoid headers when opening log files
      --stderrthreshold severity         logs at or above this threshold go to stderr (default 2)
      --user string                      Specifies the user executing the operation. Useful for auditing operations executed by 3rd party tools. Defaults to the operating system username.
  -v, --v Level                          number for the log level verbosity
      --vmodule moduleSpec               comma-separated list of pattern=N settings for file-filtered logging

1.2. 示例

1.2.1. 使用 config 管理配置

  • 查看当前环境集群信息

当前环境拥有两个集群配置,其中 k8s1 集群配置是默认的集群配置。

[minikube@localhost ~]$ minikube profile list
|---------|-----------|---------|--------------|------|---------|---------|-------|
| Profile | VM Driver | Runtime |      IP      | Port | Version | Status  | Nodes |
|---------|-----------|---------|--------------|------|---------|---------|-------|
| k8s1    | docker    | docker  | 192.168.49.2 | 8443 | v1.22.3 | Running |     3 |
| k8s2    | docker    | docker  | 192.168.58.2 | 8443 | v1.22.3 | Running |     2 |
|---------|-----------|---------|--------------|------|---------|---------|-------|
[minikube@localhost ~]$ minikube profile
k8s1

注意这里 minikube profile k8s1 设置和 minikube config set profile k8s1 是修改同一个配置项,效果相同。

  • 查看 driver 支持的配置项

可以通过 minikube config defaults driver 查看 driver 支持的配置值。

注意 minikube config defaults 目前只支持 driver 一个配置项的信息查看,详情可以通过 minikube config defutls -h 查看

[root@localhost ~]# minikube config defaults driver
* virtualbox
* vmwarefusion
* kvm2
* vmware
* none
* docker
* podman
* ssh
  • 设置 driver 的配置值为 docker

通过 config 命令将 driver 配置的值设置为 docker。设置成功后,下次集群删除重建后生效。

[root@localhost ~]# minikube config set driver docker
❗  These changes will take effect upon a minikube delete and then a minikube start
  • 查看设置的配置项

设置成功后,可以查看该值的设置

[root@localhost ~]# minikube config get driver
docker

也可以查看当前的所有配置项

[minikube@localhost ~]$ minikube config view
- cpus: 2
- driver: docker
- profile: k8s1
  • 取消设置

可以通过 unset 配置

[root@localhost ~]# minikube config unset driver
[root@localhost ~]# minikube config get driver
Error: specified key could not be found in config

取消成功后,该值没有设置内容

Copyright © 温玉 2021 | 浙ICP备2020032454号 all right reserved,powered by Gitbook该文件修订时间: 2022-06-23 23:01:26

results matching ""

    No results matching ""