Expert GuideUser guide on how to install a Red Hat OpenShift 4 single-node cluster in v4.14

Claus Küthe & Daniel Kaiser — 04. March 2024
Reading time: 6:09 Minutes

Red Hat has launched its own version of Kubernetes with OpenShift 4. Follow our instructions to install a single node cluster to get familiar with this product.

This article provides step-by-step instructions on how to install an operational Single Node OpenShift 'cluster'. Although this installation is not a cluster in a technical sense, the term is used in the following instructions.

Get familiar with OpenShift

The aim of this guide is not a production system, but a test installation that you can use to get familiar with OpenShift.

 

Even though we have used VMware ourselves, we will assume in the following that a bare metal installation will be carried out in order to keep the instructions as generic as possible.

 

In our case, we have used a virtual machine with the following parameters as the target system:

  • 24 GB RAM

  • 120 GB primary hard drive

  • 200 GB secondary hard drive

  • 8 CPUs

  • One network card with fixed IP

  • Two static name entries:
*.apps.<clustername>.<yourdomain>

and

api.<clustername>.<yourdomain>

The minimum requirement is 16.35 GiB RAM, 120 GiB hard disk and 8 CPUs - this can be used to check the installation routine at best.

Installation with VMware 

If VMware is used, the following options must be set:

  • Extended parameters: disk.EnableUUID = TRUE
  • CPU: Provide hardware-supported virtualisation for the guest operating system

Installation with KVM

For KVM please use:

 

Number of CPUs: Copy the CPU configuration from the host (host-passthrough)

Installation

In order to prepare the installation, open the Hybrid Cloud Console from Red Hat (https://console.redhat.com). Select Red Hat Open Shift or Manage OpenShift Clusters, then Red Hat OpenShift Dedicated/Create Cluster. The cluster overview should still be empty.

 

Click on "Create Cluster" to change this - in the following overview, select Baremetal or Platform agnostic (x86_64), then "Interactive" for an installation via the Red Hat web interface.

 

 

Now enter the following data:

  • Cluster name: <your name>, for example "ocp-test"
  • Base domain: Your domain, for example example.com
  • Install single node OpenShift (SNO)
  • Host's network configuration: Static IP, bridges and bonds

 

Continue with "Next". Then enter:

  • DNS: The IP address of your DNS server
  • Machine Network: The network in which the machine is located (CIDR format)
  • Default Gateway: Your gateway

 

Then click "Next" to go to the next page.

 

All you need to do here is set the following parameters:

  • MAC Address: the MAC address of the primary network interface
  • IP address: The desired IP address of the installation

Now click "Next" to go to the next step, which you can skip by clicking "Next" again.

 

Let's now move on to the more interesting part of the installation:

By clicking on "Add Host", you can create and download an installation ISO to which you can add your SSH key.

 

The "Provisioning Type" can be "Full Image" or a "Minimal Image", whereby the latter downloads missing files during the installation and the installation will therefore take longer. The image is generated with "Generate Discovery ISO" and can then be downloaded either via the provided wget-command or the browser and used as a boot disc for your server.

Note: The ISO is linked to this cluster and cannot be used to install another cluster!

Once you have started the image, your host will appear under "Host Inventory" and will be indicated as ready for installation by "Ready". It may take up to a minute for the host to appear until it is displayed as ready for installation.

Attention:
Make sure that you are installing on the correct computer.

All data on your installation computer will be deleted during the installation!

Continue with "Next" and go to the overview for "Storage". The designation "Control plane node, Worker (bootstrap)" should appear here in "Role", as you are installing a single node cluster.

Expand the detailed view by clicking on the arrow pointing downwards.

Here you should ensure that the second hard drive in the "Format" column is not selected. Also make a note of the displayed WWN, but without the prefix 0x.

Continue with "Next".

 

You will see a summary of the installation on the following page, which you can confirm with "Next". Click "Install cluster" to finally start the installation on the next page.

The installation will require approximately one hour, depending on the performance of your virtual machine.

Click on "View Cluster Events" to display status and error messages.

After installation is complete, you can see the required DNS settings with "Launch OpenShift Console".

Please note that the specified wildcard domain

*.apps.<clustername>.<yourdomain>

 

is essential in order to access the graphical user interface of the cluster and any applications running on it later.

 

As login, you can use the standard user "kubeadmin" and the password provided in the installation environment. You should download the kubeconfig file for later use.

Installing the Command Line Client (OC)

The OpenShift command line (OC) client is recommended to be installed.

You can download the client directly from the OpenShift web interface:

  • Click on "?" in the top right corner
  • From there, select "Command Line Tools"

You can download the client suitable for your operating system and architecture as a tar (Linux) or zip file (Windows) in the following view. To use the client, you must download the "kubeconfig" from the RedHat Cloud Console and save it as the file ~/.kube/config. With the command oc whoami you can check whether the installation was successful and display the currently authenticated user.

Note:

Once you have installed the cluster on a virtual machine, take a snapshot. To do this, shut down the virtual machine, create a snapshot and restart the virtual machine.

Storage

With a single node installation, storage is not provided and needs to be added manually.

 

We will now need the command line client frequently. Therefore make sure that the client was set up successfully during the previous steps.

 

Create a new project called openshift-local-storage:

oc adm new-project openshift-local-storage

 

For a single node installation, the following command should be executed:

oc annotate namespace openshift-local-storage workload.openshift.io/allowed='management'

 

The interface must then be used:

  • Call up the cluster interface and log in.
  • Call up Operators → OperatorHub.
  • Enter "Local Storage" in the search field and click on the field that appears.
  • Click on "Install".
  • Select "A specific namespace on the cluster" (should already be selected).
  • Use"Operator recommended namespace: PR openshift-local-storage" if it is selected, or use "Select a namespace" and select the namespace itself.
  • Click on "Install".

 

Once the installation is completed according to the interface, you can check the namespace for running pods:

oc -n openshift-local-storage get pods

 

The command should output at least one entry.

 

You will now need to create a persistent volume (PV). Use the following YAML-file for doing this. You need to customise the path by replacing /path/to/device with your WWN.

 

If you have not noted the WWN during the installation, you can call up your cluster via

console.redhat.com and look up the WWN of the second hard drive in the details of your cluster (without 0x).

 

Alternatively, you can log in to your cluster via SSH with the user "core" and look it up using ls /dev/disk/by-id.

Note: make sure that you are using the correct hard drive!

apiVersion: local.storage.openshift.io/v1
kind: LocalVolume
metadata:
  name: lv-main
  namespace: openshift-local-storage
spec:
  nodeSelector:
    nodeSelectorTerms:
      - matchExpressions:
        - key: kubernetes.io/hostname
          operator: In
          values:
            - <FQDN of your installation>
  storageClassDevices:
    - devicePaths:
      - /path/to/device
    fsType: ext4
    storageClassName: sc-main
    volumeMode: Filesystem

 

Make sure that the formatting is correct. If the indentation is incorrect, the YAML file cannot be read.

 
Replace /path/to/device with the path of your hard drive (e.g. /dev/disk/by-id/wwn-0x6000c29dd7af736df2e18d3714fbeef2) and save the file as local-volume.yml in a directory of your choice.
 
Then use the oc client to create the volume:
oc create -f local-volume.yml

 

You can track progress by using the following command:

oc get all -n openshift-local-storage
oc get pv

 

The second command is crucial: A storageClass with the name "sc-main" must be shown here.

 

It is important that a PersistentVolume is automatically created in the GUI under Storage → PersistentVolumes, in our case local-pv-a7b1585d.

 

However, you will need to edit it manually by clicking on the persistent volume and opening the editor by clicking on YAML.

 

Search for the key "accessModes" under "spec" and change the entry from "ReadWriteOnce" to "ReadWriteMany" before saving with "Save".

 

You will need the name of the persistent volume (for us local-pv-a7b1585d) for the next YAML file, which you store in the PersistentVolumeClaim.yml file:

apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: image-registry-storage
  namespace: openshift-image-registry
spec:
  accessModes:
    - ReadWriteMany
  volumeMode: Filesystem
  volumeName: <Your PersistentVolume>
  storageClassName: sc-main
  resources:
    requests:
      storage: 100Gi

 

Replace volumeName with a value of your choice.

 

Install the YAML file with the following command and check the result after a few seconds:

oc create -f PersistentVolumeClaim.yml -n openshift-image-registry
oc get pvc -n openshift-image-registry

Please note that the second column - STATUS - contains the value "Bound".

 

You have now created the necessary prerequisites for the registry to be created in the next step.

Registry

 

OpenShift uses its own registry, which is used to store images in your infrastructure. After the previous steps, the setup is very simple.

 

Now we reactivate the internal image registry in OpenShift by setting its "managementState" to "Managed".

oc patch configs.imageregistry.operator.openshift.io cluster --type merge \
--patch '{"spec":{"managementState":"Managed"}}'

Then OpenShift is set up to use the previously created PersistentVolumeClaim:

oc patch configs.imageregistry.operator.openshift.io cluster --type merge \
--patch '{"spec": {"storage":{"managementState":"Managed", "pvc": \
{"claim":"image-registry-storage"}}}}'

There are three further commands to check the progress of the previous commands:

oc -n openshift-local-storage get pods
oc get csvs -n openshift-local-storage
oc get clusteroperator image-registry

The last command entered in the immediate execution will display True within the DEGRADED column and "Available: The deployment does not have available replicas..." within the MESSAGE column.

 

Run the command several times until MESSAGE is empty and DEGRADED is set to False. In our case, this took about 5 minutes.

The first application

To start your first application, you can switch from "Administrator" to the "Developer" view at the top left of the interface. Then select the "+Add" menu item in the sidebar. In the workspace, you can now click on Project at the top left and create your own project, which you can then select directly.

 

You will see several buttons in the workspace - select "Samples". To start with, Nginx, a lightweight web server, is a good choice. Click on this area and create the application with "Create".

 

After waiting around one to two minutes, the application should appear under "Topology" and be selected with a green tick:

 

The reference icon in the top right-hand corner of the circle should now point directly to an introductory page of the nginx container. If you click on this symbol, you should see a welcome page for the nginx application at the address

nginx-sample-<your project>.apps.<clustername>.<yourdomain>.

 

We hope you liked these instructions and that you will be successful with the implementation.

André Wild

Do you have any questions about installation or other topics related to OpenShift? - Just get in touch with us.

André Wild, Consultant
Phone +49172 541 142 29

You were interested in this, then you may also be interested in...