我正在Deployment.yml中使用initContainers,并使用fabric8-maven-plugin将应用程序部署到openshift中。
deployment.yml中的initContainers代码段
spec:
template:
spec:
volumes:
- emptyDir: {}
name: work-dir
containers:
- name: hello-world
resources:
requests:
cpu: "0.2"
# memory: 256Mi
limits:
cpu: "1.0"
# memory: 256Mi
volumeMounts:
- mountPath: /var/work-dir
name: work-dir
initContainers:
- args:
- -c
command:
- /bin/bash
image: docker-registry.default.svc:5000/openshift/rhel-openssl-keytool
imagePullPolicy: Always
name: init-hello-world
resources: {}
terminationMessagePath: /dev/termination-log
terminationMessagePolicy: File
volumeMounts:
- mountPath: /var/work-dir
name: work-dir
f-m-p生成的openshift.yml将livenessProbe和readinessProbe添加到initContainers中,这是无效的。 生成的DC:
initContainers:
- args:
- -c
command:
- /bin/bash
image: docker-registry.default.svc:5000/openshift/rhel-openssl-keytool
imagePullPolicy: Always
livenessProbe:
httpGet:
path: /health
port: 8080
scheme: HTTP
initialDelaySeconds: 180
name: init-hello-world
readinessProbe:
httpGet:
path: /health
port: 8080
scheme: HTTP
initialDelaySeconds: 10
resources: {}
terminationMessagePath: /dev/termination-log
terminationMessagePolicy: File
volumeMounts:
- mountPath: /var/work-dir
name: work-dir
部署(mvn fabric8:deploy
)失败,并出现“ io.fabric8.kubernetes.client.KubernetesClientException spec.template.spec.initContainers [0] .livenessProbe:无效值:” < / p>
[INFO] Updating DeploymentConfig from openshift.yml
[ERROR] Failed to update DeploymentConfig from openshift.yml. io.fabric8.kubernetes.client.KubernetesClientException: Failure executing: PUT at: https
://openshifthost.com/deploymentconfigs/sample-project. Message: Deployment
Config "sample-project" is invalid: [spec.template.spec.initContainers[0].livenessProbe: Invalid value: api.Probe{Handler:api.Handler{Ex
ec:(*api.ExecAction)(nil), HTTPGet:(*api.HTTPGetAction)(0xc4459a7340), TCPSocket:(*api.TCPSocketAction)(nil)}, InitialDelaySeconds:180, TimeoutSeconds
:1, PeriodSeconds:10, SuccessThreshold:1, FailureThreshold:3}: must not be set for init containers, spec.template.spec.initContainers[0].readinessProb
e: Invalid value: api.Probe{Handler:api.Handler{Exec:(*api.ExecAction)(nil), HTTPGet:(*api.HTTPGetAction)(0xc4459a7b90), TCPSocket:(*api.TCPSocketActi
on)(nil)}, InitialDelaySeconds:10, TimeoutSeconds:1, PeriodSeconds:10, SuccessThreshold:1, FailureThreshold:3}: must not be set for init containers].
Received status: Status(apiVersion=v1, code=422, details=StatusDetails(causes=[StatusCause(field=spec.template.spec.initContainers[0].livenessProbe, m
essage=Invalid value: api.Probe{Handler:api.Handler{Exec:(*api.ExecAction)(nil), HTTPGet:(*api.HTTPGetAction)(0xc4459a7340), TCPSocket:(*api.TCPSocket
Action)(nil)}, InitialDelaySeconds:180, TimeoutSeconds:1, PeriodSeconds:10, SuccessThreshold:1, FailureThreshold:3}: must not be set for init containe
rs, reason=FieldValueInvalid, additionalProperties={}), StatusCause(field=spec.template.spec.initContainers[0].readinessProbe, message=Invalid value:
api.Probe{Handler:api.Handler{Exec:(*api.ExecAction)(nil), HTTPGet:(*api.HTTPGetAction)(0xc4459a7b90), TCPSocket:(*api.TCPSocketAction)(nil)}, Initial
DelaySeconds:10, TimeoutSeconds:1, PeriodSeconds:10, SuccessThreshold:1, FailureThreshold:3}: must not be set for init containers, reason=FieldValueIn
valid, additionalProperties={})], group=null, kind=DeploymentConfig, name=sample-project, retryAfterSeconds=null, uid=null, additionalPr
operties={}), kind=Status, message=DeploymentConfig "sample-project" is invalid: [spec.template.spec.initContainers[0].livenessProbe: In
valid value: api.Probe{Handler:api.Handler{Exec:(*api.ExecAction)(nil),
我相信initContainer不应包含livenessProbe和readinessProbe,因为它将在应用程序容器之前结束,不确定f-m-p为何会生成它。我是否缺少某些配置,或者这是fabric8-maven-plugin的错误吗?
使用的 fabric8.maven.plugin.version 版本- 3.5.33.fuse-000067-redhat-1 。
注意:从openshift.yml中删除initcontainers的livnessProbe和readinessProbe并应用资源(mvn fabric8:apply
)成功。