crc-org / crc

CRC is a tool to help you run containers. It manages a local OpenShift 4.x cluster, Microshift or a Podman VM optimized for testing and development purposes
https://crc.dev
Apache License 2.0
1.26k stars 242 forks source link

[Idea] Switching preset should store configuration option in a preset-specific file #3634

Open gbraad opened 1 year ago

gbraad commented 1 year ago

At the moment, we store our configuration in crc.json, which is unaware of preset specific changes. It stores all the values (eg. 16G of memory) in a single file, and when moved from OpenShift to Microshift, this might mean we assign a lot more memory to this instance as it assign 16G that was given for OpenShift.

We could keep crc.json to store the general configuration, but a specific file for preset-based values, such as memory, cpus, disksize and bundle. This can be stored as crc-[preset].json (eg. crc-microshift.json) and when switched we therefore preserve these specific configuration options.

crc.json

{
  "preset": "openshift",
  "proxy": ...
}

crc-openshift.json

{ 
  "cpus": 8,
  "memory": "16G"
  // no disk-size => implies the default value
}

crc-microshift.json

{
   "memory": "4G",
   //cpus not set => implies default of 2
}
gbraad commented 1 year ago

This should be considered as a spike as this is not proven to be a solution yet.

cfergeau commented 1 year ago

An alternative could be single file with an array of preset-specific values:

{
  "preset": "openshift",
  "vm-config": [
      "microshift": {
        "memory": "6"
      },
      "openshift": {
        "disk-size": "..."
      },
  ]
}

With viper separate preset files taking precedence over the main one might be easier to implement though.

gbraad commented 1 year ago

changing to read a file by name sounds easier than adding logic to handle the array. you would like this eventually to be 'exchangeable' maybe?