Skip to content

Commit b1d33c2

Browse files
committed
deploy: add spire manifests in helm and kustomize
Signed-off-by: TessaIO <[email protected]>
1 parent c77c370 commit b1d33c2

File tree

14 files changed

+192
-101
lines changed

14 files changed

+192
-101
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
dependencies:
2+
- name: spire
3+
repository: https://spiffe.github.io/helm-charts-hardened/
4+
version: 0.24.1
5+
digest: sha256:f3b4dc973a59682bf3aa5ca9b53322f57935dd093081e82a37b8082e00becbe9
6+
generated: "2024-12-20T16:52:40.180416+01:00"

deployment/helm/node-feature-discovery/Chart.yaml

+5
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,8 @@ keywords:
1313
- node-labels
1414
type: application
1515
version: 0.2.1
16+
dependencies:
17+
- name: spire
18+
version: 0.24.1
19+
repository: https://spiffe.github.io/helm-charts-hardened/
20+
condition: spire.enabled
Binary file not shown.

deployment/helm/node-feature-discovery/templates/master.yaml

+14
Original file line numberDiff line numberDiff line change
@@ -145,11 +145,25 @@ spec:
145145
{{- with .Values.master.extraArgs }}
146146
{{- toYaml . | nindent 12 }}
147147
{{- end }}
148+
{{- if .Values.spire.enabled }}
149+
- "-enable-spiffe"
150+
{{- end }}
148151
volumeMounts:
152+
{{- if .Values.spire.enabled }}
153+
- name: spire-agent-socket
154+
mountPath: /run/spire/agent-sockets
155+
readOnly: true
156+
{{- end }}
149157
- name: nfd-master-conf
150158
mountPath: "/etc/kubernetes/node-feature-discovery"
151159
readOnly: true
152160
volumes:
161+
{{- if .Values.spire.enabled }}
162+
- name: spire-agent-socket
163+
hostPath:
164+
path: /run/spire/agent-sockets/api.sock
165+
type: Socket
166+
{{- end }}
153167
- name: nfd-master-conf
154168
configMap:
155169
name: {{ include "node-feature-discovery.fullname" . }}-master-conf

deployment/helm/node-feature-discovery/templates/worker.yaml

+14
Original file line numberDiff line numberDiff line change
@@ -110,10 +110,18 @@ spec:
110110
{{- with .Values.worker.extraArgs }}
111111
{{- toYaml . | nindent 8 }}
112112
{{- end }}
113+
{{- if .Values.spire.enabled }}
114+
- "-enable-spiffe"
115+
{{- end }}
113116
ports:
114117
- containerPort: {{ .Values.worker.port | default "8080"}}
115118
name: http
116119
volumeMounts:
120+
{{- if .Values.spire.enabled }}
121+
- name: spire-agent-socket
122+
mountPath: /run/spire/agent-sockets
123+
readOnly: true
124+
{{- end }}
117125
- name: host-boot
118126
mountPath: "/host-boot"
119127
readOnly: true
@@ -144,6 +152,12 @@ spec:
144152
mountPath: "/etc/kubernetes/node-feature-discovery"
145153
readOnly: true
146154
volumes:
155+
{{- if .Values.spire.enabled }}
156+
- name: spire-agent-socket
157+
hostPath:
158+
path: /run/spire/agent-sockets
159+
type: Directory
160+
{{- end }}
147161
- name: host-boot
148162
hostPath:
149163
path: "/boot"

deployment/helm/node-feature-discovery/values.yaml

+44
Original file line numberDiff line numberDiff line change
@@ -574,3 +574,47 @@ prometheus:
574574
enable: false
575575
scrapeInterval: 10s
576576
labels: {}
577+
578+
spire:
579+
enabled: false
580+
global:
581+
spire:
582+
clusterName: "nfd"
583+
trustDomain: "nfd.k8s-sigs.io"
584+
spire-agent:
585+
kubeletConnectByHostname: "true"
586+
workloadAttestors:
587+
unix:
588+
enabled: true
589+
spire-server:
590+
controllerManager:
591+
enabled: true
592+
identities:
593+
clusterStaticEntries:
594+
node:
595+
parentID: spiffe://nfd.k8s-sigs.io/spire/server
596+
spiffeID: spiffe://nfd.k8s-sigs.io/root
597+
selectors:
598+
- k8s_psat:agent_ns:nfd
599+
- k8s_psat:agent_sa:nfd-agent
600+
- k8s_psat:cluster:nfd
601+
nfd:
602+
parentID: spiffe://nfd.k8s-sigs.io/root
603+
spiffeID: spiffe://nfd.k8s-sigs.io/worker
604+
selectors:
605+
- k8s:pod-label:app.kubernetes.io/name:node-feature-discovery
606+
607+
608+
caSubject:
609+
commonName: "nfd.k8s-sigs.io"
610+
country: "US"
611+
organization: "SPIFFE"
612+
613+
upstream:
614+
enabled: false
615+
spiffe-csi-driver:
616+
enabled: false
617+
spiffe-oidc-discovery-provider:
618+
enabled: false
619+
tornjak-frontend:
620+
enabled: false

docs/reference/master-commandline-reference.md

+16
Original file line numberDiff line numberDiff line change
@@ -306,3 +306,19 @@ Example:
306306
```bash
307307
nfd-master -resync-period=2h
308308
```
309+
310+
### -enable-spiffe
311+
312+
the `-enable-spiffe` flag enables SPIFFE verification for the created NodeFeature
313+
objects created by the worker. When enabled, master verifies the signature that
314+
is put on the annotations part of the NodeFeature object, and updates
315+
Kubernetes nodes if the signature is verified. The feature should be enabled,
316+
after deploying SPIFFE, and you can do it through the Helm chart.
317+
318+
Default: false.
319+
320+
Example:
321+
322+
```bash
323+
nfd-master -enable-spiffe
324+
```

docs/reference/worker-commandline-reference.md

+16
Original file line numberDiff line numberDiff line change
@@ -273,3 +273,19 @@ Default: 0
273273
Comma-separated list of `pattern=N` settings for file-filtered logging.
274274

275275
Default: *empty*
276+
277+
### -enable-spiffe
278+
279+
the `-enable-spiffe` flag enables signing NodeFeature spec on the worker side
280+
and puts the signature in the annotations side of the NodeFeature object.
281+
The signature is verified afterwards by the master. The feature
282+
should be enabled, after deploying SPIFFE, and you can do it through
283+
the Helm chart.
284+
285+
Default: false.
286+
287+
Example:
288+
289+
```bash
290+
nfd-master -enable-spiffe
291+
```

go.mod

+3
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ require (
1919
github.com/prometheus/client_golang v1.21.0
2020
github.com/smartystreets/goconvey v1.8.1
2121
github.com/spf13/cobra v1.9.1
22+
github.com/spiffe/go-spiffe/v2 v2.5.0
2223
github.com/stretchr/testify v1.10.0
2324
github.com/vektra/errors v0.0.0-20140903201135-c64d83aba85a
2425
golang.org/x/exp v0.0.0-20240719175910-8a7402abbf56
@@ -71,6 +72,7 @@ require (
7172
github.com/euank/go-kmsg-parser v2.0.0+incompatible // indirect
7273
github.com/felixge/httpsnoop v1.0.4 // indirect
7374
github.com/fxamacker/cbor/v2 v2.7.0 // indirect
75+
github.com/go-jose/go-jose/v4 v4.0.4 // indirect
7476
github.com/go-logr/logr v1.4.2 // indirect
7577
github.com/go-logr/stdr v1.2.2 // indirect
7678
github.com/go-ole/go-ole v1.2.6 // indirect
@@ -131,6 +133,7 @@ require (
131133
github.com/stoewer/go-strcase v1.3.0 // indirect
132134
github.com/stretchr/objx v0.5.2 // indirect
133135
github.com/x448/float16 v0.8.4 // indirect
136+
github.com/zeebo/errs v1.4.0 // indirect
134137
go.etcd.io/etcd/api/v3 v3.5.16 // indirect
135138
go.etcd.io/etcd/client/pkg/v3 v3.5.16 // indirect
136139
go.etcd.io/etcd/client/v3 v3.5.16 // indirect

go.sum

+6-22
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,8 @@ github.com/fsnotify/fsnotify v1.8.0 h1:dAwr6QBTBZIkG8roQaJjGof0pp0EeF+tNV7YBP3F/
7676
github.com/fsnotify/fsnotify v1.8.0/go.mod h1:8jBTzvmWwFyi3Pb8djgCCO5IBqzKJ/Jwo8TRcHyHii0=
7777
github.com/fxamacker/cbor/v2 v2.7.0 h1:iM5WgngdRBanHcxugY4JySA0nk1wZorNOpTgCMedv5E=
7878
github.com/fxamacker/cbor/v2 v2.7.0/go.mod h1:pxXPTn3joSm21Gbwsv0w9OSA2y1HFR9qXEeXQVeNoDQ=
79+
github.com/go-jose/go-jose/v4 v4.0.4 h1:VsjPI33J0SB9vQM6PLmNjoHqMQNGPiZ0rHL7Ni7Q6/E=
80+
github.com/go-jose/go-jose/v4 v4.0.4/go.mod h1:NKb5HO1EZccyMpiZNbdUw/14tiXNyUJh188dfnMCAfc=
7981
github.com/go-logr/logr v1.2.2/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A=
8082
github.com/go-logr/logr v1.4.2 h1:6pFjapn8bFcIbiKo3XT4j/BhANplGihG6tvd+8rYgrY=
8183
github.com/go-logr/logr v1.4.2/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY=
@@ -123,27 +125,6 @@ github.com/google/pprof v0.0.0-20241210010833-40e02aabc2ad h1:a6HEuzUHeKH6hwfN/Z
123125
github.com/google/pprof v0.0.0-20241210010833-40e02aabc2ad/go.mod h1:vavhavw2zAxS5dIdcRluK6cSGGPlZynqzFM8NdvU144=
124126
github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
125127
github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
126-
github.com/googleapis/enterprise-certificate-proxy v0.0.0-20220520183353-fd19c99a87aa/go.mod h1:17drOmN3MwGY7t0e+Ei9b45FFGA3fBs3x36SsCg1hq8=
127-
github.com/googleapis/enterprise-certificate-proxy v0.1.0/go.mod h1:17drOmN3MwGY7t0e+Ei9b45FFGA3fBs3x36SsCg1hq8=
128-
github.com/googleapis/enterprise-certificate-proxy v0.2.0/go.mod h1:8C0jb7/mgJe/9KK8Lm7X9ctZC2t60YyIpYEI16jx0Qg=
129-
github.com/googleapis/enterprise-certificate-proxy v0.2.1/go.mod h1:AwSRAtLfXpU5Nm3pW+v7rGDHp09LsPtGY9MduiEsR9k=
130-
github.com/googleapis/enterprise-certificate-proxy v0.2.3/go.mod h1:AwSRAtLfXpU5Nm3pW+v7rGDHp09LsPtGY9MduiEsR9k=
131-
github.com/googleapis/gax-go/v2 v2.0.4/go.mod h1:0Wqv26UfaUD9n4G6kQubkQ+KchISgw+vpHVxEJEs9eg=
132-
github.com/googleapis/gax-go/v2 v2.0.5/go.mod h1:DWXyrwAJ9X0FpwwEdw+IPEYBICEFu5mhpdKc/us6bOk=
133-
github.com/googleapis/gax-go/v2 v2.1.0/go.mod h1:Q3nei7sK6ybPYH7twZdmQpAd1MKb7pfu6SK+H1/DsU0=
134-
github.com/googleapis/gax-go/v2 v2.1.1/go.mod h1:hddJymUZASv3XPyGkUpKj8pPO47Rmb0eJc8R6ouapiM=
135-
github.com/googleapis/gax-go/v2 v2.2.0/go.mod h1:as02EH8zWkzwUoLbBaFeQ+arQaj/OthfcblKl4IGNaM=
136-
github.com/googleapis/gax-go/v2 v2.3.0/go.mod h1:b8LNqSzNabLiUpXKkY7HAR5jr6bIT99EXz9pXxye9YM=
137-
github.com/googleapis/gax-go/v2 v2.4.0/go.mod h1:XOTVJ59hdnfJLIP/dh8n5CGryZR2LxK9wbMD5+iXC6c=
138-
github.com/googleapis/gax-go/v2 v2.5.1/go.mod h1:h6B0KMMFNtI2ddbGJn3T3ZbwkeT6yqEF02fYlzkUCyo=
139-
github.com/googleapis/gax-go/v2 v2.6.0/go.mod h1:1mjbznJAPHFpesgE5ucqfYEscaz5kMdcIDwU/6+DDoY=
140-
github.com/googleapis/gax-go/v2 v2.7.0/go.mod h1:TEop28CZZQ2y+c0VxMUmu1lV+fQx57QpBWsYpwqHJx8=
141-
github.com/googleapis/gax-go/v2 v2.7.1/go.mod h1:4orTrqY6hXxxaUL4LHIPl6lGo8vAE38/qKbhSAKP6QI=
142-
github.com/googleapis/gax-go/v2 v2.8.0/go.mod h1:4orTrqY6hXxxaUL4LHIPl6lGo8vAE38/qKbhSAKP6QI=
143-
github.com/googleapis/gax-go/v2 v2.10.0/go.mod h1:4UOEnMCrxsSqQ940WnTiD6qJ63le2ev3xfyagutxiPw=
144-
github.com/googleapis/gax-go/v2 v2.11.0/go.mod h1:DxmR61SGKkGLa2xigwuZIQpkCI2S5iydzRfb3peWZJI=
145-
github.com/googleapis/go-type-adapters v1.0.0/go.mod h1:zHW75FOG2aur7gAO2B+MLby+cLsWGBF62rFAi7WjWO4=
146-
github.com/googleapis/google-cloud-go-testing v0.0.0-20200911160855-bcd43fbb19e8/go.mod h1:dvDLG8qkwmyD9a/MJJN3XJcT3xFxOKAvTZGvuZmac9g=
147128
github.com/gopherjs/gopherjs v1.17.2 h1:fQnZVsXk8uxXIStYb0N4bGk7jeyTalG/wsZjQ25dO0g=
148129
github.com/gopherjs/gopherjs v1.17.2/go.mod h1:pRRIvn/QzFLrKfvEz3qUuEhtE/zLCWfreZ6J5gM2i+k=
149130
github.com/gorilla/websocket v1.5.0 h1:PPwGk2jz7EePpoHN/+ClbZu8SPxiqlu12wZP/3sWmnc=
@@ -276,14 +257,15 @@ github.com/spf13/cobra v1.9.1 h1:CXSaggrXdbHK9CF+8ywj8Amf7PBRmPCOJugH954Nnlo=
276257
github.com/spf13/cobra v1.9.1/go.mod h1:nDyEzZ8ogv936Cinf6g1RU9MRY64Ir93oCnqb9wxYW0=
277258
github.com/spf13/pflag v1.0.6 h1:jFzHGLGAlb3ruxLB8MhbI6A8+AQX/2eW4qeyNZXNp2o=
278259
github.com/spf13/pflag v1.0.6/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=
260+
github.com/spiffe/go-spiffe/v2 v2.5.0 h1:N2I01KCUkv1FAjZXJMwh95KK1ZIQLYbPfhaxw8WS0hE=
261+
github.com/spiffe/go-spiffe/v2 v2.5.0/go.mod h1:P+NxobPc6wXhVtINNtFjNWGBTreew1GBUCwT2wPmb7g=
279262
github.com/stoewer/go-strcase v1.3.0 h1:g0eASXYtp+yvN9fK8sH94oCIk0fau9uV1/ZdJ0AVEzs=
280263
github.com/stoewer/go-strcase v1.3.0/go.mod h1:fAH5hQ5pehh+j3nZfvwdk2RgEgQjAoM8wodgtPmh1xo=
281264
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
282265
github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=
283266
github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo=
284267
github.com/stretchr/objx v0.5.2 h1:xuMeJ0Sdp5ZMRXx/aWO6RZxdr3beISkG5/G/aIRr3pY=
285268
github.com/stretchr/objx v0.5.2/go.mod h1:FRsXN1f5AsAjCGJKqEizvkpNtU+EGNCLh3NxZ/8L+MA=
286-
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
287269
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
288270
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
289271
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
@@ -301,6 +283,8 @@ github.com/xiang90/probing v0.0.0-20221125231312-a49e3df8f510 h1:S2dVYn90KE98chq
301283
github.com/xiang90/probing v0.0.0-20221125231312-a49e3df8f510/go.mod h1:UETIi67q53MR2AWcXfiuqkDkRtnGDLqkBTpCHuJHxtU=
302284
github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
303285
github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
286+
github.com/zeebo/errs v1.4.0 h1:XNdoD/RRMKP7HD0UhJnIzUy74ISdGGxURlYG8HSWSfM=
287+
github.com/zeebo/errs v1.4.0/go.mod h1:sgbWHsvVuTPHcqJJGQ1WhI5KbWlHYz+2+2C/LSEtCw4=
304288
go.etcd.io/bbolt v1.3.11 h1:yGEzV1wPz2yVCLsD8ZAiGHhHVlczyC9d1rP43/VCRJ0=
305289
go.etcd.io/bbolt v1.3.11/go.mod h1:dksAq7YMXoljX0xu6VF5DMZGbhYYoLUalEiSySYAS4I=
306290
go.etcd.io/etcd/api/v3 v3.5.16 h1:WvmyJVbjWqK4R1E+B12RRHz3bRGy9XVfh++MgbN+6n0=

pkg/nfd-master/nfd-master.go

+19-59
Original file line numberDiff line numberDiff line change
@@ -51,24 +51,19 @@ import (
5151
"sigs.k8s.io/yaml"
5252

5353
nfdclientset "sigs.k8s.io/node-feature-discovery/api/generated/clientset/versioned"
54-
klogutils "sigs.k8s.io/node-feature-discovery/pkg/utils/klog"
55-
spiffe "sigs.k8s.io/node-feature-discovery/pkg/utils/spiffe"
56-
57-
taintutils "k8s.io/kubernetes/pkg/util/taints"
58-
"sigs.k8s.io/yaml"
59-
6054
"sigs.k8s.io/node-feature-discovery/api/nfd/v1alpha1"
6155
nfdv1alpha1 "sigs.k8s.io/node-feature-discovery/api/nfd/v1alpha1"
6256
"sigs.k8s.io/node-feature-discovery/pkg/apis/nfd/nodefeaturerule"
6357
"sigs.k8s.io/node-feature-discovery/pkg/apis/nfd/validate"
6458
nfdfeatures "sigs.k8s.io/node-feature-discovery/pkg/features"
6559
"sigs.k8s.io/node-feature-discovery/pkg/utils"
6660
klogutils "sigs.k8s.io/node-feature-discovery/pkg/utils/klog"
61+
spiffe "sigs.k8s.io/node-feature-discovery/pkg/utils/spiffe"
6762
"sigs.k8s.io/node-feature-discovery/pkg/version"
6863
)
6964

7065
// SocketPath specifies Spiffe Socket Path
71-
const SocketPath = "unix:///run/spire/sockets/agent.sock"
66+
const SocketPath = "unix:///run/spire/agent-sockets/api.sock"
7267

7368
// Labels are a Kubernetes representation of discovered features.
7469
type Labels map[string]string
@@ -642,6 +637,14 @@ func (m *nfdMaster) getAndMergeNodeFeatures(nodeName string) (*nfdv1alpha1.NodeF
642637
return filteredObjs[i].Namespace < filteredObjs[j].Namespace
643638
})
644639

640+
// If spiffe is enabled, we should filter out the non verified NFD objects
641+
if m.config.EnableSpiffe {
642+
filteredObjs, err = m.getVerifiedNFDObjects(filteredObjs)
643+
if err != nil {
644+
return &nfdv1alpha1.NodeFeature{}, err
645+
}
646+
}
647+
645648
if len(filteredObjs) > 0 {
646649
// Merge in features
647650
//
@@ -697,55 +700,6 @@ func (m *nfdMaster) nfdAPIUpdateOneNode(cli k8sclient.Interface, node *corev1.No
697700
return fmt.Errorf("failed to merge NodeFeature objects for node %q: %w", node.Name, err)
698701
}
699702

700-
// Sort our objects
701-
sort.Slice(objs, func(i, j int) bool {
702-
// Objects in our nfd namespace gets into the beginning of the list
703-
if objs[i].Namespace == m.namespace && objs[j].Namespace != m.namespace {
704-
return true
705-
}
706-
if objs[i].Namespace != m.namespace && objs[j].Namespace == m.namespace {
707-
return false
708-
}
709-
// After the nfd namespace, sort objects by their name
710-
if objs[i].Name != objs[j].Name {
711-
return objs[i].Name < objs[j].Name
712-
}
713-
// Objects with the same name are sorted by their namespace
714-
return objs[i].Namespace < objs[j].Namespace
715-
})
716-
717-
// If spiffe is enabled, we should filter out the non verified NFD objects
718-
if m.config.EnableSpiffe {
719-
objs, err = m.getVerifiedNFDObjects(objs)
720-
if err != nil {
721-
return err
722-
}
723-
}
724-
725-
klog.V(1).InfoS("processing of node initiated by NodeFeature API", "nodeName", node.Name)
726-
727-
features := nfdv1alpha1.NewNodeFeatureSpec()
728-
729-
if len(objs) > 0 {
730-
// Merge in features
731-
//
732-
// NOTE: changing the rule api to support handle multiple objects instead
733-
// of merging would probably perform better with lot less data to copy.
734-
features = objs[0].Spec.DeepCopy()
735-
if m.config.AutoDefaultNs {
736-
features.Labels = addNsToMapKeys(features.Labels, nfdv1alpha1.FeatureLabelNs)
737-
}
738-
for _, o := range objs[1:] {
739-
s := o.Spec.DeepCopy()
740-
if m.config.AutoDefaultNs {
741-
s.Labels = addNsToMapKeys(s.Labels, nfdv1alpha1.FeatureLabelNs)
742-
}
743-
s.MergeInto(features)
744-
}
745-
746-
klog.V(4).InfoS("merged nodeFeatureSpecs", "newNodeFeatureSpec", utils.DelayedDumper(features))
747-
}
748-
749703
// Update node labels et al. This may also mean removing all NFD-owned
750704
// labels (et al.), for example in the case no NodeFeature objects are
751705
// present.
@@ -1469,16 +1423,22 @@ func (m *nfdMaster) getVerifiedNFDObjects(objs []*v1alpha1.NodeFeature) ([]*v1al
14691423
}
14701424

14711425
for _, obj := range objs {
1472-
isSignatureVerified, err := spiffe.VerifyDataSignature(obj.Spec, obj.Annotations["signature"], workerPrivateKey, workerPublicKey)
1426+
spiffeObj := spiffe.SpiffeObject{
1427+
Spec: obj.Spec,
1428+
Name: obj.Name,
1429+
Namespace: obj.Namespace,
1430+
Labels: obj.Labels,
1431+
}
1432+
isSignatureVerified, err := spiffe.VerifyDataSignature(spiffeObj, obj.Annotations["signature"], workerPrivateKey, workerPublicKey)
14731433
if err != nil {
14741434
return nil, fmt.Errorf("failed to verify NodeFeature signature: %w", err)
14751435
}
14761436

14771437
if isSignatureVerified {
1478-
klog.InfoS("NodeFeature verified", "NodeFeature name", obj.Name)
1438+
klog.InfoS("NodeFeature verified", "nodefeature", klog.KObj(obj))
14791439
verifiedObjects = append(verifiedObjects, obj)
14801440
} else {
1481-
klog.InfoS("NodeFeature not verified, skipping...", "NodeFeature name", obj.Name)
1441+
klog.InfoS("NodeFeature not verified, skipping...", "nodefeature", klog.KObj(obj))
14821442
}
14831443
}
14841444
return verifiedObjects, nil

0 commit comments

Comments
 (0)