@@ -17,6 +17,7 @@ import (
17
17
18
18
corev1 "k8s.io/api/core/v1"
19
19
apixv1beta1client "k8s.io/apiextensions-apiserver/pkg/client/clientset/clientset/typed/apiextensions/v1beta1"
20
+ policyv1beta1 "k8s.io/api/policy/v1beta1"
20
21
"k8s.io/apimachinery/pkg/api/errors"
21
22
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
22
23
"k8s.io/apimachinery/pkg/runtime"
@@ -63,7 +64,7 @@ const (
63
64
var (
64
65
openshiftSerializer = openshiftscheme .Codecs .LegacyCodec (configv1 .SchemeGroupVersion )
65
66
kubeSerializer = kubescheme .Codecs .LegacyCodec (corev1 .SchemeGroupVersion )
66
-
67
+ policyV1Beta1Serializer = kubescheme . Codecs . LegacyCodec ( policyv1beta1 . SchemeGroupVersion )
67
68
// maxEventTimeInterval represents the "only keep events that are maximum 1h old"
68
69
// TODO: make this dynamic like the reporting window based on configured interval
69
70
maxEventTimeInterval = 1 * time .Hour
@@ -114,7 +115,7 @@ func New(client configv1client.ConfigV1Interface, coreClient corev1client.CoreV1
114
115
registryClient : registryClient ,
115
116
crdClient : crdClient ,
116
117
networkClient : networkClient ,
117
- policyClient : policyClient ,
118
+ policyClient : policyClient ,
118
119
}
119
120
}
120
121
@@ -157,8 +158,8 @@ func GatherPodDisruptionBudgets(i *Gatherer) func() ([]record.Record, []error) {
157
158
records := []record.Record {}
158
159
for _ , pdb := range pdbs .Items {
159
160
records = append (records , record.Record {
160
- Name : fmt .Sprintf ("config/policy /%s" , pdb .GetName ()),
161
- Item : record. JSONMarshaller { Object : pdb },
161
+ Name : fmt .Sprintf ("config/pdbs /%s" , pdb .GetName ()),
162
+ Item : PodDisruptionBudgetsAnonymizer { & pdb },
162
163
})
163
164
}
164
165
return records , nil
@@ -1114,6 +1115,20 @@ func anonymizePod(pod *corev1.Pod) *corev1.Pod {
1114
1115
return pod
1115
1116
}
1116
1117
1118
+ type PodDisruptionBudgetsAnonymizer struct {
1119
+ * policyv1beta1.PodDisruptionBudget
1120
+ }
1121
+
1122
+ // Marshal implements serialization of a Pod with anonymization
1123
+ func (a PodDisruptionBudgetsAnonymizer ) Marshal (_ context.Context ) ([]byte , error ) {
1124
+ return runtime .Encode (policyV1Beta1Serializer , a .PodDisruptionBudget )
1125
+ }
1126
+
1127
+ // GetExtension returns extension for anonymized pod objects
1128
+ func (a PodDisruptionBudgetsAnonymizer ) GetExtension () string {
1129
+ return "json"
1130
+ }
1131
+
1117
1132
func isHealthyPod (pod * corev1.Pod , now time.Time ) bool {
1118
1133
// pending pods may be unable to schedule or start due to failures, and the info they provide in status is important
1119
1134
// for identifying why scheduling has not happened
0 commit comments