expected webhook response of admission.k8s.io/v1, Kind=AdmissionReview, got /, Kind=

 

  • 에러 내용

expected webhook response of admission.k8s.io/v1, Kind=AdmissionReview, got /, Kind=

 

  • 에러 원인

admission 의 webhook 응답이 기대한것과 다름.

나는 v1을 요청했으나 응답이 v1으로 오지 않았다는 것.

 

  • 해결

v1beta1은 따로 응답에 kind나 apiversion 을 기술하지 않아도 됬었는데

v1부터는 kind와 apiversion을 응답에 같이 넣어주면 된다.

 

	requestedAdmissionReview := v1.AdmissionReview{}
	responseAdmissionReview := v1.AdmissionReview{}

	if _, _, err := deserializer.Decode(body, nil, &requestedAdmissionReview); err != nil {
		level.Warn(a.logger).Log("msg", "Unable to deserialize request", "err", err)
		responseAdmissionReview.Response = toAdmissionResponseFailure("Unable to deserialize request", []error{err})
	} else {
		responseAdmissionReview.Response = admit(requestedAdmissionReview)
	}

	responseAdmissionReview.Response.UID = requestedAdmissionReview.Request.UID
	responseAdmissionReview.APIVersion = requestedAdmissionReview.APIVersion
	responseAdmissionReview.Kind = requestedAdmissionReview.Kind

	respBytes, err := json.Marshal(responseAdmissionReview)
  • 소스 출처 prometheus-operator github

 

 

+ Recent posts