Bug 2033784 - set kube-apiserver degraded=true if webhook matches a virtual resource
Summary: set kube-apiserver degraded=true if webhook matches a virtual resource
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: OpenShift Container Platform
Classification: Red Hat
Component: kube-apiserver
Version: 4.10
Hardware: Unspecified
OS: Unspecified
unspecified
medium
Target Milestone: ---
: 4.10.0
Assignee: Luis Sanchez
QA Contact: Rahul Gangwar
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2021-12-17 20:47 UTC by Luis Sanchez
Modified: 2022-03-10 16:35 UTC (History)
4 users (show)

Fixed In Version:
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
: 2046620 (view as bug list)
Environment:
Last Closed: 2022-03-10 16:34:54 UTC
Target Upstream Version:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Github openshift cluster-kube-apiserver-operator pull 1249 0 None open Bug 2033784: set kube-apiserver degraded=true if webhook matches a virtual resource 2021-12-17 20:49:51 UTC
Red Hat Product Errata RHSA-2022:0056 0 None None None 2022-03-10 16:35:13 UTC

Description Luis Sanchez 2021-12-17 20:47:42 UTC
Virtual API resources (those representing operation on objects, rather than objects) should not have any admission web-hooks configured to validate or mutate the API.

Comment 3 Rahul Gangwar 2022-01-25 13:54:53 UTC
 oc get clusterversion           
NAME      VERSION                              AVAILABLE   PROGRESSING   SINCE   STATUS
version   4.10.0-0.nightly-2022-01-24-070025   True        False         7h12m   Cluster version is 4.10.0-0.nightly-2022-01-24-070025

Create a webhook that matches one of these resources.

cat webhook-config.yaml
apiVersion: admissionregistration.k8s.io/v1
kind: ValidatingWebhookConfiguration
metadata:
  name: "test-virtual-cfg"
webhooks:
- name: "test.virtual.com"
  rules:
  - apiGroups:   ["authorization.k8s.io"]
    apiVersions: ["v1"]
    operations:  ["*"]
    resources:   ["subjectaccessreviews"]
    scope:       "Namespaced"
  clientConfig:
    service:
      namespace: "example-namespace"
      name: "example-service"
  admissionReviewVersions: ["v1"]
  sideEffects: None
  timeoutSeconds: 5

oc apply -f webhook-config.yaml

kube-apiserver degraded when matched a virtual resource.

oc get co kube-apiserver -o yaml

status:
  conditions:
  - lastTransitionTime: "2022-01-25T13:45:32Z"
    message: |-
      ValidatingAdmissionWebhookConfigurationDegraded: test.virtual.com: unable to find find service example-service.example-namespace: service "example-service" not found
      VirtualResourceAdmissionDegraded: Validating webhook test.virtual.com matches a virtual resource subjectaccessreviews.authorization.k8s.io/v1
    reason: ValidatingAdmissionWebhookConfiguration_WebhookServiceNotFound::VirtualResourceAdmission_AdmissionWebhookMatchesVirtualResource
    status: "True"
    type: Degraded

Comment 4 Rahul Gangwar 2022-01-25 15:42:44 UTC
Same has been done for MutatingAdmissionWebhookConfiguration

apiVersion: admissionregistration.k8s.io/v1
kind: MutatingWebhookConfiguration
metadata:
  name: "test1-virtual-cfg"
webhooks:
- name: "test1.virtual.com"
  rules:
  - apiGroups:   ["authorization.k8s.io"]
    apiVersions: ["v1"]
    operations:  ["*"]
    resources:   ["subjectaccessreviews"]
    scope:       "Namespaced"
  clientConfig:
    service:
      namespace: "example-namespace"
      name: "example-service"
  admissionReviewVersions: ["v1"]
  sideEffects: None
  timeoutSeconds: 5

oc apply -f webhook-config.yaml

oc get co kube-apiserver -o yaml

 - lastTransitionTime: "2022-01-25T13:45:32Z"
    message: |-
      MutatingAdmissionWebhookConfigurationDegraded: test1.virtual.com: unable to find find service example-service.example-namespace: service "example-service" not found
      ValidatingAdmissionWebhookConfigurationDegraded: test.virtual.com: unable to find find service example-service.example-namespace: service "example-service" not found
      VirtualResourceAdmissionDegraded: Mutating webhook test1.virtual.com matches a virtual resource subjectaccessreviews.authorization.k8s.io/v1.
      VirtualResourceAdmissionDegraded: Validating webhook test.virtual.com matches a virtual resource subjectaccessreviews.authorization.k8s.io/v1
    reason: MutatingAdmissionWebhookConfiguration_WebhookServiceNotFound::ValidatingAdmissionWebhookConfiguration_WebhookServiceNotFound::VirtualResourceAdmission_AdmissionWebhookMatchesVirtualResource
    status: "True"
    type: Degraded

Comment 7 errata-xmlrpc 2022-03-10 16:34:54 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory (Moderate: OpenShift Container Platform 4.10.3 security update), and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHSA-2022:0056


Note You need to log in before you can comment on or make changes to this bug.