… but only if you have large pockets, that is! 🙂
I suppose that, by now, you’ve already heard of minishift – tool which helps you run a single-node OpenShift 3.x cluster inside a virtual machine (on your preferred hypervisor), which is extremely convenient if you need to do some local development, testing, etc. Of course, you can always deploy what you need on top of Azure or any other cloud provider, but having OpenShift cluster locally can have its benefits.
And what if you need, let’s say, an OpenShift 4.x cluster “to go”?
Don’t worry, there is a solution for you as well! It’s called CodeReady Containers (CRC) (version 1.9 at the time of writing), and is basically a single node OpenShift 4.x cluster, inside a virtual machine (sounds a lot like minishift, doesn’t it?).
So, how can you get your hands on CRC and make it work?
There are a couple of steps involved:
- look at the prerequisites:
- create a free Red Hat account:
- download the CRC disk image and your pull secret file:
- download the OpenShift tools (as I’m using Windows, so I’ll use this one):
- unzip all to a location you like (mine is C:\PocketOpenShift):
- (optional) add this location to PATH for easier usage (as already mentined, I’m using Windows & PowerShell):
1 |
[System.Environment]::SetEnvironmentVariable("PATH", $Env:Path + ";C:\PocketOpenShift", "Machine") |
- run “crc setup” which will prepare the environment:
1 2 3 4 5 6 7 8 9 10 11 12 |
crc setup # INFO Checking if oc binary is cached # INFO Checking if podman remote binary is cached # INFO Checking if CRC bundle is cached in '$HOME/.crc' # INFO Checking if running as normal user # INFO Checking Windows 10 release # INFO Checking if Hyper-V is installed and operational # INFO Checking if user is a member of the Hyper-V Administrators group # INFO Checking if Hyper-V service is enabled # INFO Checking if the Hyper-V virtual switch exist # INFO Found Virtual Switch to use: Default Switch # Setup is complete, you can now run 'crc start' to start the OpenShift cluster |
- run “crc start” (with one or more options, if needed – as you can see, I’ll be using custom number of vCPUs, amount of RAM and a custom nameserver):
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
crc start --cpus 4 --memory 8192 --nameserver 8.8.8.8 --pull-secret-file ".\pull-secret.txt" # INFO Checking if oc binary is cached # INFO Checking if podman remote binary is cached # INFO Checking if running as normal user # INFO Checking Windows 10 release # INFO Checking if Hyper-V is installed and operational # INFO Checking if user is a member of the Hyper-V Administrators group # INFO Checking if Hyper-V service is enabled # INFO Checking if the Hyper-V virtual switch exist # INFO Found Virtual Switch to use: Default Switch # INFO Loading bundle: crc_hyperv_4.3.10.crcbundle ... # INFO Checking size of the disk image C:\Users\tomica\.crc\cache\crc_hyperv_4.3.10\crc.vhdx ... # INFO Creating CodeReady Containers VM for OpenShift 4.3.10... # INFO Verifying validity of the cluster certificates ... # INFO Adding 8.8.8.8 as nameserver to the instance ... # INFO Will run as admin: add dns server address to interface vEthernet (Default Switch) # INFO Check internal and public DNS query ... # INFO Check DNS query from host ... # INFO Copying kubeconfig file to instance dir ... # INFO Adding user's pull secret ... # INFO Updating cluster ID ... # INFO Starting OpenShift cluster ... [waiting 3m] # INFO # INFO To access the cluster, first set up your environment by following 'crc oc-env' instructions # INFO Then you can access it by running 'oc login -u developer -p developer https://api.crc.testing:6443' # INFO To login as an admin, run 'oc login -u kubeadmin -p <a_secret_password> https://api.crc.testing:6443' # INFO # INFO You can now run 'crc console' and use these credentials to access the OpenShift web console # Started the OpenShift cluster # WARN The cluster might report a degraded or error state. This is expected since several operators have been disabled to lower the resource usage. For more information, please consult the documentation |
- at any time, you can check the status of your cluster by using “crc status” command:
1 2 3 4 5 6 |
crc status # CRC VM: Running # OpenShift: Running (v4.3.10) # Disk Usage: 10.67GB of 32.72GB (Inside the CRC VM) # Cache Usage: 14.27GB # Cache Directory: C:\Users\tomica\.crc\cache |
- once it is up, you can use “oc login” or console (bring it up with “crc console“) to connect to it, either as an (kube)admin or a developer, and continue working as you would normally with any other OpenShift cluster:
1 2 3 4 5 6 7 8 9 10 11 |
oc login -u kubeadmin -p <a_secret_password> https://api.crc.testing:6443 # The server uses a certificate signed by an unknown authority. # You can bypass the certificate check, but any data you send to the server could be intercepted by others. # Use insecure connections? (y/n): <strong>y</strong> # # Login successful. # # You have access to 53 projects, the list has been suppressed. You can list all projects with 'oc projects' # # Using project "default". # Welcome! See 'oc help' to get started. |
- one other thing I like to do is to enable monitoring and other disabled stuff (note though – your VM should have 12+ GB RAM) – you can do it with two commands – first one lists all that is disabled, and the second one, with the index at the end, enables it (also note that in the official documentation there is an issue with “” and ” (they are switched), if you’re working in PowerShell):
1 2 3 4 5 6 7 8 9 10 11 12 13 |
oc get clusterversion version -ojsonpath="{range .spec.overrides[*]}{.name}{'\n'}{end}" | % {$nl++;"`t$($nl-1) `t $_"};$nl=0 # 0 cluster-monitoring-operator # 1 machine-config-operator # 2 etcd-quorum-guard # 3 machine-api-operator # 4 cluster-autoscaler-operator # 5 insights-operator # 6 prometheus-k8s oc patch clusterversion/version --type="json" -p "[{'op':'remove', 'path':'/spec/overrides/0'}]" -oyaml # ... # state: Completed # ... |
- monitoring should now be working as well:
And that’s it – you’re ready to work on your own “pocket OpenShift cluster”! 🙂
Of course, don’t forget that there is also the official documentation, including the Getting Started guide and Release Notes and Known Issues document. So… take a look!
Cheers!