crc icon indicating copy to clipboard operation
crc copied to clipboard

[Spike] Use `crc config` to use custom location for .crc directory

Open vyasgun opened this issue 10 months ago • 12 comments

Fixes: Issue #3966

Solution/Idea

The location for .crc directory is made configurable for the user through crc config. Currently, this PR will use the value set in the config as the new base directory.

Proposed changes

List main as well as consequential changes you introduced or had to introduce.

  • Add a new config key called crc-dir
  • Initialise Crc base directory variables based on the saved config
  • New config will take effect after rerunning crc setup

Testing

What is the bottom-line functionality that needs testing? Describe in pseudo-code or in English. Use verifiable statements that tie your changes to existing functionality.

gvyas-mac:crc gvyas$ crc config view
- consent-telemetry                     : no
- preset                                : microshift

gvyas-mac:crc gvyas$ crc config set crc-dir ~/test1
Changes to configuration property 'crc-dir' are only applied during 'crc setup'.
Please run 'crc setup' for this configuration to take effect.

gvyas-mac:crc gvyas$ crc config view
- consent-telemetry                     : no
- crc-dir                               : /Users/gvyas/test1
- preset                                : microshift

gvyas-mac:crc gvyas$ crc setup
INFO Using bundle path /Users/gvyas/test1/.crc/cache/crc_microshift_vfkit_4.15.3_amd64.crcbundle 
INFO Checking if running macOS version >= 13.x    
INFO Checking if running as non-root              
INFO Checking if crc-admin-helper executable is cached 
INFO Caching crc-admin-helper executable          
INFO Using root access: Changing ownership of /Users/gvyas/test1/.crc/bin/crc-admin-helper-darwin 
Password:
INFO Using root access: Setting suid for /Users/gvyas/test1/.crc/bin/crc-admin-helper-darwin 
INFO Checking if running on a supported CPU architecture 
INFO Checking if crc executable symlink exists    
INFO Creating symlink for crc executable          
INFO Checking minimum RAM requirements            
INFO Check if Podman binary exists in: /Users/gvyas/test1/.crc/bin/oc 
INFO Checking if running emulated on Apple silicon 
INFO Checking if vfkit is installed               
INFO Setting up virtualization with vfkit         
INFO Checking if CRC bundle is extracted in "/Users/gvyas/test1/.crc/cache/crc_microshift_vfkit_4.15.3_amd64.crcbundle" 
INFO Checking if /Users/gvyas/test1/.crc/cache/crc_microshift_vfkit_4.15.3_amd64.crcbundle exists 
INFO Checking if old launchd config for tray and/or daemon exists 
INFO Checking if crc daemon plist file is present and loaded 
INFO Adding crc daemon plist file and loading it  
INFO Checking SSH port availability               
Your system is correctly setup for using CRC. Use 'crc start' to start the instance
gvyas-mac:crc gvyas$ crc start
INFO Using bundle path /Users/gvyas/test1/.crc/cache/crc_microshift_vfkit_4.15.3_amd64.crcbundle 
INFO Checking if running macOS version >= 13.x    
INFO Checking if running as non-root              
INFO Checking if crc-admin-helper executable is cached 
INFO Checking if running on a supported CPU architecture 
INFO Checking if crc executable symlink exists    
INFO Checking minimum RAM requirements            
INFO Check if Podman binary exists in: /Users/gvyas/test1/.crc/bin/oc 
INFO Checking if running emulated on Apple silicon 
INFO Checking if vfkit is installed               
INFO Checking if old launchd config for tray and/or daemon exists 
INFO Checking if crc daemon plist file is present and loaded 
INFO Checking SSH port availability               
INFO Loading bundle: crc_microshift_vfkit_4.15.3_amd64... 
INFO Creating CRC VM for MicroShift 4.15.3...     
INFO Generating new SSH key pair...               
INFO Starting CRC VM for microshift 4.15.3...     
INFO CRC instance is running with IP 127.0.0.1    
INFO CRC VM is running                            
INFO Updating authorized keys...                  
INFO Configuring shared directories
INFO Check internal and public DNS query...       
INFO Check DNS query from host...                 
INFO Starting Microshift service... [takes around 1min] 
INFO Check internal and public DNS query...       
INFO Check DNS query from host...                 
INFO Starting Microshift service... [takes around 1min] 
INFO Waiting for kube-apiserver availability... [takes around 2min] 
INFO Adding microshift context to kubeconfig...   
Started the MicroShift cluster.

Use the 'oc' command line interface:
  $ eval $(crc oc-env)
  $ oc COMMAND

vyasgun avatar Apr 01 '24 07:04 vyasgun