How can I choose a name for my application on OpenShift

6/18/2019

I deployed my application on Openshift using the commands:

oc project <projectname>

Then I navigate to my application's directory and use the command:

mvn fabric8:deploy -Popenshift

This deploys to Openshift perfectly.

The only problem is that it automatically names my application and I am not sure where it is getting the name from. I want to change it to [app-name]-test, [app-name]-dev, etc

So, where does it get the application name from and how can I change it?

-- monkey123
kubernetes
microservices
openshift

1 Answer

6/18/2019

It's usually in your fabric8 XML configuration (pom.xml). For example:

<configuration>
  <!-- Standard d-m-p configuration which defines how images are build, i.e. how the docker.tar is created -->
  <images>
    <image>
      <name>${image.user}/${project.artifactId}:${project.version}</name>
      <!-- "alias" is used to correlate to the containers in the pod spec -->
      <alias>camel-service</alias>
      <build>
        <from>fabric8/java</from>
        <assembly>
          <basedir>/deployments</basedir>
          <descriptorRef>artifact-with-dependencies</descriptorRef>
        </assembly>
        <env>
          <JAVA_LIB_DIR>/deployments</JAVA_LIB_DIR>
          <JAVA_MAIN_CLASS>org.apache.camel.cdi.Main</JAVA_MAIN_CLASS>
        </env>
      </build>
    </image>
  </images>
  <!-- resources to be created -->
  <resources>
    <!-- Labels that are applied to all created objects -->
    <labels>
      <group>quickstarts</group>
    </labels>
    <!-- Definition of the ReplicationController / ReplicaSet. Any better name than "containers" ? -->
    <deployment>
      <!-- Name of the replication controller, which will have a sane default (container alisa, mvn coords, ..) -->
      <!-- Override here -->
      <name>${project.artifactId}</name>
      ...

It defaults to ${project.artifactId} but you can override with whatever you'd like with something like ${project.artifactId}-dev. You can also edit the deployment manually in Kubernetes:

$ kubectl edit deployment ${project.artifactId}
-- Rico
Source: StackOverflow