Curl failing in Kubernetes pod

6/23/2021

Having an issue with a pod post k8s upgrade on cluster. The pod wont come up cos its stuck trying to complete the init container

The init container does a curl against another pod and greps for a specific HTTP response

Command:
   sh
   -c
   while true; do
    echo "Waiting for prosody to become available..."
    sleep 1
    curl -s -i -k https://wad-0-mum-prosody:5281/xmpp-websocket/ | grep -q "HTTP/1.1 200 OK"
    [ $? -ne 0 ] || break
   done

The pod which it does the curl against is up and running and is accepting on port 5281. When I run the curl manually with grep and I get below

<!-- begin snippet: js hide: false console: true babel: false --><!-- language: lang-html -->
/ $ curl -s -i -k https://wad-0-mum-prosody:5281/xmpp-websocket/ | grep -q "HTTP/1.1 200 OK" / $ echo $? 1
<!-- end snippet -->

I didn't have this issue in the other clusters I upgraded recently so I am stumped.

-- DeirdreRodgers
curl
http
kubernetes

1 Answer

6/23/2021

I believe the initContainer here is supposed to be waiting for other Pod to come online. When it is UP, initContainer's job is done. Could you please try this code in your spec. It is doing the same thing, just in a different fashion.

initContainers:
      - name: init-container-name
        command: ['sh', '-c', 'while [ `curl -Lk --write-out "%{http_code}\n" --silent --output /dev/null "https://wad-0-mum-prosody:5281/xmpp-websocket"` -ne 200 ]; do sleep 2; done']
-- Nish
Source: StackOverflow