From 5183ea0bf03996c0de45ce9402eba12975b38b03 Mon Sep 17 00:00:00 2001 From: Jordan Liggitt Date: Tue, 22 Jun 2021 14:02:17 -0400 Subject: [PATCH] PodSecurity: metrics: stub interface Co-authored-by: Tim Allclair --- .../pod-security-admission/metrics/doc.go | 18 ++++++++++++++ .../pod-security-admission/metrics/metrics.go | 24 +++++++++++++++++++ .../metrics/metrics_test.go | 17 +++++++++++++ 3 files changed, 59 insertions(+) create mode 100644 staging/src/k8s.io/pod-security-admission/metrics/doc.go create mode 100644 staging/src/k8s.io/pod-security-admission/metrics/metrics.go create mode 100644 staging/src/k8s.io/pod-security-admission/metrics/metrics_test.go diff --git a/staging/src/k8s.io/pod-security-admission/metrics/doc.go b/staging/src/k8s.io/pod-security-admission/metrics/doc.go new file mode 100644 index 00000000000..27091daf8e2 --- /dev/null +++ b/staging/src/k8s.io/pod-security-admission/metrics/doc.go @@ -0,0 +1,18 @@ +/* +Copyright 2021 The Kubernetes Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Package metrics contains metrics interfaces and implementations for PodSecurity admission +package metrics // import "k8s.io/pod-security-admission/metrics" diff --git a/staging/src/k8s.io/pod-security-admission/metrics/metrics.go b/staging/src/k8s.io/pod-security-admission/metrics/metrics.go new file mode 100644 index 00000000000..ae7bf8fb86c --- /dev/null +++ b/staging/src/k8s.io/pod-security-admission/metrics/metrics.go @@ -0,0 +1,24 @@ +/* +Copyright 2021 The Kubernetes Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package metrics + +type EvaluationRecorder interface { + // TODO: fill in args required to record https://github.com/kubernetes/enhancements/tree/master/keps/sig-auth/2579-psp-replacement#monitoring + RecordEvaluation() +} + +// TODO: default prometheus-based implementation diff --git a/staging/src/k8s.io/pod-security-admission/metrics/metrics_test.go b/staging/src/k8s.io/pod-security-admission/metrics/metrics_test.go new file mode 100644 index 00000000000..17911b6bc6c --- /dev/null +++ b/staging/src/k8s.io/pod-security-admission/metrics/metrics_test.go @@ -0,0 +1,17 @@ +/* +Copyright 2021 The Kubernetes Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package metrics