6. Add project in Openshift

6.5. Add Service

The jenkins task added a service.yaml dc.yaml in .openshift/resource.

You can use the service template of Middelware to build your service.yaml.

This service has 

  • a name
  • a namespace : the openshift project
  • the port for the internal and the external
  • a reference to the deployment config

For this exercise, I give you the content of this file. You must only change [userid].

apiVersion: v1

kind: Service

metadata:

  name: trainings-hello[userId]

  #Set here the project name previously created by Server Team

  namespace: socsec-test-trainings

spec:

  selector:

  #Set here the deployment config name created in dc.yaml

    deploymentconfig: trainings-hello[userId]

  ports:

  - nodePort: 0

  #Set here the port that you want to be exposed by the service

    port: 80

    protocol: TCP

    #Set here the port exposed by the Docker container

    targetPort: 8080

This file describe the service of your project. The project is deployed on socsec-sda-1, use the deployment config trainings-hello[userid] and the port.

Here is the result in the console : 

Openshift2