I have an OpenShift/Tekton pipeline which in Task A
deploys an application to a test environment. In Task B
, the application's test suite is run. If all tests pass, then the application is deployed to another environment in Task C
.
The problem is that Task A
's pod is deployed (with oc apply -f <deployment>
), and before the pod is actually ready to receive requests, Task B
starts running the test suite, and all the tests fail (because it can't reach the endpoints defined in the test cases).
Is there an elegant way to make sure the pod from Task A
is ready to receive requests, before starting the execution of Task B
? One solution I have seen is to do HTTP GET requests against a health endpoint until you get a HTTP 200 response. We have quite a few applications which do not expose HTTP endpoints, so is there a more "generic" way to make sure the pod is ready? Can I for example query for a specific record in Task A
's log? There is a log statement which always shows when the pod is ready to receive traffic.
If it's of any interest, here is the definition for Task A
:
apiVersion: tekton.dev/v1beta1kind: Taskmetadata: name: create-and-deploy-integration-serverspec: 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