how can i get logs of all the pods in my project as an openshift non-admin user?

6/25/2021

I want to create a helm chart for my users who wants to deploy there own logging stack in my PaaS, my api is pretty much exactly the same as openshift api, but i don't know how a user can deploy fluentd in there project and get all the logs of all the pods inside of that project.

-- tahacodes
fluentd
kubernetes
okd
openshift
paas

1 Answer

6/26/2021

To get the logs of all the pods inside a project, one could use a bash script:

#!/usr/bin/env bash
for p in $(oc get pods -n $1 | cut -f 1 -d ' ' | tail -n +2); do
    oc logs $p
done
  1. Save the code as pods-all-ns.sh
  2. Run the bash script using the command line providing the project name ./pods-all-ns.sh default

To get all the logs of all the pods of a deployment, one could a label selector oc logs -l service=logevents

-- Dhriti Shikhar
Source: StackOverflow