【问题标题】:How can I choose a name for my application on OpenShift如何在 OpenShift 上为我的应用程序选择名称
【发布时间】:2019-06-18 10:12:20
【问题描述】:

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

oc project <projectname>

然后我导航到我的应用程序目录并使用命令:

mvn fabric8:deploy -Popenshift

这完美地部署到 Openshift。

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

那么,它从哪里获取应用程序名称以及如何更改它?

【问题讨论】:

  • 您将在某个地方(可能在 fabric8:deploy 定义中)使用模板文件,这就是设置应用程序名称的地方。通过metadata.labels.app 设置作为一组已部署事物(部署或 pod 或其他)的应用程序

标签: kubernetes openshift microservices


【解决方案1】:

通常在您的 fabric8 XML 配置中 (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>
      ...

它默认为${project.artifactId},但您可以使用${project.artifactId}-dev 之类的任何内容覆盖。您还可以在 Kubernetes 中手动编辑部署:

$ kubectl edit deployment ${project.artifactId}

【讨论】:

    猜你喜欢
    • 2018-06-28
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-12-15
    • 1970-01-01
    • 1970-01-01
    • 2016-04-18
    相关资源
    最近更新 更多