acrlabs / simkube

Record-and-replay Kubernetes simulator based on KWOK
https://appliedcomputing.io/simkube
MIT License
232 stars 11 forks source link

If a pod requires a serviceaccount, the simulated pod won't run #129

Open drmorr0 opened 1 week ago

drmorr0 commented 1 week ago

Describe the bug

If a pod has the serviceAccount field set in the trace, then the simulated version of the pod won't run because the serviceAccount doesn't exist in the virtualized namespace.

Steps to reproduce

  1. Create a trace with a deployment like the following:
piVersion: apps/v1
kind: Deployment
metadata:
  name: nginx-deployment
  namespace: default
spec:
  selector:
    matchLabels:
      app: nginx
  replicas: 2 # tells deployment to run 2 pods matching the template
  template:
    metadata:
      labels:
        app: nginx
    spec:
      containers:
      - name: nginx
        image: nginx:1.14.2
        ports:
        - containerPort: 80
      serviceAccount: foobar
  1. Try to run the trace in SimKube
  2. The pods won't be scheduled, because of the following error:
Error creating: pods "nginx-deployment-6bdc77d84d-" is forbidden: error looking up service account default/foobar: serviceaccount "foobar" not found

Expected behavior

The pod should get scheduled in the simulated cluster.

Additional Info

Kubernetes Version: any Environment (kind, EKS, self-managed/hosted, etc.): any Affected components (sk-vnode, sk-cloudprov, sk-ctrl, sk-driver, skctl, sk-tracer): sk-driver

drmorr0 commented 1 week ago

You "should" be able to resolve this by including the serviceAccount object in the trace_config, but I'd like to have a solution that doesn't require that.