Deploy your first application on Hosted OpenShift on VCD

In this guide, you will learn how to:

  • create a Kubernetes/OpenShift project,
  • deploy your first Apache HTTPD application,
  • and verify its proper operation internally.

1. Create un project (namespace)

Create an isolated environment for your application:

oc new-project demo-app

Verify:

oc get projects

2. Deploy Apache application HTTPD

We will use the official Red Hat Universal Base Image (UBI), which complies with the SCC:

oc -n demo-app create deployment myapp --image=registry.access.redhat.com/ubi9/httpd-24

Verify that the pod starts:

oc -n demo-app get pods

3. Check application state

Check the pods

oc -n demo-app get pods -o wide

Expected status: Running

Check the Apache container logs

oc -n demo-app logs deployment/myapp

Check the pod in detail (if there’s a problem)

oc -n demo-app describe pod <POD_NAME>

4. Create internal Service (ClusterIP)

Even if we don’t expose the application, we can make it accessible to other pods in the cluster:

oc -n demo-app expose deployment myapp --port=8080 --target-port=8080 --type=ClusterIP

Apache UBI HTTPD listens on port 8080 by default, hence the --port=8080.

Verify:

oc -n demo-app get svc myapp

This service is internal to the cluster only.

5. Test the application from another pod

    Create a temporary pod:

    oc -n demo-app run test --rm -it --image=busybox --sh

    From the shell:

    wget -qO- http://myapp:8080

    You should see the default Apache page.

    Exit the pod:

    exit

    6. Clean up if necessary

    oc delete project demo-app

    🎉 Your Apache application is deployed!

    You have learned how to:

    • create a project,
    • deploy an application,
    • create an internal service,
    • test the application internally within the cluster