From b444ef95a8d068d6f21c64ea80e5a87fa3046612 Mon Sep 17 00:00:00 2001 From: Swati Sehgal Date: Tue, 16 Nov 2021 11:58:04 +0000 Subject: [PATCH] NFD-Topology-Updater: Bump NRT API to version v0.0.12 The NodeResourceTopology API has been made cluster scoped as in the current context a CR corresponds to a Node and since Node is a cluster scoped resource it makes sense to make NRT cluster scoped as well. Ref: https://github.com/k8stopologyawareschedwg/noderesourcetopology-api/pull/18 Signed-off-by: Swati Sehgal --- cmd/nfd-master/main.go | 3 --- .../noderesourcetopologies.yaml | 5 ++--- .../helm/node-feature-discovery/templates/master.yaml | 5 ----- .../templates/topologyupdater-crds.yaml | 5 ++--- deployment/helm/node-feature-discovery/values.yaml | 1 - docs/advanced/developer-guide.md | 2 -- docs/get-started/deployment-and-usage.md | 1 - go.mod | 6 +++--- go.sum | 4 ++-- pkg/nfd-master/nfd-master.go | 11 +++++------ 10 files changed, 14 insertions(+), 29 deletions(-) diff --git a/cmd/nfd-master/main.go b/cmd/nfd-master/main.go index f7fda4c349..ca2a576dcf 100644 --- a/cmd/nfd-master/main.go +++ b/cmd/nfd-master/main.go @@ -105,9 +105,6 @@ func initFlags(flagset *flag.FlagSet) *master.Args { flagset.BoolVar(&args.VerifyNodeName, "verify-node-name", false, "Verify worker node name against the worker's TLS certificate. "+ "Only takes effect when TLS authentication has been enabled.") - flagset.StringVar(&args.NRTNamespace, "nrt-namespace", "default", - "Namespace in which Node Resource Topology CR are created"+ - "Ensure that the namespace specified is already exists.") return args } diff --git a/deployment/base/noderesourcetopologies-crd/noderesourcetopologies.yaml b/deployment/base/noderesourcetopologies-crd/noderesourcetopologies.yaml index 299c24db98..b8f81214f3 100644 --- a/deployment/base/noderesourcetopologies-crd/noderesourcetopologies.yaml +++ b/deployment/base/noderesourcetopologies-crd/noderesourcetopologies.yaml @@ -3,10 +3,9 @@ kind: CustomResourceDefinition metadata: annotations: api-approved.kubernetes.io: https://github.com/kubernetes/enhancements/pull/1870 - controller-gen.kubebuilder.io/version: v0.6.0 + controller-gen.kubebuilder.io/version: v0.7.0 creationTimestamp: null name: noderesourcetopologies.topology.node.k8s.io - namespace: "" spec: group: topology.node.k8s.io names: @@ -16,7 +15,7 @@ spec: shortNames: - node-res-topo singular: noderesourcetopology - scope: Namespaced + scope: Cluster versions: - name: v1alpha1 schema: diff --git a/deployment/helm/node-feature-discovery/templates/master.yaml b/deployment/helm/node-feature-discovery/templates/master.yaml index 752ac578de..63dea55d08 100644 --- a/deployment/helm/node-feature-discovery/templates/master.yaml +++ b/deployment/helm/node-feature-discovery/templates/master.yaml @@ -62,11 +62,6 @@ spec: {{- if .Values.master.extraLabelNs | empty | not }} - "--extra-label-ns={{- join "," .Values.master.extraLabelNs }}" {{- end }} - {{- if .Values.master.topologyUpdaterNs | empty }} - - "--nrt-namespace={{ $.Release.Namespace }}" - {{- else }} - - "--nrt-namespace={{ .Values.master.topologyUpdaterNs }}" - {{- end }} ## Enable TLS authentication ## The example below assumes having the root certificate named ca.crt stored in ## a ConfigMap named nfd-ca-cert, and, the TLS authentication credentials stored diff --git a/deployment/helm/node-feature-discovery/templates/topologyupdater-crds.yaml b/deployment/helm/node-feature-discovery/templates/topologyupdater-crds.yaml index b6098f14d8..cf5daf27b8 100644 --- a/deployment/helm/node-feature-discovery/templates/topologyupdater-crds.yaml +++ b/deployment/helm/node-feature-discovery/templates/topologyupdater-crds.yaml @@ -4,10 +4,9 @@ kind: CustomResourceDefinition metadata: annotations: api-approved.kubernetes.io: https://github.com/kubernetes/enhancements/pull/1870 - controller-gen.kubebuilder.io/version: v0.6.0 + controller-gen.kubebuilder.io/version: v0.7.0 creationTimestamp: null name: noderesourcetopologies.topology.node.k8s.io - namespace: "" spec: group: topology.node.k8s.io names: @@ -17,7 +16,7 @@ spec: shortNames: - node-res-topo singular: noderesourcetopology - scope: Namespaced + scope: Cluster versions: - name: v1alpha1 schema: diff --git a/deployment/helm/node-feature-discovery/values.yaml b/deployment/helm/node-feature-discovery/values.yaml index 349afdcb2d..6c2f448066 100644 --- a/deployment/helm/node-feature-discovery/values.yaml +++ b/deployment/helm/node-feature-discovery/values.yaml @@ -27,7 +27,6 @@ master: podSecurityContext: {} # fsGroup: 2000 - topologyUpdaterNs: "" securityContext: allowPrivilegeEscalation: false capabilities: diff --git a/docs/advanced/developer-guide.md b/docs/advanced/developer-guide.md index fbd9fb4508..b6eb7b1ef9 100644 --- a/docs/advanced/developer-guide.md +++ b/docs/advanced/developer-guide.md @@ -184,8 +184,6 @@ Usage of nfd-master: Comma separated list of labels to be exposed as extended resources. -verify-node-name Verify worker node name against the worker's TLS certificate. Only takes effect when TLS authentication has been enabled. - -nrt-namespace - Namespace in which Node Resource Topology CR are created. Ensure that the namespace specified already exists -version Print version and exit. ``` diff --git a/docs/get-started/deployment-and-usage.md b/docs/get-started/deployment-and-usage.md index 8bcf4d7f6c..b4f7dd081e 100644 --- a/docs/get-started/deployment-and-usage.md +++ b/docs/get-started/deployment-and-usage.md @@ -298,7 +298,6 @@ We have introduced the following Chart parameters. | `master.*` | dict | | NFD master deployment configuration | | `master.instance` | string | | Instance name. Used to separate annotation namespaces for multiple parallel deployments | | `master.extraLabelNs` | array | [] | List of allowed extra label namespaces | -| `master.topologyUpdaterNs` | string | "" | Namespace in which Node Resource Topology CR are created, the namespace specified must be already existed. | | `master.replicaCount` | integer | 1 | Number of desired pods. This is a pointer to distinguish between explicit zero and not specified | | `master.podSecurityContext` | dict | {} | SecurityContext holds pod-level security attributes and common container settings | | `master.service.type` | string | ClusterIP | NFD master service type | diff --git a/go.mod b/go.mod index e1efd2ed8f..ca05696220 100644 --- a/go.mod +++ b/go.mod @@ -8,7 +8,7 @@ require ( github.com/golang/protobuf v1.5.2 github.com/google/go-cmp v0.5.5 github.com/jaypipes/ghw v0.8.1-0.20210827132705-c7224150a17e - github.com/k8stopologyawareschedwg/noderesourcetopology-api v0.0.10 + github.com/k8stopologyawareschedwg/noderesourcetopology-api v0.0.12 github.com/klauspost/cpuid/v2 v2.0.9 github.com/onsi/ginkgo v1.14.0 github.com/onsi/gomega v1.10.1 @@ -20,8 +20,8 @@ require ( google.golang.org/grpc v1.38.0 google.golang.org/protobuf v1.27.1 k8s.io/api v0.22.0 - k8s.io/apimachinery v0.22.0 - k8s.io/client-go v0.22.0 + k8s.io/apimachinery v0.22.3 + k8s.io/client-go v0.22.3 k8s.io/klog/v2 v2.9.0 k8s.io/kubelet v0.0.0 k8s.io/kubernetes v1.22.0 diff --git a/go.sum b/go.sum index 81541fed71..f3eb623de8 100644 --- a/go.sum +++ b/go.sum @@ -416,8 +416,8 @@ github.com/jtolds/gls v4.20.0+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfV github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w= github.com/julienschmidt/httprouter v1.3.0/go.mod h1:JR6WtHb+2LUe8TCKY3cZOxFyyO8IZAc4RVcycCCAKdM= github.com/jung-kurt/gofpdf v1.0.3-0.20190309125859-24315acbbda5/go.mod h1:7Id9E/uU8ce6rXgefFLlgrJj/GYY22cpxn+r32jIOes= -github.com/k8stopologyawareschedwg/noderesourcetopology-api v0.0.10 h1:wHS+TOQfFY67wkS1roZ5WVyihnE/IQmVsD0zzKtzHrU= -github.com/k8stopologyawareschedwg/noderesourcetopology-api v0.0.10/go.mod h1:yJo22okt35DQhvNw3Hgpaol6/oryET8Y5n1CJb9R5mM= +github.com/k8stopologyawareschedwg/noderesourcetopology-api v0.0.12 h1:NhXbOjO1st8hIcVpegr3zw/AGG12vs3z//tCDDcfPpE= +github.com/k8stopologyawareschedwg/noderesourcetopology-api v0.0.12/go.mod h1:AkACMQGiTgCt0lQw3m7TTU8PLH9lYKNK5e9DqFf5VuM= github.com/karrick/godirwalk v1.16.1 h1:DynhcF+bztK8gooS0+NDJFrdNZjJ3gzVzC545UNA9iw= github.com/karrick/godirwalk v1.16.1/go.mod h1:j4mkqPuvaLI8mp1DroR3P6ad7cyYd4c1qeJ3RV7ULlk= github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8= diff --git a/pkg/nfd-master/nfd-master.go b/pkg/nfd-master/nfd-master.go index 1a681323fb..c629bfe452 100644 --- a/pkg/nfd-master/nfd-master.go +++ b/pkg/nfd-master/nfd-master.go @@ -94,7 +94,6 @@ type Args struct { Prune bool VerifyNodeName bool ResourceLabels utils.StringSetVal - NRTNamespace string } type NfdMaster interface { @@ -447,7 +446,7 @@ func (m *nfdMaster) UpdateNodeTopology(c context.Context, r *topologypb.NodeTopo klog.Infof("received CR updation request for node %q", r.NodeName) } if !m.args.NoPublish { - err := m.updateCR(r.NodeName, r.TopologyPolicies, r.Zones, m.args.NRTNamespace) + err := m.updateCR(r.NodeName, r.TopologyPolicies, r.Zones) if err != nil { klog.Errorf("failed to advertise NodeResourceTopology: %w", err) return &topologypb.NodeTopologyResponse{}, err @@ -642,7 +641,7 @@ func modifyCR(topoUpdaterZones []*v1alpha1.Zone) []v1alpha1.Zone { return zones } -func (m *nfdMaster) updateCR(hostname string, tmpolicy []string, topoUpdaterZones []*v1alpha1.Zone, namespace string) error { +func (m *nfdMaster) updateCR(hostname string, tmpolicy []string, topoUpdaterZones []*v1alpha1.Zone) error { cli, err := m.apihelper.GetTopologyClient() if err != nil { return err @@ -650,7 +649,7 @@ func (m *nfdMaster) updateCR(hostname string, tmpolicy []string, topoUpdaterZone zones := modifyCR(topoUpdaterZones) - nrt, err := cli.TopologyV1alpha1().NodeResourceTopologies(namespace).Get(context.TODO(), hostname, metav1.GetOptions{}) + nrt, err := cli.TopologyV1alpha1().NodeResourceTopologies().Get(context.TODO(), hostname, metav1.GetOptions{}) if errors.IsNotFound(err) { nrtNew := v1alpha1.NodeResourceTopology{ ObjectMeta: metav1.ObjectMeta{ @@ -660,7 +659,7 @@ func (m *nfdMaster) updateCR(hostname string, tmpolicy []string, topoUpdaterZone TopologyPolicies: tmpolicy, } - _, err := cli.TopologyV1alpha1().NodeResourceTopologies(namespace).Create(context.TODO(), &nrtNew, metav1.CreateOptions{}) + _, err := cli.TopologyV1alpha1().NodeResourceTopologies().Create(context.TODO(), &nrtNew, metav1.CreateOptions{}) if err != nil { return fmt.Errorf("failed to create v1alpha1.NodeResourceTopology!:%w", err) } @@ -672,7 +671,7 @@ func (m *nfdMaster) updateCR(hostname string, tmpolicy []string, topoUpdaterZone nrtMutated := nrt.DeepCopy() nrtMutated.Zones = zones - nrtUpdated, err := cli.TopologyV1alpha1().NodeResourceTopologies(namespace).Update(context.TODO(), nrtMutated, metav1.UpdateOptions{}) + nrtUpdated, err := cli.TopologyV1alpha1().NodeResourceTopologies().Update(context.TODO(), nrtMutated, metav1.UpdateOptions{}) if err != nil { return fmt.Errorf("failed to update v1alpha1.NodeResourceTopology!:%w", err) }