Kubernetes, configure startupProbe to read stdout logs - kubernetes

I have Java application running on kube and wanted to set startupProbe to look for 'tomcat started' text in java logs that are thrown to stdout; any ideas how to make that happen? I saw the documentation but there are only references to checking/curling some endpoint or running a command. Question is how can pod check its own logs
Also - I see that stdout logs are temporarily stored on /var/logs/containers directory (that is on NODE, not POD) so kinda not usefull.

In your question you are focused a bit more on the solution that the actual problem. So let's see how we can tackle the problem from different angle. This is the tomcat echo command that you are trying to base your probe on:
https://github.com/apache/tomcat/blob/0a2ee9b1ba7ded327c2aa2361cccff6a16cdef84/bin/catalina.sh#L506
As you can see this indeed tell you that Tomcat has started but it is not validating anything for you as the code continue to run. You will also notice that this output is not from the tomcat itself but from the script that launches tomcat.
Opened port on the other side is much better option to validate that the web server is up and running. Here's an example how this can be checked:
If you curl the tomcat port that is opened,the exit code would be 0 which will tell you that the server has started:
curl -s localhost:8080 > /dev/null
Here we are using echo $? to check the output from the previous command to validate it:
/usr/local/tomcat# echo $?
0
Moving forward, let's now make a test with the port that is not opened:
We are using the same way of checking it as in previous steps, the difference is just providing the different port (not opened):
/usr/local/tomcat# curl -s localhost:8010 > /dev/null
And then use echo $? to check the exit code of the command:
/usr/local/tomcat# echo $?
7
Alternative way described in this answer would be to query the Kubernetes API for pod logs:
GET /api/v1/namespaces/{namespace}/pods/{name}/log
Having said that, the best way of building things would be to have actual health check endpoint from you application.

Related

TCurl/Yab Command to check Cadence server health

I'm looking for a command-line tool to check the cadence server health. I've come across TCurl/Yab, but not able to figure out the exact command to run.
TCurl command to check for cadence server health is:
tcurl -p localhost:7933 cadence-frontend --health

starting Mock Server automatically when running restbird docker container

i want to use the "Mock Server" feature provided with https://restbird.org/ .
When starting restbird via the provided docker image, it listens on localhost:8080 by default.
Unfortunately the configured "Mock Server" instances still need to be started via the Web Frontend as it is described in the documentation here:
https://restbird.org/docs/mock-run.html#run-mock-server
Is there a way to automatically start the "Mock Server" instances when running the docker image without logging in into the backend (via admin/admin) and clicking the "start" button ?
Reason is, i want to start the mock server inside a gitlab pipeline where i have no further interaction possibilities after the container has been started.
I can not find anything like this in the documentation.
Thanks a lot for any clues - or if it is not possible i cam make a feature request.
I have found the solution myself. One can start a specific Mock Server as described in:
https://restbird.org/docs/API-MockServer.html#start-specific-mockserver-case
This can be scripted into my pipeline after executing the docker run command.

vtctlclient: command not found

I am trying to run Vitess on Minikube and I'm going through the 'Getting Started' steps found here: http://vitess.io/getting-started/#set-up-google-compute-engine-container-engine-and-cloud-tools
I have installed everything I need to including 'vtctlclient'. I have verified that all the correct directories were created when I did this.
However, there is a script in my directory '/go/src/github.com/youtube/vitess/examples/kubernetes' called 'kvtctl.sh' which uses kubectl to discover the pod name and set up the tunnel and then runs 'vtctlclient'. When I run this script, this is what is returned:
'Starting port forwarding to vtctld...
./kvtctl.sh: line 29: vtctlclient: command not found'
I am totally lost as to why the vtctlclient command is not found because I just installed it using Go.
Any help on this matter would be much appreciated.
Maybe the go install directory is not in your path. Have you tried running vtctlclient manually (just like kvtctl.sh does)?
PS: You may want to join our Vitess Slack channel where you may get more prompt answers for your questions. Let me know if you need an invite.

Proxy setting in gsutil tool

I use gsutil tool for download archives from Google Storage.
I use next CMD command:
python c:\gsutil\gsutil cp gs://pubsite_prod_rev_XXXXXXXXXXXXX/YYYYY/*.zip C:\Tmp\gs
Everything works fine, but if I try to run that command from corporate proxy, I receive error:
Caught socket error, retrying: [Errno 10051] A socket operation was attempted to an unreachable network
I tried several times to set the proxy settings in .boto file, but all to no avail.
Someone faced with such a problem?
Thanks!
Please see the section "I'm connecting through a proxy server, what do I need to do?" at https://developers.google.com/storage/docs/faq#troubleshooting
Basically, you need to configure the proxy settings in your .boto file, and you need to ensure that your proxy allows traffic to accounts.google.com as well as to *.storage.googleapis.com.
A change was just merged into github yesterday that fixes some of the proxy support. Please try it out, or specifically, overwrite this file with your current copy:
https://github.com/GoogleCloudPlatform/gsutil/blob/master/gslib/util.py
I believe I am having the same problem with the proxy settings being ignored under Linux (Ubuntu 12.04.4 LTS) and gsutils 4.2 (downloaded today).
I've been watching tcpdump on the host to confirm that gsutils is attempting to directly route to Google IPs instead of to my proxy server.
It seems that on the first execution of a simple command like "gsutil -d ls" it will use my proxy settings specified .boto for the first POST and then switch back to attempting to route directly to Google instead of my proxy server.
Then if I CTRL-C and re-run the exact same command, the proxy setting is no longer used at all. This difference in behaviour baffles me. If I wait long enough, I think it will work for the initial request again so this suggests some form on caching taking place. I'm not 100% of this behaviour yet because I haven't been able to predict when it occurs.
I also noticed that it always first tries to connect to 169.254.169.254 on port 80 regardless of proxy settings. A grep shows that it's hardcoded into oauth2_client.py, test_utils.py, layer1.py, and utils.py (under different subdirectories of the gsutils root).
I've tried setting the http_proxy environment variable but it appears that there is code that unsets this.

Force cURL to print 1 for failure, 0 for success?

I'm writing a Nagios plugin for a Mumble server in Perl (for the experience- plenty are already available), and I've already run into a brick wall. What I'd like to do is use cURL to connect to the port Mumble binds itself to- if the connection is successful I'd like cURL to simply print a 0, and if it failed, it should print a 1. Looking through the man page I'm unable to find any flags that could replicate that sort of behavior. Any ideas? Could this be done in a more elegant way, or with a different utility?
Why not use IO::Socket and check to see if you can connect that way? seems that that would be a touch more light weight than full on cURL.