我执行mvn fabric8:resource-apply
时收到此错误消息:
[错误]无法在项目tdev-wsec-service上执行目标io.fabric8:fabric8-maven-plugin:3.5.38:resource-apply(default-cli):无法从openshift.yml创建DeploymentConfig。 io.fabric8.kubernetes.client.KubernetesClientException:执行失败:POST位于https://minishift.t-systems.net:8443/apis/apps.openshift.io/v1/namespaces/myproject/deploymentconfigs。消息:DeploymentConfig“ tdev-wsec-service”无效:spec.template.spec.containers [0]。名称:无效值:“ com.tsystems.iberia-tdev-wsec-service”:DNS-1123标签必须包含小写字母数字字符或“-”,并且必须以字母数字字符开头和结尾(例如,“ my-name”或“ 123-abc”,用于验证的正则表达式为“ a-z0-9?”)。收到的状态:Status(apiVersion = v1,code = 422,details = StatusDetails(原因= [StatusCause(field = spec.template.spec.containers [0] .name,message = Invalid value:“ com.tsystems.iberia-tdev -wsec-service”:DNS-1123标签必须由小写字母数字字符或“-”组成,并且必须以字母数字字符开头和结尾(例如,“ my-name”或“ 123-abc”,用于验证为'a-z0-9?'),原因= FieldValueInvalid,additionalProperties = {})],组=空,kind = DeploymentConfig,名称= tdev-ws ...
简而言之:
DeploymentConfig“ tdev-wsec-service”无效:spec.template.spec.containers [0] .name:无效的值:“ com.tsystems.iberia-tdev-wsec-service”:必须有DNS-1123标签由小写字母数字字符或“-”组成,并且必须以字母数字字符开头和结尾(例如,“ my-name”或“ 123-abc”,用于验证的正则表达式为“ a-z0-9?”) / p>
我正在尝试将这些资源用于openshift:
fabric8插件抱怨某件事,我不太了解出什么问题。例如,fabric8插件告诉我部署配置内部有问题,但是wsec-deployment.yaml
的内容确实很简单:
metadata:
annotations:
configmap.fabric8.io/update-on-change: ${project.artifactId}
labels:
name: wsec
name: wsec
spec:
replicas: 1
selector:
name: wsec
version: ${project.version}
provider: fabric8
template:
metadata:
labels:
name: wsec
version: ${project.version}
provider: fabric8
spec:
containers:
- env:
- name: SPRING_APPLICATION_JSON
valueFrom:
configMapKeyRef:
name: wsec-configmap
key: SPRING_APPLICATION_JSON
name: wsec
image: ${docker.image}
有什么想法吗?
编辑
父pom.xml
与fabric8最相关的部分:
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.tsystems.iberia</groupId>
<artifactId>t-devhub</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>pom</packaging>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.0.1.RELEASE</version>
</parent>
<properties>
<java.version>1.8</java.version>
<spring-cloud.version>Finchley.RC1</spring-cloud.version>
<fabric8-maven-plugin.version>3.5.38</fabric8-maven-plugin.version>
<fabric8.build.strategy>docker</fabric8.build.strategy>
<fabric8.build.mode>openshift</fabric8.build.mode>
<docker.from>docker.io/fabric8/java-jboss-openjdk8-jdk:1.2</docker.from>
<docker.assemblyDescriptorRef>artifact</docker.assemblyDescriptorRef>
<docker.image>${project.artifactId}:${project.version}</docker.image>
</properties>
<build>
<plugins>
<plugin>
<groupId>io.fabric8</groupId>
<artifactId>fabric8-maven-plugin</artifactId>
<version>${fabric8-maven-plugin.version}</version>
<configuration>
<mode>${fabric8.build.mode}</mode>
<enricher>
<excludes>
<exclude>spring-boot-health-check</exclude>
</excludes>
</enricher>
<images>
<image>
<name>${docker.image}</name>
<build>
<from>${docker.from}</from>
<assembly>
<targetDir>/deployments</targetDir>
<descriptorRef>${docker.assemblyDescriptorRef}</descriptorRef>
</assembly>
<env>
<JAVA_APP_JAR>${project.artifactId}-${project.version}.jar</JAVA_APP_JAR>
</env>
</build>
<run>
<ports>
<port>8080:8080</port>
</ports>
</run>
</image>
</images>
</configuration>
</plugin>
</plugins>
</build>
</project>
答案 0 :(得分:0)
我发现arttifactId中的破折号(-)多于此。
<groupId>com.something</groupId>
<artifactId>servicename-microservice-something</artifactId>
<version>1.0</version>
<name>servicename</name>
将artifactId更改为
<artifactId>servicename</artifactId>
成功了。