How to view logs of failed jobs with kubectl?












0














I've created a Kubernetes job that has now failed. Where can I find the logs to this job?



I'm not sure how to find the associated pod (I assume once the job fails it deletes the pod)?



Running kubectl describe job does not seem to show any relevant information:



Name:           app-raiden-migration-12-19-58-21-11-2018
Namespace: localdev
Selector: controller-uid=c2fd06be-ed87-11e8-8782-080027eeb8a0
Labels: jobType=database-migration
Annotations: kubectl.kubernetes.io/last-applied-configuration={"apiVersion":"batch/v1","kind":"Job","metadata":{"annotations":{},"labels":{"jobType":"database-migration"},"name":"app-raiden-migration-12-19-58-21-1...
Parallelism: 1
Completions: 1
Start Time: Wed, 21 Nov 2018 12:19:58 +0000
Pods Statuses: 0 Running / 0 Succeeded / 1 Failed
Pod Template:
Labels: controller-uid=c2fd06be-ed87-11e8-8782-080027eeb8a0
job-name=app-raiden-migration-12-19-58-21-11-2018
Containers:
app:
Image: pp3-raiden-app:latest
Port: <none>
Command:
php
artisan
migrate
Environment:
DB_HOST: local-mysql
DB_PORT: 3306
DB_DATABASE: raiden
DB_USERNAME: <set to the key 'username' in secret 'cloudsql-db-credentials'> Optional: false
DB_PASSWORD: <set to the key 'password' in secret 'cloudsql-db-credentials'> Optional: false
LOG_CHANNEL: stderr
APP_NAME: Laravel
APP_KEY: ABCDEF123ERD456EABCDEF123ERD456E
APP_URL: http://192.168.99.100
OAUTH_PRIVATE: <set to the key 'oauth_private.key' in secret 'laravel-oauth'> Optional: false
OAUTH_PUBLIC: <set to the key 'oauth_public.key' in secret 'laravel-oauth'> Optional: false
Mounts: <none>
Volumes: <none>
Events:
Type Reason Age From Message
---- ------ ---- ---- -------
Normal SuccessfulCreate 2m job-controller Created pod: app-raiden-migration-12-19-58-21-11-2018-pwnjn
Warning BackoffLimitExceeded 2m job-controller Job has reach the specified backoff limit









share|improve this question






















  • It seems your pod hasn't started yet. It's failing to start.
    – Shudipta Sharma
    Nov 21 '18 at 13:07
















0














I've created a Kubernetes job that has now failed. Where can I find the logs to this job?



I'm not sure how to find the associated pod (I assume once the job fails it deletes the pod)?



Running kubectl describe job does not seem to show any relevant information:



Name:           app-raiden-migration-12-19-58-21-11-2018
Namespace: localdev
Selector: controller-uid=c2fd06be-ed87-11e8-8782-080027eeb8a0
Labels: jobType=database-migration
Annotations: kubectl.kubernetes.io/last-applied-configuration={"apiVersion":"batch/v1","kind":"Job","metadata":{"annotations":{},"labels":{"jobType":"database-migration"},"name":"app-raiden-migration-12-19-58-21-1...
Parallelism: 1
Completions: 1
Start Time: Wed, 21 Nov 2018 12:19:58 +0000
Pods Statuses: 0 Running / 0 Succeeded / 1 Failed
Pod Template:
Labels: controller-uid=c2fd06be-ed87-11e8-8782-080027eeb8a0
job-name=app-raiden-migration-12-19-58-21-11-2018
Containers:
app:
Image: pp3-raiden-app:latest
Port: <none>
Command:
php
artisan
migrate
Environment:
DB_HOST: local-mysql
DB_PORT: 3306
DB_DATABASE: raiden
DB_USERNAME: <set to the key 'username' in secret 'cloudsql-db-credentials'> Optional: false
DB_PASSWORD: <set to the key 'password' in secret 'cloudsql-db-credentials'> Optional: false
LOG_CHANNEL: stderr
APP_NAME: Laravel
APP_KEY: ABCDEF123ERD456EABCDEF123ERD456E
APP_URL: http://192.168.99.100
OAUTH_PRIVATE: <set to the key 'oauth_private.key' in secret 'laravel-oauth'> Optional: false
OAUTH_PUBLIC: <set to the key 'oauth_public.key' in secret 'laravel-oauth'> Optional: false
Mounts: <none>
Volumes: <none>
Events:
Type Reason Age From Message
---- ------ ---- ---- -------
Normal SuccessfulCreate 2m job-controller Created pod: app-raiden-migration-12-19-58-21-11-2018-pwnjn
Warning BackoffLimitExceeded 2m job-controller Job has reach the specified backoff limit









share|improve this question






















  • It seems your pod hasn't started yet. It's failing to start.
    – Shudipta Sharma
    Nov 21 '18 at 13:07














0












0








0







I've created a Kubernetes job that has now failed. Where can I find the logs to this job?



I'm not sure how to find the associated pod (I assume once the job fails it deletes the pod)?



Running kubectl describe job does not seem to show any relevant information:



Name:           app-raiden-migration-12-19-58-21-11-2018
Namespace: localdev
Selector: controller-uid=c2fd06be-ed87-11e8-8782-080027eeb8a0
Labels: jobType=database-migration
Annotations: kubectl.kubernetes.io/last-applied-configuration={"apiVersion":"batch/v1","kind":"Job","metadata":{"annotations":{},"labels":{"jobType":"database-migration"},"name":"app-raiden-migration-12-19-58-21-1...
Parallelism: 1
Completions: 1
Start Time: Wed, 21 Nov 2018 12:19:58 +0000
Pods Statuses: 0 Running / 0 Succeeded / 1 Failed
Pod Template:
Labels: controller-uid=c2fd06be-ed87-11e8-8782-080027eeb8a0
job-name=app-raiden-migration-12-19-58-21-11-2018
Containers:
app:
Image: pp3-raiden-app:latest
Port: <none>
Command:
php
artisan
migrate
Environment:
DB_HOST: local-mysql
DB_PORT: 3306
DB_DATABASE: raiden
DB_USERNAME: <set to the key 'username' in secret 'cloudsql-db-credentials'> Optional: false
DB_PASSWORD: <set to the key 'password' in secret 'cloudsql-db-credentials'> Optional: false
LOG_CHANNEL: stderr
APP_NAME: Laravel
APP_KEY: ABCDEF123ERD456EABCDEF123ERD456E
APP_URL: http://192.168.99.100
OAUTH_PRIVATE: <set to the key 'oauth_private.key' in secret 'laravel-oauth'> Optional: false
OAUTH_PUBLIC: <set to the key 'oauth_public.key' in secret 'laravel-oauth'> Optional: false
Mounts: <none>
Volumes: <none>
Events:
Type Reason Age From Message
---- ------ ---- ---- -------
Normal SuccessfulCreate 2m job-controller Created pod: app-raiden-migration-12-19-58-21-11-2018-pwnjn
Warning BackoffLimitExceeded 2m job-controller Job has reach the specified backoff limit









share|improve this question













I've created a Kubernetes job that has now failed. Where can I find the logs to this job?



I'm not sure how to find the associated pod (I assume once the job fails it deletes the pod)?



Running kubectl describe job does not seem to show any relevant information:



Name:           app-raiden-migration-12-19-58-21-11-2018
Namespace: localdev
Selector: controller-uid=c2fd06be-ed87-11e8-8782-080027eeb8a0
Labels: jobType=database-migration
Annotations: kubectl.kubernetes.io/last-applied-configuration={"apiVersion":"batch/v1","kind":"Job","metadata":{"annotations":{},"labels":{"jobType":"database-migration"},"name":"app-raiden-migration-12-19-58-21-1...
Parallelism: 1
Completions: 1
Start Time: Wed, 21 Nov 2018 12:19:58 +0000
Pods Statuses: 0 Running / 0 Succeeded / 1 Failed
Pod Template:
Labels: controller-uid=c2fd06be-ed87-11e8-8782-080027eeb8a0
job-name=app-raiden-migration-12-19-58-21-11-2018
Containers:
app:
Image: pp3-raiden-app:latest
Port: <none>
Command:
php
artisan
migrate
Environment:
DB_HOST: local-mysql
DB_PORT: 3306
DB_DATABASE: raiden
DB_USERNAME: <set to the key 'username' in secret 'cloudsql-db-credentials'> Optional: false
DB_PASSWORD: <set to the key 'password' in secret 'cloudsql-db-credentials'> Optional: false
LOG_CHANNEL: stderr
APP_NAME: Laravel
APP_KEY: ABCDEF123ERD456EABCDEF123ERD456E
APP_URL: http://192.168.99.100
OAUTH_PRIVATE: <set to the key 'oauth_private.key' in secret 'laravel-oauth'> Optional: false
OAUTH_PUBLIC: <set to the key 'oauth_public.key' in secret 'laravel-oauth'> Optional: false
Mounts: <none>
Volumes: <none>
Events:
Type Reason Age From Message
---- ------ ---- ---- -------
Normal SuccessfulCreate 2m job-controller Created pod: app-raiden-migration-12-19-58-21-11-2018-pwnjn
Warning BackoffLimitExceeded 2m job-controller Job has reach the specified backoff limit






kubernetes kubectl






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Nov 21 '18 at 12:23









Chris Stryczynski

3,74252961




3,74252961












  • It seems your pod hasn't started yet. It's failing to start.
    – Shudipta Sharma
    Nov 21 '18 at 13:07


















  • It seems your pod hasn't started yet. It's failing to start.
    – Shudipta Sharma
    Nov 21 '18 at 13:07
















It seems your pod hasn't started yet. It's failing to start.
– Shudipta Sharma
Nov 21 '18 at 13:07




It seems your pod hasn't started yet. It's failing to start.
– Shudipta Sharma
Nov 21 '18 at 13:07












2 Answers
2






active

oldest

votes


















1














kubectl get pods -a



And then a pod will be shown like below:



app-raiden-migration-12-19-58-21-11-2018-pwnjn 0/1 Error 0 6m






share|improve this answer





























    0














    You can get the pods of this job by running:



    kubectl get pods --selector=job-name=app-raiden-migration-12-19-58-21-11-2018


    but in this case i think you won't find any pods because no pod is created, and as mentioned in this link: Job Termination and Cleanup, pods are not deleted after jobs completion.
    But still i don't know how you can find out why that pod failed to run (but if there is a pod and you could find it, you can find the logs of that pod). I had the same mistake and i ran the job again and job worked successfully.



    EDIT:



    I just see the events of your job, your job has made pod and you can see the logs of your pod by your pod name as I mentioned above.






    share|improve this answer























      Your Answer






      StackExchange.ifUsing("editor", function () {
      StackExchange.using("externalEditor", function () {
      StackExchange.using("snippets", function () {
      StackExchange.snippets.init();
      });
      });
      }, "code-snippets");

      StackExchange.ready(function() {
      var channelOptions = {
      tags: "".split(" "),
      id: "1"
      };
      initTagRenderer("".split(" "), "".split(" "), channelOptions);

      StackExchange.using("externalEditor", function() {
      // Have to fire editor after snippets, if snippets enabled
      if (StackExchange.settings.snippets.snippetsEnabled) {
      StackExchange.using("snippets", function() {
      createEditor();
      });
      }
      else {
      createEditor();
      }
      });

      function createEditor() {
      StackExchange.prepareEditor({
      heartbeatType: 'answer',
      autoActivateHeartbeat: false,
      convertImagesToLinks: true,
      noModals: true,
      showLowRepImageUploadWarning: true,
      reputationToPostImages: 10,
      bindNavPrevention: true,
      postfix: "",
      imageUploader: {
      brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
      contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
      allowUrls: true
      },
      onDemand: true,
      discardSelector: ".discard-answer"
      ,immediatelyShowMarkdownHelp:true
      });


      }
      });














      draft saved

      draft discarded


















      StackExchange.ready(
      function () {
      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53411958%2fhow-to-view-logs-of-failed-jobs-with-kubectl%23new-answer', 'question_page');
      }
      );

      Post as a guest















      Required, but never shown

























      2 Answers
      2






      active

      oldest

      votes








      2 Answers
      2






      active

      oldest

      votes









      active

      oldest

      votes






      active

      oldest

      votes









      1














      kubectl get pods -a



      And then a pod will be shown like below:



      app-raiden-migration-12-19-58-21-11-2018-pwnjn 0/1 Error 0 6m






      share|improve this answer


























        1














        kubectl get pods -a



        And then a pod will be shown like below:



        app-raiden-migration-12-19-58-21-11-2018-pwnjn 0/1 Error 0 6m






        share|improve this answer
























          1












          1








          1






          kubectl get pods -a



          And then a pod will be shown like below:



          app-raiden-migration-12-19-58-21-11-2018-pwnjn 0/1 Error 0 6m






          share|improve this answer












          kubectl get pods -a



          And then a pod will be shown like below:



          app-raiden-migration-12-19-58-21-11-2018-pwnjn 0/1 Error 0 6m







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Nov 21 '18 at 12:27









          Chris Stryczynski

          3,74252961




          3,74252961

























              0














              You can get the pods of this job by running:



              kubectl get pods --selector=job-name=app-raiden-migration-12-19-58-21-11-2018


              but in this case i think you won't find any pods because no pod is created, and as mentioned in this link: Job Termination and Cleanup, pods are not deleted after jobs completion.
              But still i don't know how you can find out why that pod failed to run (but if there is a pod and you could find it, you can find the logs of that pod). I had the same mistake and i ran the job again and job worked successfully.



              EDIT:



              I just see the events of your job, your job has made pod and you can see the logs of your pod by your pod name as I mentioned above.






              share|improve this answer




























                0














                You can get the pods of this job by running:



                kubectl get pods --selector=job-name=app-raiden-migration-12-19-58-21-11-2018


                but in this case i think you won't find any pods because no pod is created, and as mentioned in this link: Job Termination and Cleanup, pods are not deleted after jobs completion.
                But still i don't know how you can find out why that pod failed to run (but if there is a pod and you could find it, you can find the logs of that pod). I had the same mistake and i ran the job again and job worked successfully.



                EDIT:



                I just see the events of your job, your job has made pod and you can see the logs of your pod by your pod name as I mentioned above.






                share|improve this answer


























                  0












                  0








                  0






                  You can get the pods of this job by running:



                  kubectl get pods --selector=job-name=app-raiden-migration-12-19-58-21-11-2018


                  but in this case i think you won't find any pods because no pod is created, and as mentioned in this link: Job Termination and Cleanup, pods are not deleted after jobs completion.
                  But still i don't know how you can find out why that pod failed to run (but if there is a pod and you could find it, you can find the logs of that pod). I had the same mistake and i ran the job again and job worked successfully.



                  EDIT:



                  I just see the events of your job, your job has made pod and you can see the logs of your pod by your pod name as I mentioned above.






                  share|improve this answer














                  You can get the pods of this job by running:



                  kubectl get pods --selector=job-name=app-raiden-migration-12-19-58-21-11-2018


                  but in this case i think you won't find any pods because no pod is created, and as mentioned in this link: Job Termination and Cleanup, pods are not deleted after jobs completion.
                  But still i don't know how you can find out why that pod failed to run (but if there is a pod and you could find it, you can find the logs of that pod). I had the same mistake and i ran the job again and job worked successfully.



                  EDIT:



                  I just see the events of your job, your job has made pod and you can see the logs of your pod by your pod name as I mentioned above.







                  share|improve this answer














                  share|improve this answer



                  share|improve this answer








                  edited Dec 30 '18 at 11:52

























                  answered Dec 30 '18 at 11:10









                  mahdi1008

                  13




                  13






























                      draft saved

                      draft discarded




















































                      Thanks for contributing an answer to Stack Overflow!


                      • Please be sure to answer the question. Provide details and share your research!

                      But avoid



                      • Asking for help, clarification, or responding to other answers.

                      • Making statements based on opinion; back them up with references or personal experience.


                      To learn more, see our tips on writing great answers.





                      Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


                      Please pay close attention to the following guidance:


                      • Please be sure to answer the question. Provide details and share your research!

                      But avoid



                      • Asking for help, clarification, or responding to other answers.

                      • Making statements based on opinion; back them up with references or personal experience.


                      To learn more, see our tips on writing great answers.




                      draft saved


                      draft discarded














                      StackExchange.ready(
                      function () {
                      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53411958%2fhow-to-view-logs-of-failed-jobs-with-kubectl%23new-answer', 'question_page');
                      }
                      );

                      Post as a guest















                      Required, but never shown





















































                      Required, but never shown














                      Required, but never shown












                      Required, but never shown







                      Required, but never shown

































                      Required, but never shown














                      Required, but never shown












                      Required, but never shown







                      Required, but never shown







                      Popular posts from this blog

                      Wiesbaden

                      Marschland

                      Dieringhausen