Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't integrate rocks to securityContext.runAsNonRoot: true #243

Open
misohu opened this issue Nov 12, 2024 · 3 comments
Open

Can't integrate rocks to securityContext.runAsNonRoot: true #243

misohu opened this issue Nov 12, 2024 · 3 comments
Labels
bug Something isn't working

Comments

@misohu
Copy link
Member

misohu commented Nov 12, 2024

Bug Description

While working on net-istio-webhook extension rock for knative we had encountered a problem where we can't run rocks in securityContext.runAsNonRoot: true Kubernetes deployment.

Rocks like net-istio-webhook are deployed as part of KnativeServing CR.

This is how securityContext for the webhook deployment looks like.

...
securityContext:
  allowPrivilegeEscalation: false
  capabilities:
    drop:
    - ALL
  runAsNonRoot: true
  seccompProfile:
    type: RuntimeDefault
terminationMessagePath: /dev/termination-log
terminationMessagePolicy: File
...

This problem is known problem in rockcraft project tracked here: canonical/rockcraft#659

To Reproduce

Use (or build) the rock presented in this PR.

Use the rock in the config file for knative-serving. One way to do it is just change the linked field in the config before deploying. Simplest way is to run bundle integration test from the root folder of knative-operators.

tox -e integration -- --model kubeflow --keep-models -vv -s

After some time the test should be green. After that you can check the pods in the knnative-serving namespace

kubectl get po -n knative-serving

The pod for net-istio-webhook is in ConfigurationError state. You can inspect the events of the pod

kubectl describe pod net-istio-webhook-<pod-id> -n knative-serving

You should see simillar error message.

Events:
  Type     Reason     Age               From               Message
  ----     ------     ----              ----               -------
  Normal   Scheduled  32s               default-scheduler  Successfully assigned knative-serving/net-istio-webhook-86cddb56c6-b89bl to hyrule
  Normal   Pulling    32s               kubelet            Pulling image "misohu/net-istio-webhook:1.12.12"
  Normal   Pulled     28s               kubelet            Successfully pulled image "misohu/net-istio-webhook:1.12.12" in 3.804s (3.804s including waiting)
  Warning  Failed     5s (x4 over 28s)  kubelet            Error: container has runAsNonRoot and image has non-numeric user (_daemon_), cannot verify user is non-root (pod: "net-istio-webhook-86cddb56c6-b89bl_knative-serving(7ceb92aa-cd32-49e8-9fb0-a83b1987779d)", container: webhook)
  Normal   Pulled     5s (x3 over 27s)  kubelet            Container image "misohu/net-istio-webhook:1.12.12" already present on machine

Environment

Juju: 3.4.5
Kubernetes: 1.29

Relevant Log Output

Events:
  Type     Reason     Age               From               Message
  ----     ------     ----              ----               -------
  Normal   Scheduled  32s               default-scheduler  Successfully assigned knative-serving/net-istio-webhook-86cddb56c6-b89bl to hyrule
  Normal   Pulling    32s               kubelet            Pulling image "misohu/net-istio-webhook:1.12.12"
  Normal   Pulled     28s               kubelet            Successfully pulled image "misohu/net-istio-webhook:1.12.12" in 3.804s (3.804s including waiting)
  Warning  Failed     5s (x4 over 28s)  kubelet            Error: container has runAsNonRoot and image has non-numeric user (_daemon_), cannot verify user is non-root (pod: "net-istio-webhook-86cddb56c6-b89bl_knative-serving(7ceb92aa-cd32-49e8-9fb0-a83b1987779d)", container: webhook)
  Normal   Pulled     5s (x3 over 27s)  kubelet            Container image "misohu/net-istio-webhook:1.12.12" already present on machine

Additional Context

No response

@misohu misohu added the bug Something isn't working label Nov 12, 2024
Copy link

Thank you for reporting us your feedback!

The internal ticket has been created: https://warthogs.atlassian.net/browse/KF-6537.

This message was autogenerated

@misohu
Copy link
Member Author

misohu commented Nov 12, 2024

I have also explored the option to disable the runAsNonRoot option for net-istio-weebhook deployment in KnativeServing CR by adding the:

workloads:
    - name: net-istio-webhook
      podSpec:
        securityContext:
          runAsUser: 0

Sadly this option is not supported for net-istio workloads.

@mvlassis
Copy link
Contributor

I encounter the same issue while integrating the net-istio-controller rock, see the logs:

Events:
  Type     Reason     Age                From               Message
  ----     ------     ----               ----               -------
  Normal   Scheduled  73s                default-scheduler  Successfully assigned knative-serving/net-istio-controller-5896777f8b-pkjcx to dev
  Normal   Pulling    73s                kubelet            Pulling image "mvlassis/net-istio-controller:v1.12.3"
  Normal   Pulled     68s                kubelet            Successfully pulled image "mvlassis/net-istio-controller:v1.12.3" in 5.012s (5.012s including waiting)
  Warning  Failed     12s (x6 over 68s)  kubelet            Error: container has runAsNonRoot and image has non-numeric user (_daemon_), cannot verify user is non-root (pod: "net-istio-controller-5896777f8b-pkjcx_knative-serving(f27196b4-4f99-4dcf-b234-9a587b905c8c)", container: controller)
  Normal   Pulled     12s (x5 over 68s)  kubelet            Container image "mvlassis/net-istio-controller:v1.12.3" already present on machine

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants