Skip to content

Ability to share service account from runner pod to job pod in Kubernetes mode #2754

Closed

Description

@veronicatjan

What would you like added?

We're installing ARC on EKS cluster, then set up IRSA to grant permission to a service account.
We need a way to let job pod use the same service account as the runner pod, so that they have the same permission.

I saw this solution #798 , but it is no longer working due to Error: Volume mounts outside of the work folder are not supported

Why is this needed?

The runner will be used to build image then push to our private ECR registry. We were able to configure the runner pod to use the right service account with ECR push permission, but the workflow job pod that runs the actual job is using default service account that doesn't have ECR push permission.

Additional context

Manifests:

apiVersion: v1
kind: ServiceAccount
metadata:
  namespace: default
  name: kubernetes-runner
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
  name: kubernetes-runner-role
rules:
- apiGroups: [""]
  resources: ["pods"]
  verbs: ["get", "list", "create", "delete"]
- apiGroups: [""]
  resources: ["pods/exec"]
  verbs: ["get", "create"]
- apiGroups: [""]
  resources: ["pods/log"]
  verbs: ["get", "list", "watch",]
- apiGroups: ["batch"]
  resources: ["jobs"]
  verbs: ["get", "list", "create", "delete"]
- apiGroups: [""]
  resources: ["secrets"]
  verbs: ["get", "list", "create", "delete"]
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
  name: kubernetes-runner-rolebinding
roleRef:
  apiGroup: rbac.authorization.k8s.io
  kind: ClusterRole
  name: kubernetes-runner-role
subjects:
- kind: ServiceAccount
  name: kubernetes-runner
  namespace: default
---
apiVersion: actions.summerwind.dev/v1alpha1
kind: RunnerDeployment
metadata:
  name: nonprivileged-runners
spec:
  template:
    spec:
       securityContext:
         # For Ubuntu 20.04 runner
         fsGroup: 1000
      containerMode: kubernetes
      serviceAccountName: kubernetes-runner
      workVolumeClaimTemplate:
        storageClassName: "gp2"
        accessModes:
        - ReadWriteOnce
        resources:
          requests:
            storage: 2Gi
      labels:
        - eks
        - teamsvcs
        - kaniko
      repository: infra/runner-test
---
apiVersion: actions.summerwind.dev/v1alpha1
kind: HorizontalRunnerAutoscaler
metadata:
  name: nonprivileged-runners-autoscaler
spec:
  scaleTargetRef:
    kind: RunnerDeployment
    name: nonprivileged-runners
  minReplicas: 1
  maxReplicas: 10
  metrics:
  - type: TotalNumberOfQueuedAndInProgressWorkflowRuns
    repositoryNames:
    - infra/runner-test

Activity

  1. added
    enhancement
    needs triage
    on Jul 19, 2023
  2. github-actions commented on Jul 19, 2023

    @github-actions
    Contributor

    Hello! Thank you for filing an issue.

    The maintainers will triage your issue shortly.

    In the meantime, please take a look at the troubleshooting guide for bug reports.

    If this is a feature request, please review our contribution guidelines.

  3. changed the title [-]Ability to use IRSA IAM role within a workflow job pod in Kubernetes mode[/-] [+]Ability to use EKS IRSA IAM role within a workflow job pod in Kubernetes mode[/+] on Jul 19, 2023
  4. changed the title [-]Ability to use EKS IRSA IAM role within a workflow job pod in Kubernetes mode[/-] [+]Ability to share service account from runner pod to job pod in Kubernetes mode[/+] on Jul 20, 2023
  5. veronicatjan commented on Jul 21, 2023

    @veronicatjan
    Author

    I'm able to achieve this goal by using this runner-container-hooks. actions/runner-container-hooks#50

  6. gustoliv commented on Aug 31, 2023

    @gustoliv

    @veronicatjan could you give me an example of this configuration, please?

  7. johnjeffers commented on Oct 15, 2023

    @johnjeffers

    @veronicatjan can you please post an example of how you fixed this?

  8. johnjeffers commented on Oct 16, 2023

    @johnjeffers

    If anyone else comes across this thread looking for the solution, here you go: #2992 (comment)

  9. igor9silva commented on Jan 4, 2024

    @igor9silva

    Thank you @johnjeffers!!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementneeds triage

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions