Code Monkey home page Code Monkey logo

circleci-runner-k8s's Introduction

CircleCI has a new container runner in open preview, which will replace the self-hosted runner on Kubernetes solution detailed on this page.

CircleCI Runner on Kubernetes

Repository with various files to install CircleCI's runner on Kubernetes via Helm chart.

Prerequisites

  • Generate a token and resource class for your runner. For each different type of runner you want to run, you will need to repeat these same steps.
    • For example, if you want ten runners that pull the same types of jobs or run the same parallel job based on availability, you only need to create one runner resource class. All ten runners would share the same token.
    • If you want to run ten separate runners that pull different jobs that do different things, we recommend creating ten different runner resource classes. Each one would have a different name and use a different token, and you would a copy of this Helm chart for each type of runner resource.
  • Have a Kubernetes cluster (and nodes) you would like to install the runner pod(s) in.

Setup

  1. Clone this repository.
  2. Modify values as needed in values.yaml:
Value Description Default
image.repository
image.tag
You can extend a custom Docker image from the CircleCI default runner and use that instead.
For CircleCI Enterprise installations, see the compatible version tags here.
circleci/runner
launch-agent
replicaCount The number of replicas of this runner you want in your cluster. Must currently be set and updated manually. See pending work. 1
resourceClass The resource class you created for your runner. We recommend not inserting it into values.yaml directly and setting it when you install your chart instead. See next step. ""
runnerToken The token you created for your runner. We recommend not inserting it into values.yaml directly and setting it when you install your chart instead. See next step. ""
All other values Modify at your own discretion and risk. N/A
  1. Using the resource class name and token you created in the Prerequisites section, you'll want to set parameters as you install the Helm chart:
$ helm install "circleci-runner" ./ \
  --set runnerToken=$CIRCLECI_RUNNER_TOKEN \
  --set resourceClass=$CIRCLECI_RUNNER_RESOURCE_CLASS \
  --namespace your-namespace
  1. Call your runner class(es) in your job(s). Example:
version: 2.1

executors:
  my-runner:
    machine: true
    resource_class: my-namespace/my-runner-resource-class
  
workflows:
  my-workflow:
    jobs:
      - my-job

jobs:
  my-job:
    executor: my-runner
    steps:
      - checkout
      - run: echo "Hello from my custom runner!"

Set Environment Variables

Environment variables can be configured in env section of the values.yaml file. Environment variables can be used to further configure the CircleCI Runner using the environment variables described in the configuration reference page. It's also possible to add additional Kubernetes secret references (see example in env section of values.yaml.

Setup with Optional Secret Creation

There may be cases where you do not want Helm to create the Secret resource for you. One case would be if you were using a GitOps deployment tool such as ArgoCD or Flux. In these cases you would need to create a secret manually in the same namespace and cluster where the Helm managed runner resources will be deployed.

  1. Create the secret
$ kubectl create secret generic config-values \
  --namespace your-namespace \
  --from-literal resourceClass=$CIRCLECI_RUNNER_RESOURCE_CLASS \
  --from-literal runnerToken=$CIRCLECI_RUNNER_TOKEN
  1. Install the Helm chart
$ helm install "circleci-runner" ./ \
  --set configSecret.create=false \
  --namespace your-namespace

Setup with parametrized Service Account

There may be cases where a service account does not need to be created, or one already exists that should be reused. The values.yaml file can be modified to accommodate this scenario.

A new service account is created by default with the suggested values.yaml file. Setting the account name to circleci-runner. The serviceAccount.name value in values.yaml can be modified to a different name as required for deployment.

An existing service account can be reused by setting the serviceAccount.name parameter in the values.yaml file to the name of the existing account, and setting serviceAccount.create to false. This may be required when creating multiple helm releases from this chart.

More details about using and configuring a service account can be found in the Helm documentation.

Support Scope

  • Customers who modify the chart beyond values in values.yaml do so at their own risk. The type of support CircleCI provides for those customizations will be limited.

Reporting Issues

  • Customers are encouraged to open issues here to report bugs or problems, and open support tickets to receive specific help from support engineers.

Known Issues/Pending Work

  • Autoscaling is not yet implemented - for now, you'll need to manually modify the replicaCount in values.yaml and update the cluster and run:
$ helm upgrade "circleci-runner" ./ \
  --set runnerToken=$CIRCLECI_RUNNER_TOKEN \
  --set resourceClass=$CIRCLECI_RUNNER_RESOURCE_CLASS \
  --namespace your-namespace
  • Containers are not currently privileged, so you would not be able to execute privileged workloads (e.g., Docker in Docker).

circleci-runner-k8s's People

Contributors

christian-stephen avatar circlemossbot-public avatar jagnk avatar jrahme-cci avatar jrouly avatar kkowalski avatar kylecrawshaw avatar mat1g3r avatar mvxt avatar projectfrank avatar ranrubin avatar sebastian-lerner avatar stuart133 avatar wyardley avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.