openshift local Tutorial for Developers

Author

Reads 1K

Container terminal with straddle carriers and stacked shipping containers under a cloudy sky.
Credit: pexels.com, Container terminal with straddle carriers and stacked shipping containers under a cloudy sky.

If you're a developer looking to get started with OpenShift Local, you're in the right place. OpenShift Local is a tool that allows you to run a local OpenShift cluster on your machine, making it easy to test and develop applications.

With OpenShift Local, you can deploy applications to a local cluster using the same tools and workflows as you would in a production environment. This means you can test and iterate on your code without having to set up a full production environment.

To get started with OpenShift Local, you'll need to have Docker and a compatible version of Kubernetes installed on your machine.

Installation

To install OpenShift Local, you'll need to download the appropriate platform from the Red Hat Hybrid Cloud Console. This step is crucial, and you can find the download link on the console.

You can install OpenShift Local on your local machine using the crc.dev instructions, which provide a detailed guide on how to do it. However, if you're using Ubuntu 22.04, you might need to select the qemu-system-x86 package instead of the qemu-kvm package.

To install the Local Storage Operator, you can use the OpenShift Container Platform web console or the CLI. If you choose to use the web console, navigate to Operators → OperatorHub, type Local Storage into the filter box, and click Install.

Installing

A car dashboard with glowing dials and controls, showcasing illuminated technology at night.
Credit: pexels.com, A car dashboard with glowing dials and controls, showcasing illuminated technology at night.

Installing the Local Storage Operator is a crucial step in enabling local volumes in your cluster.

The Local Storage Operator is not installed in OpenShift Container Platform by default, so you'll need to follow a specific procedure to install and configure it.

You can install the Local Storage Operator from the web console by navigating to Operators → OperatorHub, typing Local Storage into the filter box, and clicking Install.

Alternatively, you can install it from the CLI by creating the Local Storage Operator object using the command $oc apply -f openshift-local-storage.yaml.

To verify local storage installation, check that all pods and the Local Storage Operator have been created.

There are also different ways to install the Local Storage Operator, such as using the Red Hat Hybrid Cloud Console or following instructions from the crc.dev.

For example, on Ubuntu 22.04, you might need to select the qemu-system-x86 package instead of the qemu-kvm package.

Here are the installation options for the Local Storage Operator:

  • Update channel: stable
  • Installation mode: A specific namespace on the cluster
  • Installed Namespace: Operator recommended namespace openshift-local-storage
  • Update approval: Automatic

If you're using a Mac M1, you can install Red Hat OpenShift Local by downloading the latest release from the Red Hat Hybrid Cloud Console and following the instructions from the crc.dev.

You'll need at least 4 physical CPU cores, 9 GB of free memory, and 35 GB of storage space to install the OpenShift Container Platform cluster using Red Hat OpenShift Local.

Provisioning and Management

Credit: youtube.com, OpenShift in 1 hour with Demo | Most Popular Kubernetes Platform used by Organizations

Provisioning local volumes in OpenShift Container Platform is a bit different than with other storage options. Local volumes cannot be created by dynamic provisioning, but instead, you can define a PersistentVolume (PV) object to create a local volume.

To create a PV, you'll need to define a file, such as example-pv-filesystem.yaml, with the PV object definition. This resource must specify the nodes and paths to the local volumes.

You can only specify a directory with Filesystem volumeMode, and a raw block volume (volumeMode: block) is not formatted with a file system.

Here are the steps to create a PV:

1. Define the PV by creating a file with the PV object definition.

2. Create the PV resource in your OpenShift Container Platform cluster using the oc create command.

3. Verify that the local PV was created using the oc get pv command.

Alternatively, you can use the Local Storage Operator to automate local storage discovery and provisioning. This feature is useful when dynamic provisioning is not available during deployment, such as with bare metal, VMware, or AWS store instances with attached devices.

Credit: youtube.com, Openshift 4.12 Installation | Complete Openshift Cluster Installation | English

To use the Local Storage Operator, you'll need to:

  • Have cluster administrator permissions
  • Have installed the Local Storage Operator
  • Have attached local disks to OpenShift Container Platform nodes
  • Have access to the OpenShift Container Platform web console and the oc command-line interface (CLI)

You can enable automatic discovery of local devices from the web console, and then automatically provision local volumes for the discovered devices.

Here's a summary of the steps to provision local volumes with the Local Storage Operator:

  • Enable automatic discovery of local devices from the web console
  • Display a continuous list of available devices on a node
  • Automatically provision local volumes for the discovered devices from the web console
  • Alternatively, provision local volumes for the discovered devices from the CLI

Automation and Discovery

You need cluster administrator permissions to automate discovery and provisioning for local storage devices. This is a crucial requirement to get started.

The Local Storage Operator is the key to automating local storage discovery and provisioning. It simplifies installation when dynamic provisioning is not available during deployment.

To use the Local Storage Operator, you must have installed it. This is a necessary step before you can automate local storage discovery and provisioning.

You can attach local disks to OpenShift Container Platform nodes, but you need to make sure the Local Storage Operator is the only entity managing local devices on the node.

Credit: youtube.com, OpenShift Architecture | K21Academy

To enable automatic discovery of local devices from the web console, you can follow a simple procedure. This will help you display a local volume discovery instance named auto-discover-devices.

To automatically provision local volumes for the discovered devices from the web console, you can follow another procedure. This will help you provision local volumes for the discovered devices.

Alternatively, you can provision local volumes for the discovered devices from the CLI using the oc command-line interface. This gives you more flexibility and options.

To display a continuous list of available devices on a node, you can use the CLI. This will help you keep track of the available devices on your node.

Here are the requirements to automate discovery and provisioning for local storage devices:

  • Cluster administrator permissions
  • The Local Storage Operator installed
  • Local disks attached to OpenShift Container Platform nodes
  • Access to the OpenShift Container Platform web console and the oc command-line interface (CLI)

Tolerations and Metrics

Local Storage Operator metrics are essential for monitoring and troubleshooting. OpenShift Container Platform provides metrics for the Local Storage Operator.

To use these metrics, you need to enable support for monitoring when installing the Local Storage Operator. This is crucial for getting accurate data.

Credit: youtube.com, OpenShift Infra Nodes, Taints, and Tolerations

Some of the key metrics provided by OpenShift Container Platform include:

  • lso_discovery_disk_count: total number of discovered devices on each node
  • lso_lvset_provisioned_PV_count: total number of PVs created by LocalVolumeSet objects
  • lso_lvset_unmatched_disk_count: total number of disks that Local Storage Operator did not select for provisioning because of mismatching criteria
  • lso_lvset_orphaned_symlink_count: number of devices with PVs that no longer match LocalVolumeSet object criteria
  • lso_lv_orphaned_symlink_count: number of devices with PVs that no longer match LocalVolume object criteria
  • lso_lv_provisioned_PV_count: total number of provisioned PVs for LocalVolume

If you're upgrading to OpenShift Container Platform 4.9 or later, don't forget to enable metric support manually by adding the operator-metering=true label to the namespace.

Tolerations with Pods

Tolerations allow pods to run on tainted nodes, which are nodes that have been marked with a taint to prevent general workloads from running on them.

The Local Storage Operator requires tolerations to be added to the Pod or DaemonSet definition to run on tainted nodes. This is done through the LocalVolume resource.

To apply tolerations to the Local Storage Operator pod, you need to specify the key, value, and effect of the taint, which is expressed as key=value:effect.

A taint on a node instructs the node to repel all pods that do not tolerate the taint, so you need to use a specific taint that is not on other pods to ensure the Local Storage Operator pod can run on that node.

Credit: youtube.com, Kubernetes Node Selector vs Node Affinity vs Pod Affinity vs Tains & Tolerations

Here's an example of how to add tolerations to the LocalVolume spec in the YAML file:

The key and value must match for the Equal operator, but the key can exist without a value for the Exists operator.

By adding tolerations to the LocalVolume spec, you can allow the Local Storage Operator to use tainted nodes and provision local storage on them.

Metrics

Metrics are a crucial aspect of monitoring and managing your OpenShift Container Platform. OpenShift provides metrics for the Local Storage Operator, which you can use to track the performance and efficiency of your storage infrastructure.

To access these metrics, you need to enable support for monitoring when installing the Local Storage Operator. This will allow you to view metrics such as the total number of discovered devices on each node.

The Local Storage Operator provides the following metrics: lso_discovery_disk_count: total number of discovered devices on each nodelso_lvset_provisioned_PV_count: total number of PVs created by LocalVolumeSet objectslso_lvset_unmatched_disk_count: total number of disks that Local Storage Operator did not select for provisioning because of mismatching criterialso_lvset_orphaned_symlink_count: number of devices with PVs that no longer match LocalVolumeSet object criterialso_lv_orphaned_symlink_count: number of devices with PVs that no longer match LocalVolume object criterialso_lv_provisioned_PV_count: total number of provisioned PVs for LocalVolume

You'll also need to enable metric support manually by adding the operator-metering=true label to the namespace when upgrading to OpenShift Container Platform 4.9 or later. This will ensure you have access to the metrics you need to optimize your storage infrastructure.

Oscar Hettinger

Writer

Oscar Hettinger is a skilled writer with a passion for crafting informative and engaging content. With a keen eye for detail, he has established himself as a go-to expert in the tech industry, covering topics such as cloud storage and productivity tools. His work has been featured in various online publications, where he has shared his insights on Google Drive subtitle management and other related topics.

Love What You Read? Stay Updated!

Join our community for insights, tips, and more.