Kubernetes 如何在OpenShift上为我的应用程序选择名称

Kubernetes 如何在OpenShift上为我的应用程序选择名称,kubernetes,openshift,microservices,Kubernetes,Openshift,Microservices,我使用以下命令在Openshift上部署了我的应用程序: oc project <projectname> 这将完美地部署到Openshift 唯一的问题是,它会自动命名我的应用程序,我不确定它是从哪里获得名称的。我想把它改成[app name]-test[app name]-dev等等 那么,它从哪里获得应用程序名称?我如何更改它?它通常在您的fabric8配置中(pom.xml)。例如: <configuration> <!-- Standard d-m-

我使用以下命令在Openshift上部署了我的应用程序:

oc project <projectname>
这将完美地部署到Openshift

唯一的问题是,它会自动命名我的应用程序,我不确定它是从哪里获得名称的。我想把它改成[app name]-test[app name]-dev等等


那么,它从哪里获得应用程序名称?我如何更改它?

它通常在您的fabric8配置中(
pom.xml
)。例如:

<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>
      ...

您将在某个地方(可能在fabric8:deploy定义中)使用一个模板文件,该文件就是设置应用程序名称的地方。通过
metadata.labels.app
<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>
      ...
$ kubectl edit deployment ${project.artifactId}