我有一个 OpenShift/Tekton 管道,用于Task A
将应用程序部署到测试环境。在Task B
中,运行应用程序的测试套件。如果所有测试都通过,则应用程序将部署到Task C
.
问题是Task A
的 pod 已部署(使用oc apply -f <deployment>
),并且在 pod 实际准备好接收请求之前,Task B
开始运行测试套件,并且所有测试都失败(因为它无法到达测试用例中定义的端点) .
在开始执行之前,是否有一种优雅的方法可以确保 podTask A
已准备好接收请求Task B
?我见过的一种解决方案是对健康端点执行 HTTP GET 请求,直到获得 HTTP 200 响应。我们有不少应用程序不公开 HTTP 端点,那么是否有更“通用”的方法来确保 pod 已准备好?例如,我可以查询日志中的特定记录Task A
吗?有一条日志语句始终显示 pod 何时准备好接收流量。
如果有任何兴趣,这里是 的定义Task A
:
apiVersion: tekton.dev/v1beta1
kind: Task
metadata:
name: create-and-deploy-integration-server
spec:
params:
- name: release-name
type: string
description: The release name of the application
- name: image-name
type: string
description: The name of the container image to use
- name: namespace
type: string
description: The namespace (OCP project) the application resides in
- name: commit-id
type: string
description: The commit hash identifier for the current HEAD commit
steps:
- name: create-is-manifest
image: image-registry.openshift-image-registry.svc:5000/openshift/origin-cli
script: |
echo "Creating IntegrationServer manifest"
cat << EOF > integrationserver.yaml
apiVersion: appconnect.ibm.com/v1beta1
kind: IntegrationServer
metadata:
name: $(params.release-name)
namespace: $(params.namespace)
spec:
license:
accept: true
license: L-KSBM-BZWEAT
use: CloudPakForIntegrationNonProduction
pod:
containers:
runtime:
image: image-registry.openshift-image-registry.svc:5000/$(params.namespace)/$(params.image-name)-$(params.commit-id)
imagePullPolicy: Always
resources:
limits:
cpu: 500m
memory: 500Mi
requests:
cpu: 300m
memory: 300Mi
adminServerSecure: true
router:
timeout: 120s
designerFlowsOperationMode: disabled
service:
endpointType: http
version: 11.0.0.11-r2
replicas: 1
barURL: ''
EOF
- name: deploy-is-manifest
image: image-registry.openshift-image-registry.svc:5000/openshift/origin-cli
script: |
echo "Applying IntegrationServer manifest to OpenShift cluster"
oc apply -f integrationserver.yaml