@@ -20,6 +20,7 @@ import (
2020 "context"
2121 "fmt"
2222
23+ directpvtypes "github.com/minio/directpv/pkg/apis/directpv.min.io/types"
2324 "github.com/minio/directpv/pkg/consts"
2425 "github.com/minio/directpv/pkg/k8s"
2526 legacyclient "github.com/minio/directpv/pkg/legacy/client"
@@ -203,12 +204,12 @@ func livenessProbeContainer(image string) corev1.Container {
203204 }
204205}
205206
206- func newDaemonset (podSpec corev1.PodSpec , name , selectorValue , appArmorProfile string ) * appsv1.DaemonSet {
207+ func newDaemonset (podSpec corev1.PodSpec , name , selectorValue string , args * Args ) * appsv1.DaemonSet {
207208 annotations := map [string ]string {createdByLabel : pluginName }
208- if appArmorProfile != "" {
209+ if args . AppArmorProfile != "" {
209210 // AppArmor profiles need to be specified per-container
210211 for _ , container := range podSpec .Containers {
211- annotations ["container.apparmor.security.beta.kubernetes.io/" + container .Name ] = "localhost/" + appArmorProfile
212+ annotations ["container.apparmor.security.beta.kubernetes.io/" + container .Name ] = "localhost/" + args . AppArmorProfile
212213 }
213214 }
214215
@@ -218,10 +219,13 @@ func newDaemonset(podSpec corev1.PodSpec, name, selectorValue, appArmorProfile s
218219 Kind : "DaemonSet" ,
219220 },
220221 ObjectMeta : metav1.ObjectMeta {
221- Name : name ,
222- Namespace : namespace ,
223- Annotations : map [string ]string {},
224- Labels : defaultLabels ,
222+ Name : name ,
223+ Namespace : namespace ,
224+ Annotations : map [string ]string {
225+ string (directpvtypes .ImageTagLabelKey ): args .imageTag ,
226+ string (directpvtypes .PluginVersionLabelKey ): args .PluginVersion ,
227+ },
228+ Labels : defaultLabels ,
225229 },
226230 Spec : appsv1.DaemonSetSpec {
227231 Selector : metav1 .AddLabelToSelector (& metav1.LabelSelector {}, selectorKey , selectorValue ),
@@ -302,7 +306,7 @@ func doCreateDaemonset(ctx context.Context, args *Args) (err error) {
302306 selectorValue = fmt .Sprintf ("%v-%v" , consts .Identity , getRandSuffix ())
303307 }
304308
305- daemonset := newDaemonset (podSpec , consts .NodeServerName , selectorValue , args . AppArmorProfile )
309+ daemonset := newDaemonset (podSpec , consts .NodeServerName , selectorValue , args )
306310
307311 if ! args .DryRun && ! args .Declarative {
308312 _ , err = k8s .KubeClient ().AppsV1 ().DaemonSets (namespace ).Create (
@@ -365,7 +369,7 @@ func doCreateLegacyDaemonset(ctx context.Context, args *Args) (err error) {
365369 selectorValue = fmt .Sprintf ("%v-%v" , consts .Identity , getRandSuffix ())
366370 }
367371
368- daemonset := newDaemonset (podSpec , consts .LegacyNodeServerName , selectorValue , args . AppArmorProfile )
372+ daemonset := newDaemonset (podSpec , consts .LegacyNodeServerName , selectorValue , args )
369373
370374 if ! args .DryRun && ! args .Declarative {
371375 _ , err = k8s .KubeClient ().AppsV1 ().DaemonSets (namespace ).Create (
0 commit comments