\n
The problem is in my pipeline I want to run curl
command to check if my nginx server is working properly once the image gets pulled and the pod STATUS is Running, but obviously if the image didn't get pulled yet curl will say connection refused because the container is not up yet.
How can I do that and is there a way to get the output of pulling images at least?
\n\n\nthe task runs the commands with && so the curl gets executed right after kubectl.
\n
\n\n","author":{"@type":"Person","name":"Affes Salem"},"upvoteCount":1,"answerCount":2,"acceptedAnswer":null}}Am working on a kind cluster with 3 control-plane nodes and 2 worker nodes.
\n
Reputation: 1649
I am currently building a CI/CD pipeline where I am trying to test a simple nginx deployment, the problem is when I run kubectl apply -f ./nginx-demplyment.yaml
I only get the output that resources got created/updated.
In my use case I the first thing i get is:
deployment.apps/nginx1.14.2 created
service/my-service created
And this is the output of kubectl get all
where pods STATUS
says ContainerCreating:
The problem is in my pipeline I want to run curl
command to check if my nginx server is working properly once the image gets pulled and the pod STATUS is Running, but obviously if the image didn't get pulled yet curl will say connection refused because the container is not up yet.
How can I do that and is there a way to get the output of pulling images at least?
the task runs the commands with && so the curl gets executed right after kubectl.
Am working on a kind cluster with 3 control-plane nodes and 2 worker nodes.
Upvotes: 1
Views: 1082
Reputation: 1649
I think there is a possible way to do that which is by downloading the images first then deploying Nginx.
minikube image load <image-name>
kind load docker-image nginx:1.14.2 --name k8s-cluster
once the image gets pulled next command curl
will work as wanted.
Upvotes: 0
Reputation: 35014
You can use kubectl wait
to wait for the deployment to be in a certain condition. Another option (or possibly used in combination) is to retry curl until the request returns a 200. An example of kubectl wait for your nginx deployment to become ready:
kubectl wait --for=condition=available deployment/nginx
Upvotes: 2