{"id":19936402,"url":"https://github.com/adamrushuk/debug-k8s-pipeline","last_synced_at":"2026-04-13T05:50:43.784Z","repository":{"id":131173598,"uuid":"277244005","full_name":"adamrushuk/debug-k8s-pipeline","owner":"adamrushuk","description":"Interactive debugging within a Jenkins CI pipeline, running within Kubernetes","archived":false,"fork":false,"pushed_at":"2020-07-05T13:45:27.000Z","size":7,"stargazers_count":3,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2026-01-03T22:53:53.948Z","etag":null,"topics":["ansible","debug","jenkins","k8s","kubernetes","packer"],"latest_commit_sha":null,"homepage":"https://adamrushuk.github.io/interactive-debugging-within-a-jenkins-container-running-on-kubernetes/","language":"Shell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/adamrushuk.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-07-05T06:25:14.000Z","updated_at":"2023-03-05T09:06:06.000Z","dependencies_parsed_at":null,"dependency_job_id":"f0e7a670-5d39-400b-83ff-731367f96957","html_url":"https://github.com/adamrushuk/debug-k8s-pipeline","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/adamrushuk/debug-k8s-pipeline","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/adamrushuk%2Fdebug-k8s-pipeline","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/adamrushuk%2Fdebug-k8s-pipeline/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/adamrushuk%2Fdebug-k8s-pipeline/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/adamrushuk%2Fdebug-k8s-pipeline/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/adamrushuk","download_url":"https://codeload.github.com/adamrushuk/debug-k8s-pipeline/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/adamrushuk%2Fdebug-k8s-pipeline/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31741541,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-13T05:13:27.074Z","status":"ssl_error","status_checked_at":"2026-04-13T05:13:25.150Z","response_time":93,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ansible","debug","jenkins","k8s","kubernetes","packer"],"created_at":"2024-11-12T23:25:51.253Z","updated_at":"2026-04-13T05:50:43.742Z","avatar_url":"https://github.com/adamrushuk.png","language":"Shell","funding_links":[],"categories":[],"sub_categories":[],"readme":"# debug-k8s-pipeline\n\nCode examples for my\n[Interactive debugging within a Jenkins container running on Kubernetes](https://adamrushuk.github.io/interactive-debugging-within-a-jenkins-container-running-on-kubernetes/) blog post.\n\n## Demo Notes\n\n### Problem - Why debug within the pipeline?\n\nSeveral main issues:\n\n- Some pipelines (like Golden Images) could take an hour or more between builds:\n  - very slow to develop and troubleshoot\n- Couldn't debug within pipeline using standard methods:\n  - debugging individual scripts fine outside of the pipeline\n  - what if we need the full build environment?\n- Packer and Ansible dont allow interactive debugging within build container:\n  - no \"pause on error\" functionality\n  - need terminal session attached\n\n### Solution\n\nThe solution was to follow these steps:\n\n1. Install a terminal multiplexer (like `screen`) within the build container, which allowed sessions you can attach to.\n1. Use Packer's new `error-cleanup-provisioner` to pause the build.\n1. Connect to the build container within Kubernetes:\n   1. `kubectl exec --namespace jenkins -it \u003cpod_name\u003e -- /bin/sh`\n1. Attach to the screen session.\n1. Use an interactive debugger, like the Ansible playbook debugger.\n\n### Live Demo - Debugging within a Jenkins pipeline running on Kubernetes\n\n1. VSCode: `F1 \u003e Screencast Mode`\n1. Start Jenkins pipeline:  \n  *(This takes about 3 mins to spin up a build container and stop on error)*\n1. Discuss the problems / solution, whilst Jenkins job is running.\n1. Open the [Microsoft Kubernetes extension](https://marketplace.visualstudio.com/items?itemName=ms-kubernetes-tools.vscode-kubernetes-tools) view in VSCode and select `jenkins` namespace in `k8s-cluster` AKS cluster.\n1. Expand `Workloads \u003e Pods` and refresh view to see the Jenkins pod named `debug-k8s-pipeline...`.\n1. Right-click pod, select `Terminal`, then select the `builder` container from the drop-down list.\n1. Debug using commands within `/notes/debug_jenkins_container.sh`.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fadamrushuk%2Fdebug-k8s-pipeline","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fadamrushuk%2Fdebug-k8s-pipeline","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fadamrushuk%2Fdebug-k8s-pipeline/lists"}