{"id":23689770,"url":"https://github.com/bjnandi/self-hosted-github-actions-runner-in-kubernetes","last_synced_at":"2026-04-11T00:05:56.588Z","repository":{"id":270235525,"uuid":"909621175","full_name":"bjnandi/self-hosted-github-actions-runner-in-kubernetes","owner":"bjnandi","description":"Deploy a self-hosted GitHub Actions runner in a Kubernetes cluster to execute CI/CD workflows. The lab covers creating a custom Docker image for the runner, configuring Kubernetes deployments, and setting up GitHub Actions workflows for automated application deployment. By the end, you will deploy and verify an Nginx application in Kubernetes.","archived":false,"fork":false,"pushed_at":"2024-12-29T15:57:47.000Z","size":21,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-12-29T16:25:31.313Z","etag":null,"topics":["aws","cicd","cicd-pipeline","deployments","github","github-actions","k8s","kubernetes","nginx","runner","self-hosted","workflow"],"latest_commit_sha":null,"homepage":"","language":"Dockerfile","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/bjnandi.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":"2024-12-29T09:28:01.000Z","updated_at":"2024-12-29T15:57:51.000Z","dependencies_parsed_at":"2024-12-29T16:25:49.785Z","dependency_job_id":"6b2c1231-d7ea-419f-9ece-c7d3a6ab7d7e","html_url":"https://github.com/bjnandi/self-hosted-github-actions-runner-in-kubernetes","commit_stats":null,"previous_names":["bjnandi/self-hosted-github-actions-runner-in-kubernetes"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bjnandi%2Fself-hosted-github-actions-runner-in-kubernetes","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bjnandi%2Fself-hosted-github-actions-runner-in-kubernetes/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bjnandi%2Fself-hosted-github-actions-runner-in-kubernetes/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bjnandi%2Fself-hosted-github-actions-runner-in-kubernetes/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bjnandi","download_url":"https://codeload.github.com/bjnandi/self-hosted-github-actions-runner-in-kubernetes/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239753702,"owners_count":19691158,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":["aws","cicd","cicd-pipeline","deployments","github","github-actions","k8s","kubernetes","nginx","runner","self-hosted","workflow"],"created_at":"2024-12-30T01:39:17.839Z","updated_at":"2025-12-30T23:04:39.771Z","avatar_url":"https://github.com/bjnandi.png","language":"Dockerfile","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Self Hosted GitHub Actions Runner in Kubernetes\nDeploy a self-hosted GitHub Actions runner in a Kubernetes cluster to execute CI/CD workflows. The lab covers creating a custom Docker image for the runner, configuring Kubernetes deployments, and setting up GitHub Actions workflows for automated application deployment. By the end, you will deploy and verify an Nginx application in Kubernetes, leveraging the scalability.\n\nStep 1: Project Structure Setup\n- Create a new repository:\nGo to GitHub and create a new repository ( e.g., github-runner-k8s ) with a README.md file.\n- Clone the repository:\n```\ngit clone https://github.com/bjnandi/self-hosted-github-actions-runner-in-kubernetes\n```\n- Setup githubs default account:\n```\ngit config user.email \"\u003cyour-email\u003e\"\ngit config user.name \"\u003cYour Name\u003e\"\n```\n\nStep 2: Creating the Custom runner image\n- Create Directory for github-runner:\n```\ncd github-runner-k8s\n```\nStep 3: Entrypoint Script\n- Make the script executable:\n```\nchmod +x entrypoint.sh\n```\nStep 4: Build the docker image\n- Docker Build\n```\ndocker build \\\n  --build-arg RUNNER_VERSION=\"2.302.1\" \\\n  --build-arg GITHUB_PERSONAL_TOKEN=\"\u003cyour-personal-access-token\" \\\n  --build-arg GITHUB_OWNER=\"\u003cyour-github-username\u003e\" \\\n  --build-arg GITHUB_REPOSITORY=\"\u003cyour-github-repository-name\" \\\n  -t runner-image .\n```\nStep 5: Push the Image to DockerHub\n- Docker Login\n```\ndocker login\n```\n- Tag the Docker Image\n```\ndocker tag runner-image:latest bjnandi/self-hosted-github-actions-runner-in-a-kubernetes:latest\n```\n- Push the Image to DockerHub\n```\ndocker push bjnandi/self-hosted-github-actions-runner-in-a-kubernetes:latest\n```\nStep 6: Configure the self hosted runner in Kubernetes\n- Create a Kubernetes namespace:\n```\nkubectl create namespace host-runner\n```\n- Create secrets (replace placeholder values):\n```\nkubectl -n host-runner create secret generic github-secret \\\n  --from-literal=GITHUB_OWNER=\u003cyour-github-username\u003e \\\n  --from-literal=GITHUB_REPOSITORY=\u003cyour-repo-name\u003e \\\n  --from-literal=GITHUB_PERSONAL_TOKEN=\u003cyour-github-personal-access-token\u003e\n```\nStep 7: Deploying to Kubernetes\n- Apply the Kubernetes deployment:\n```\nkubectl apply -f github-runner.yaml -n host-runner\n```\n- Verify the deployment:\n```\nkubectl get pods -n host-runner\n```\nStep 8: Testing the Runner with Nginx Deployment\n- Add GitHub Repository Secrets\nEnsure the following secrets are added to your GitHub repository for secure handling:\n```\nDOCKER_REGISTRY: Docker registry name (e.g., Docker Hub username).\nDOCKER_USERNAME: Docker Hub username.\nDOCKER_PASSWORD: Docker Hub password.\nKUBE_CONFIG: Kubernetes configuration file.\n```\n\n- Kubernetes Configuration File\nTo get the KUBE_CONFIG file, you can use the following command:\n```\ncat /etc/rancher/k3s/k3s.yaml\n```\n- To get the master node ip, you can use the following command:\n```\nkubectl get nodes -o wide\n```\n\nStep 9: Verify the Workflow\n- Create a directory structure for the Nginx deployment files in your repository root directory.\n```\ncd ../nginx-deployment\n```\n- Commit and Push to Repository\nAfter creating the required files and configuration, commit and push all files to the main branch of your repository.\n```\ngit add --all\ngit commit -m \"cicd-k8s\"\ngit push\n```\n- Access the Application\nIn Poridhi's Kubernetes cluster verify the deploymets and services\n```\nkubectl get namespaces\n````\n- For successful deployment, you should see the dev namespace.\n```\nkubectl get deployments -n dev\n```\n- For successful deployment, you should see the nginx-deployment.\n```\nkubectl get services -n dev\n```\n- Now to access the application, you should get the etho ip of the master node and the nodeport of the service.\n\nTo get the eth0 ip of the master node, you can use the following command:\n```\nifconfig\n```\n- Access the Application:\n```\ncurl ip-address:30080\n```\n\nCongratulations!! You have successfully set up a self-hosted runner in Kubernetes and deployed an Nginx application using GitHub Actions. You have learned how to automate the Docker build, Kubernetes deployment, and service creation using GitHub workflows. By leveraging self-hosted runners, you can optimize resource usage and streamline CI/CD processes in Kubernetes environments.\n\nFor more Details:\nhttps://poridhi.io/lab-group-modules/676a65139561ceed0084a234/676a80c3b4d4aa86d481e56f\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbjnandi%2Fself-hosted-github-actions-runner-in-kubernetes","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbjnandi%2Fself-hosted-github-actions-runner-in-kubernetes","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbjnandi%2Fself-hosted-github-actions-runner-in-kubernetes/lists"}