Skip to content

Commit edc7907

Browse files
k8s client use protobuf
1 parent 8cdbe45 commit edc7907

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

pkg/exporters/k8sexporter/problemclient/problem_client.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,10 @@ func NewClientOrDie(npdo *options.NodeProblemDetectorOptions) Client {
7474
}
7575

7676
cfg.UserAgent = fmt.Sprintf("%s/%s", filepath.Base(os.Args[0]), version.Version())
77+
// warning! this client use protobuf can not used on CRD
78+
// https://kubernetes.io/docs/reference/using-api/api-concepts/
79+
cfg.AcceptContentTypes = "application/vnd.kubernetes.protobuf,application/json"
80+
cfg.ContentType = "application/vnd.kubernetes.protobuf"
7781
// TODO(random-liu): Set QPS Limit
7882
c.client = clientset.NewForConfigOrDie(cfg).CoreV1()
7983
c.nodeName = npdo.NodeName

pkg/systemlogmonitor/log_monitor.go

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,10 @@ func InitK8sClientOrDie(options *options.NodeProblemDetectorOptions) *clientset.
8686
panic(err)
8787
}
8888
cfg.UserAgent = fmt.Sprintf("%s/%s", filepath.Base(os.Args[0]), version.Version())
89+
// warning! this client use protobuf can not used on CRD
90+
// https://kubernetes.io/docs/reference/using-api/api-concepts/
91+
cfg.AcceptContentTypes = "application/vnd.kubernetes.protobuf,application/json"
92+
cfg.ContentType = "application/vnd.kubernetes.protobuf"
8993
k8sClient = clientset.NewForConfigOrDie(cfg)
9094
return k8sClient
9195
}
@@ -224,10 +228,10 @@ func (l *logMonitor) generateStatus(logs []*logtypes.Log, rule systemlogtypes.Ru
224228
if rule.Type == types.Temp {
225229
// For temporary error only generate event
226230
events = append(events, types.Event{
227-
Severity: types.Warn,
228-
Timestamp: timestamp,
229-
Reason: rule.Reason,
230-
Message: message,
231+
Severity: types.Warn,
232+
Timestamp: timestamp,
233+
Reason: rule.Reason,
234+
Message: message,
231235
})
232236
} else {
233237
// For permanent error changes the condition

0 commit comments

Comments
 (0)