{"id":952,"date":"2024-02-12T05:06:10","date_gmt":"2024-02-12T05:06:10","guid":{"rendered":"https:\/\/blog.ngocha.biz\/?p=952"},"modified":"2024-02-12T05:06:10","modified_gmt":"2024-02-12T05:06:10","slug":"github-actions-runner-aws-eks","status":"publish","type":"post","link":"https:\/\/blog.ngocha.biz\/?p=952","title":{"rendered":"How to Setup GitHub Actions Runner on AWS EKS Cluster (Self Hosted)"},"content":{"rendered":"<p>In this guide, I am going to show you how to set up a Github Actions self-hosted runner on the AWS EKS Cluster.<\/p>\n<h2 id=\"prerequisites\">Prerequisites<\/h2>\n<ol>\n<li>GitHub repository with access to create Personal Access Token (PAT)<\/li>\n<li>EKS Cluster<\/li>\n<li>Helm Installed in your system<\/li>\n<\/ol>\n<h2 id=\"configuring-runner-on-aws-eks-cluster\">Configuring Runner on AWS EKS Cluster<\/h2>\n<p>Follow the below steps to set up a self-hosted runner on EKS.<\/p>\n<h3 id=\"step-1-install-cert-manager-on-eks-cluster\">Step 1: Install Cert Manager on EKS Cluster<\/h3>\n<p>Run the below commands to install cert-manager on the EKS cluster using helm.<\/p>\n<pre><code>kubectl apply -f https:\/\/github.com\/cert-manager\/cert-manager\/releases\/download\/v1.13.2\/cert-manager.yaml<\/code><\/pre>\n<p>This command will install cert-manager on the <strong><code>cert-manager namespace<\/code><\/strong> as default.<\/p>\n<p>You can check if cert-manager is installed properly using the command below<\/p>\n<pre><code>kubectl get pods --namespace cert-manager<\/code><\/pre>\n<figure class=\"kg-card kg-image-card\"><img decoding=\"async\" src=\"https:\/\/storage.ghost.io\/c\/5f\/2f\/5f2f4d20-2abf-4534-8d40-7aa233aedd43\/content\/images\/2025\/03\/image-126-9.png\" class=\"kg-image\" alt=\"\" loading=\"lazy\" width=\"927\" height=\"264\" srcset=\"https:\/\/storage.ghost.io\/c\/5f\/2f\/5f2f4d20-2abf-4534-8d40-7aa233aedd43\/content\/images\/size\/w600\/2025\/03\/image-126-9.png 600w, https:\/\/storage.ghost.io\/c\/5f\/2f\/5f2f4d20-2abf-4534-8d40-7aa233aedd43\/content\/images\/2025\/03\/image-126-9.png 927w\" sizes=\"auto, (min-width: 720px) 720px\"><\/figure>\n<h3 id=\"step-2-create-authentication-token\">Step 2: Create Authentication Token<\/h3>\n<p>To authenticate the EKS cluster as a runner to GitHub Actions we are going to use the Personal Access Token (PAT) of GitHub.<\/p>\n<p>To create the token go to <strong><code>Settings-&gt;Developer settings-&gt;Personal access tokens<\/code><\/strong>, then select tokens and press the generate new token button as shown in the below image<\/p>\n<figure class=\"kg-card kg-image-card\"><img decoding=\"async\" src=\"https:\/\/storage.ghost.io\/c\/5f\/2f\/5f2f4d20-2abf-4534-8d40-7aa233aedd43\/content\/images\/2025\/03\/2023-11-24_12-31-25-1.png\" class=\"kg-image\" alt=\"\" loading=\"lazy\" width=\"1266\" height=\"632\" srcset=\"https:\/\/storage.ghost.io\/c\/5f\/2f\/5f2f4d20-2abf-4534-8d40-7aa233aedd43\/content\/images\/size\/w600\/2025\/03\/2023-11-24_12-31-25-1.png 600w, https:\/\/storage.ghost.io\/c\/5f\/2f\/5f2f4d20-2abf-4534-8d40-7aa233aedd43\/content\/images\/size\/w1000\/2025\/03\/2023-11-24_12-31-25-1.png 1000w, https:\/\/storage.ghost.io\/c\/5f\/2f\/5f2f4d20-2abf-4534-8d40-7aa233aedd43\/content\/images\/2025\/03\/2023-11-24_12-31-25-1.png 1266w\" sizes=\"auto, (min-width: 720px) 720px\"><\/figure>\n<p>Select Generate New token and a new page will open, give a name for your token and select the <strong><code>repo<\/code><\/strong> access as shown in the below image.<\/p>\n<figure class=\"kg-card kg-image-card\"><img decoding=\"async\" src=\"https:\/\/storage.ghost.io\/c\/5f\/2f\/5f2f4d20-2abf-4534-8d40-7aa233aedd43\/content\/images\/2025\/03\/2023-11-24_12-34-56-1.png\" class=\"kg-image\" alt=\"\" loading=\"lazy\" width=\"1382\" height=\"928\" srcset=\"https:\/\/storage.ghost.io\/c\/5f\/2f\/5f2f4d20-2abf-4534-8d40-7aa233aedd43\/content\/images\/size\/w600\/2025\/03\/2023-11-24_12-34-56-1.png 600w, https:\/\/storage.ghost.io\/c\/5f\/2f\/5f2f4d20-2abf-4534-8d40-7aa233aedd43\/content\/images\/size\/w1000\/2025\/03\/2023-11-24_12-34-56-1.png 1000w, https:\/\/storage.ghost.io\/c\/5f\/2f\/5f2f4d20-2abf-4534-8d40-7aa233aedd43\/content\/images\/2025\/03\/2023-11-24_12-34-56-1.png 1382w\" sizes=\"auto, (min-width: 720px) 720px\"><\/figure>\n<p>Now, generate the token by pressing the Generate token button at the bottom.<\/p>\n<p>Copy the access token and create a Kubernetes secret using the below command, the secret containing the access token will be used by the actions runner controller.<\/p>\n<p>Create a namespace and secret for actions-runner-controller using the command given below<\/p>\n<pre><code>kubectl create ns actions-runner-system\n\nkubectl create secret generic controller-manager -n actions-runner-system --from-literal=github_token=xxxxxxxxxxxxxxxxxx43rw<\/code><\/pre>\n<p>Make sure to specify your access token in the above command.<\/p>\n<h3 id=\"step-3-install-actions-runner-controller-arc-on-eks-cluster\">Step 3: Install Actions Runner Controller (ARC) on EKS Cluster<\/h3>\n<p>Actions Runner Controller is an operator of Kubernetes that manages the self-hosted runners of GitHub actions.<\/p>\n<p>It makes sure that the required resources to run a workflow in available by automatically deploying, scaling, and monitoring the runners on the cluster according to the needs.<\/p>\n<p>To install Actions Runner Controller on your EKS cluster run the following commands<\/p>\n<pre><code>helm repo add actions-runner-controller https:\/\/actions-runner-controller.github.io\/actions-runner-controller\n\nhelm repo update\n\nhelm upgrade --install --namespace actions-runner-system \\\n  --create-namespace --wait actions-runner-controller \\\n  actions-runner-controller\/actions-runner-controller \\\n  --set syncPeriod=1m<\/code><\/pre>\n<p>Once the installation is done, run the command given below to verify if the action runner controller is installed properly.<\/p>\n<pre><code>kubectl get all -n actions-runner-system<\/code><\/pre>\n<p>You will get the following output<\/p>\n<figure class=\"kg-card kg-image-card\"><img decoding=\"async\" src=\"https:\/\/storage.ghost.io\/c\/5f\/2f\/5f2f4d20-2abf-4534-8d40-7aa233aedd43\/content\/images\/2025\/03\/image-127-8.png\" class=\"kg-image\" alt=\"\" loading=\"lazy\" width=\"861\" height=\"540\" srcset=\"https:\/\/storage.ghost.io\/c\/5f\/2f\/5f2f4d20-2abf-4534-8d40-7aa233aedd43\/content\/images\/size\/w600\/2025\/03\/image-127-8.png 600w, https:\/\/storage.ghost.io\/c\/5f\/2f\/5f2f4d20-2abf-4534-8d40-7aa233aedd43\/content\/images\/2025\/03\/image-127-8.png 861w\" sizes=\"auto, (min-width: 720px) 720px\"><\/figure>\n<h3 id=\"step-4-deploy-runner\">Step 4: Deploy Runner<\/h3>\n<p>To deploy a self-hosted runner for GitHub Actions, create a YML file runner.yml and copy the below content<\/p>\n<pre><code>apiVersion: actions.summerwind.dev\/v1alpha1\nkind: RunnerDeployment\nmetadata:\n  name: k8s-action-runner\n  namespace: actions-runner-system\nspec:\n  replicas: 1\n  template:\n    spec:\n      repository: pet-clinic-project\/github-actions\n      labels:\n        - \"eks_runner\"<\/code><\/pre>\n<p>Make sure to replace the repository name and label of your runner.<\/p>\n<p>Run the below command to deploy the runner<\/p>\n<pre><code>kubectl create -f runner.yml<\/code><\/pre>\n<p>Check if the pod for the runner is created and running using the command<\/p>\n<pre><code>kubectl get pod -n actions-runner-system | grep -i \"k8s-action-runner\"<\/code><\/pre>\n<p>You will get the following output while running the above command<\/p>\n<figure class=\"kg-card kg-image-card\"><img decoding=\"async\" src=\"https:\/\/storage.ghost.io\/c\/5f\/2f\/5f2f4d20-2abf-4534-8d40-7aa233aedd43\/content\/images\/2025\/03\/image-132-8.png\" class=\"kg-image\" alt=\"\" loading=\"lazy\" width=\"861\" height=\"242\" srcset=\"https:\/\/storage.ghost.io\/c\/5f\/2f\/5f2f4d20-2abf-4534-8d40-7aa233aedd43\/content\/images\/size\/w600\/2025\/03\/image-132-8.png 600w, https:\/\/storage.ghost.io\/c\/5f\/2f\/5f2f4d20-2abf-4534-8d40-7aa233aedd43\/content\/images\/2025\/03\/image-132-8.png 861w\" sizes=\"auto, (min-width: 720px) 720px\"><\/figure>\n<p>Now you can see your runner has been registered on GitHub in <strong>Settings -&gt; Actions -&gt; Runners<\/strong> as shown below<\/p>\n<figure class=\"kg-card kg-image-card\"><img decoding=\"async\" src=\"https:\/\/storage.ghost.io\/c\/5f\/2f\/5f2f4d20-2abf-4534-8d40-7aa233aedd43\/content\/images\/2025\/03\/2023-11-23_15-18-46-1.png\" class=\"kg-image\" alt=\"\" loading=\"lazy\" width=\"1022\" height=\"592\" srcset=\"https:\/\/storage.ghost.io\/c\/5f\/2f\/5f2f4d20-2abf-4534-8d40-7aa233aedd43\/content\/images\/size\/w600\/2025\/03\/2023-11-23_15-18-46-1.png 600w, https:\/\/storage.ghost.io\/c\/5f\/2f\/5f2f4d20-2abf-4534-8d40-7aa233aedd43\/content\/images\/size\/w1000\/2025\/03\/2023-11-23_15-18-46-1.png 1000w, https:\/\/storage.ghost.io\/c\/5f\/2f\/5f2f4d20-2abf-4534-8d40-7aa233aedd43\/content\/images\/2025\/03\/2023-11-23_15-18-46-1.png 1022w\" sizes=\"auto, (min-width: 720px) 720px\"><\/figure>\n<h2 id=\"test-github-actions-workflow\">Test GitHub Actions Workflow<\/h2>\n<p>I am going to run the workflow with simple steps to check if the self-hosted runner is working properly. Create a YML file and your repository structure should be like given below<\/p>\n<pre><code>.\n\u251c\u2500\u2500 README.md\n\u2514\u2500\u2500 .github\n    \u2514\u2500\u2500 workflows\n        \u2514\u2500\u2500 test.yml<\/code><\/pre>\n<p>In GitHub Actions a YML file will be used to run the workflow which will be placed under the .github\/workflows directory as shown in the above structure. Copy the below contents and paste them into your YML file.<\/p>\n<pre><code>name: Testing\n\non:\n  push:\n    branches:\n      - main\n\njobs:\n  build:\n    runs-on: eks_runner\n    container:\n      image: ubuntu:latest\n    steps:\n    - name: Checkout Repository\n      uses: actions\/checkout@v2\n      with:\n        ref: main\n\n    - name: Echo Message\n      run: echo \"Hello World\"<\/code><\/pre>\n<p>This YML file is configured like the workflow gets triggered whenever a change is pushed to the main branch and runs the build job on your GitHub Actions self-hosted runner.<\/p>\n<p>Make sure to specify your runner&#8217;s name in the above YML file.<\/p>\n<p>After creating the YML file, push the changes to your repository that will trigger the workflow.<\/p>\n<p>You can see if the build process has started by going to your GitHub repository and selecting the Actions tab as given below.<\/p>\n<figure class=\"kg-card kg-image-card\"><img decoding=\"async\" src=\"https:\/\/storage.ghost.io\/c\/5f\/2f\/5f2f4d20-2abf-4534-8d40-7aa233aedd43\/content\/images\/2025\/03\/2023-11-23_15-48-35-1.png\" class=\"kg-image\" alt=\"\" loading=\"lazy\" width=\"1180\" height=\"638\" srcset=\"https:\/\/storage.ghost.io\/c\/5f\/2f\/5f2f4d20-2abf-4534-8d40-7aa233aedd43\/content\/images\/size\/w600\/2025\/03\/2023-11-23_15-48-35-1.png 600w, https:\/\/storage.ghost.io\/c\/5f\/2f\/5f2f4d20-2abf-4534-8d40-7aa233aedd43\/content\/images\/size\/w1000\/2025\/03\/2023-11-23_15-48-35-1.png 1000w, https:\/\/storage.ghost.io\/c\/5f\/2f\/5f2f4d20-2abf-4534-8d40-7aa233aedd43\/content\/images\/2025\/03\/2023-11-23_15-48-35-1.png 1180w\" sizes=\"auto, (min-width: 720px) 720px\"><\/figure>\n<p>Once your job has been finished, you can view the summary of the workflow as shown below.<\/p>\n<figure class=\"kg-card kg-image-card\"><img decoding=\"async\" src=\"https:\/\/storage.ghost.io\/c\/5f\/2f\/5f2f4d20-2abf-4534-8d40-7aa233aedd43\/content\/images\/2025\/03\/2023-11-23_15-50-07-1.png\" class=\"kg-image\" alt=\"\" loading=\"lazy\" width=\"1494\" height=\"888\" srcset=\"https:\/\/storage.ghost.io\/c\/5f\/2f\/5f2f4d20-2abf-4534-8d40-7aa233aedd43\/content\/images\/size\/w600\/2025\/03\/2023-11-23_15-50-07-1.png 600w, https:\/\/storage.ghost.io\/c\/5f\/2f\/5f2f4d20-2abf-4534-8d40-7aa233aedd43\/content\/images\/size\/w1000\/2025\/03\/2023-11-23_15-50-07-1.png 1000w, https:\/\/storage.ghost.io\/c\/5f\/2f\/5f2f4d20-2abf-4534-8d40-7aa233aedd43\/content\/images\/2025\/03\/2023-11-23_15-50-07-1.png 1494w\" sizes=\"auto, (min-width: 720px) 720px\"><\/figure>\n<hr>\n<p><strong>Ngu\u1ed3n:<\/strong> <a href=\"https:\/\/devopscube.com\/github-actions-runner-aws-eks\/\" target=\"_blank\" rel=\"noopener noreferrer\">How to Setup GitHub Actions Runner on AWS EKS Cluster (Self Hosted) \u2014 DevOpsCube<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Source: https:\/\/devopscube.com\/github-actions-runner-aws-eks\/<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-952","post","type-post","status-publish","format-standard","hentry","category-devops"],"_links":{"self":[{"href":"https:\/\/blog.ngocha.biz\/index.php?rest_route=\/wp\/v2\/posts\/952","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.ngocha.biz\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.ngocha.biz\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.ngocha.biz\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.ngocha.biz\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=952"}],"version-history":[{"count":0,"href":"https:\/\/blog.ngocha.biz\/index.php?rest_route=\/wp\/v2\/posts\/952\/revisions"}],"wp:attachment":[{"href":"https:\/\/blog.ngocha.biz\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=952"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.ngocha.biz\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=952"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.ngocha.biz\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=952"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}