Running the SV Server in RedHat OpenShift

This topic describes how to run the Service Virtualization server within the RedHat OpenShift 4 cluster. The deployment has been tested in RedHat Openshift 4.5 CodeReady Containers.

Prerequisites

  • Make sure you download and setup RedHat Openshift 4.5 CodeReady Containers.

  • Windows: To run OpenShift from a non-system drive, set the HOMEDRIVE and HOMEPATH environment variables.

    Example:

    set HOMEDRIVE=e:
    set HOMEPATH=\work\openshift\home
  • If you encounter DNS issues during the deployment (for example, failing Docker image pull), try starting OpenShift with -n parameter setting a DNS server.

    Example:

    crc start -n 8.8.8.8

  • Prepare sv-server project.

    1. Open the OpenShift admin console:

      • crc console

      • user: kubeadmin

      For credentials run crc console --credentials

    2. Create a project sv-server.

    3. The SV Server Docker image requires root permissions. Run the following commands to create a service account granting permissions for the sv-server project:

      oc create serviceaccount runasanyuid
      oc project sv-server
      oc adm policy add-scc-to-user anyuid -z runasanyuid --as system:admin

Back to top

Database deployment

A running service providing a connection to a database is a prerequisite for the SV Server. To perform a database deployment, create the following components using an OpenShift admin console:

Database Persistent Volume Claim

kind: PersistentVolumeClaim
apiVersion: v1
metadata:
name: postgres-db-pvc
labels:
app: sv-postgres-db
spec:
accessModes:
- ReadWriteOnce
selector:
matchLabels:
volume: pv0006
resources:
requests:
storage: 4Gi
volumeMode: Filesystem

If OpenShift fails to map the claim to an existing persistent volume, change the volume name (pv0006 in the example) to address an existing volume. You can also create a new one if no suitable unmapped volume exists.

PostgreSQL deployment config

apiVersion: apps.openshift.io/v1
kind: DeploymentConfig
metadata:
name: sv-postgres-db
labels:
app: sv-postgres-db
spec:
selector:
name: sv-postgres-db
replicas: 1
template:
metadata:
labels:
name: sv-postgres-db
spec:
serviceAccountName: runasanyuid securityContext:
type: RunAsAny
containers:
- name: sv-postgres-db
image: postgres
env:
- name: POSTGRES_PASSWORD
value: "postgres"
imagePullPolicy: Always
ports:
- containerPort: 5432
volumeMounts:
- name: postgres-data
mountPath: /var/lib/postgresql/data
readOnly: false
volumes:
- name: postgres-data
persistentVolumeClaim:
claimName: postgres-db-pvc

Rollout the deployment config which should end with a pod running the database.

Database Service

Create a service that provides access to the database pod:

apiVersion: v1
kind: Service
metadata:
name: sv-postgres-db-service
spec:
ports:
- name: postgres-db-port
port: 5432
targetPort: 5432
selector:
name: sv-postgres-db
type: NodePort

Back to top

SV Server deployment

To perform an SV Server deployment, you must create the following components:

SV Server Persistent Volume Claims

Create the following persistent volume claims:

kind: PersistentVolumeClaim
  apiVersion: v1
metadata:
name: sv-work-pvc
spec:
accessModes:
- ReadWriteOnce
selector:
matchLabels:
volume: pv0007
resources:
requests:
storage: 100k
volumeMode: Filesystem
kind: PersistentVolumeClaim
  apiVersion: v1
metadata:
name: sv-logs-pvc
spec:
accessModes:
- ReadWriteOnce
selector:
matchLabels:
volume: pv0008
resources:
requests:
storage: 20k
volumeMode: Filesystem

If OpenShift fails to map the claims to existing persistent volumes, change the volume names (pv0007 and pv0008 in the example) to address existing volumes. You may also create a new ones if no suitable unmapped volume exists.

SV Server Deployment Config

apiVersion: apps.openshift.io/v1
kind: DeploymentConfig
metadata:
name: sv-postgres-db
labels:
app: sv-postgres-db
spec:
selector:
name: sv-postgres-db
replicas: 1
template:
metadata:
labels:
name: sv-postgres-db
spec:
serviceAccountName: runasanyuid
securityContext:
type: RunAsAny
containers:
- name: sv-postgres-db
image: postgres
env:
- name: POSTGRES_PASSWORD
value: "postgres"
imagePullPolicy: Always
ports:
- containerPort: 5432
volumeMounts:
- name: postgres-data
mountPath: /var/lib/postgresql/data
readOnly: false
volumes:
- name: postgres-data
persistentVolumeClaim: claimName: postgres-db-pvc

Rollout the deployment config which should end with a pod running the SV Server.

SV Server Service

Create a service providing an access to SV Server:

apiVersion: v1
kind: Service
metadata:
name: sv-service
spec:
ports:
- name: sv-mgmt
port: 6085
targetPort: 6085
- name: sv-http-agent
port: 7000
targetPort: 7000
selector:
name: sv-server
type: NodePort

The SV Server is accessible at an external port assigned to the sv-service.

Back to top