question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

CRDs cause errors (both for RBAC and SUPPORTED_API_VERSIONS)

See original GitHub issue

Describe the bug

The connaisseur webhook seems to intercept any CREATE/UPDATE operations, even those to CRDs. However, the clusterolebinding doesn’t have access to “get” these resources, and this creates errors like this:

[2022-03-17 04:47:13,564] ERROR: Traceback (most recent call last):
  File "/app/connaisseur/flask_application.py", line 71, in mutate
    response = asyncio.run(__admit(admission_request))
  File "/usr/local/lib/python3.10/asyncio/runners.py", line 44, in run
    return loop.run_until_complete(main)
  File "/usr/local/lib/python3.10/asyncio/base_events.py", line 641, in run_until_complete
    return future.result()
  File "/app/connaisseur/flask_application.py", line 139, in __admit
    await patches
  File "/app/connaisseur/flask_application.py", line 165, in __validate_image
    image in admission_request.wl_object.parent_containers.values()
  File "/app/connaisseur/workload_object.py", line 68, in parent_containers
    parent = k_api.request_kube_api(
  File "/app/connaisseur/kube_api.py", line 22, in request_kube_api
    response.raise_for_status()
  File "/usr/local/lib/python3.10/site-packages/requests/models.py", line 960, in raise_for_status
    raise HTTPError(http_error_msg, response=self)
requests.exceptions.HTTPError: 403 Client Error: Forbidden for url: https://10.96.0.1:443/apis/vault.banzaicloud.com/v1alpha1/namespaces/preview-notifications-pr-7/vaults/vault

Expected behavior

Since we already have a preset list of objects we allow connaisseur to watch, connaisseur should only respond to these objects, not all objects.

Optional: To reproduce

  • Deploy connaisseur
  • Add any service which uses CRDs to specify images (the above example uses banzaicloud’s bank-vaults)
  • Watch connaisseur logs
  • Deploy a CR for the service, and observe the error

Optional: Versions (please complete the following information as relevant):

  • Connaisseur: 2.5.1

Optional: Additional context

As a test, I manually edited the clusterrole to permit get to all the CRDs we use. In the example below, minio-operator’s Tenant CR was used. Although connaisseur was able to get the object, it still produced an error:

[2022-03-17 01:57:30,798] ERROR: Traceback (most recent call last):
  File "/app/connaisseur/flask_application.py", line 71, in mutate
    response = asyncio.run(__admit(admission_request))
  File "/usr/local/lib/python3.10/asyncio/runners.py", line 44, in run
    return loop.run_until_complete(main)
  File "/usr/local/lib/python3.10/asyncio/base_events.py", line 641, in run_until_complete
    return future.result()
  File "/app/connaisseur/flask_application.py", line 139, in __admit
    await patches
  File "/app/connaisseur/flask_application.py", line 165, in __validate_image
    image in admission_request.wl_object.parent_containers.values()
  File "/app/connaisseur/workload_object.py", line 81, in parent_containers
    parent_containers.update(WorkloadObject(parent, self.namespace).containers)
  File "/app/connaisseur/workload_object.py", line 40, in __init__
    if self.api_version not in SUPPORTED_API_VERSIONS[self.kind]:
KeyError: 'Tenant'

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:10 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
funkypenguincommented, Mar 24, 2022

Thanks heaps, @xopham, -rc3 seems to work as expected 😃

1reaction
funkypenguincommented, Mar 23, 2022

Hi @xopham,

Sure, here’s a really minimal reproduction, tested using KinD:

  1. Deploy vault-operator:
helm repo add banzaicloud-stable https://kubernetes-charts.banzaicloud.com
helm upgrade --install vault-operator banzaicloud-stable/vault-operator
  1. Deploy connaisseur:
helm repo add connaisseur https://sse-secure-systems.github.io/connaisseur/charts
helm upgrade --install connaisseur connaisseur/connaisseur
  1. Deploy one of the bank-vaults sample CRs:
kubectl apply -f https://raw.githubusercontent.com/banzaicloud/bank-vaults/main/operator/deploy/cr-priority.yaml
  1. Observe the connaisseur logs:
 kubectl logs -l app.kubernetes.io/name=connaisseur

Output is something like this:

[2022-03-23 08:09:05,384] INFO: 10.244.0.1 - - [23/Mar/2022 08:09:05] "POST /mutate?timeout=30s HTTP/1.1" 200 -
    image in admission_request.wl_object.parent_containers.values()
  File "/app/connaisseur/workload_object.py", line 68, in parent_containers
    parent = k_api.request_kube_api(
  File "/app/connaisseur/kube_api.py", line 22, in request_kube_api
    response.raise_for_status()
  File "/usr/local/lib/python3.10/site-packages/requests/models.py", line 960, in raise_for_status
    raise HTTPError(http_error_msg, response=self)
requests.exceptions.HTTPError: 403 Client Error: Forbidden for url: https://10.96.0.1:443/apis/vault.banzaicloud.com/v1alpha1/namespaces/default/vaults/vault

[2022-03-23 08:07:26,766] INFO: 10.244.0.1 - - [23/Mar/2022 08:07:26] "POST /mutate?timeout=30s HTTP/1.1" 200 -
Read more comments on GitHub >

github_iconTop Results From Across the Web

error GitRepository/flux-system.flux-system · Issue #87 - GitHub
I have been following the automation tutorial.
Read more >
Chapter 22. Clusters at the network far edge
Installing and deploying the clusters is a two-stage process, involving an initial installation phase, and a subsequent configuration phase.
Read more >
Kubernetes 1.22 deprecated APIs - Google Cloud
Migrate manifests and API clients to use the rbac.authorization.k8s.io/v1 API ... user agents that use the deprecated APIs to use supported API versions....
Read more >
Release notes | Logging | OpenShift Container Platform 4.11
This release includes OpenShift Logging Bug Fix Release 5.3.11. Bug fixes. Before this update, the Operator did not ensure that the pod was...
Read more >
Kubernetes Role-Based Access Control (RBAC) - StrongDM
Explanation of role-based access control (RBAC) in Kubernetes, why it is hard to manage manually & practical strategies for simplifying RBAC ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found