Skip to content

Commit

Permalink
Merge pull request #1976 from marquiz/devel/grpc-api-cleanup
Browse files Browse the repository at this point in the history
Cleanup for NodeFeature API being GA
  • Loading branch information
k8s-ci-robot authored Dec 13, 2024
2 parents caaac59 + fc103a6 commit 3e87c97
Show file tree
Hide file tree
Showing 17 changed files with 38 additions and 134 deletions.
6 changes: 2 additions & 4 deletions cmd/nfd-master/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -142,11 +142,9 @@ func initFlags(flagset *flag.FlagSet) (*master.Args, *master.ConfigOverrideArgs)
"Do not publish feature labels")
flagset.Var(overrides.DenyLabelNs, "deny-label-ns",
"Comma separated list of denied label namespaces")
flagset.Var(overrides.ResyncPeriod, "resync-period",
"Specify the NFD API controller resync period."+
"It does not have effect when the NodeFeature API has been disabled (with -feature-gates NodeFeatureAPI=false).")
flagset.Var(overrides.ResyncPeriod, "resync-period", "Specify the NFD API controller resync period.")
overrides.NfdApiParallelism = flagset.Int("nfd-api-parallelism", 10, "Defines the maximum number of goroutines responsible of updating nodes. "+
"Can be used for the throttling mechanism. It does not have effect if NodeFeatureAPI feature gate is disabled.")
"Can be used for the throttling mechanism.")

return args, overrides
}
2 changes: 0 additions & 2 deletions deployment/base/worker-daemonset/worker-daemonset.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,6 @@ spec:
requests:
cpu: 5m
memory: 64Mi
args:
- "-server=nfd-master:8080"
ports:
- name: metrics
containerPort: 8081
2 changes: 0 additions & 2 deletions deployment/base/worker-job/worker-job.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,5 +33,3 @@ spec:
- "nfd-worker"
args:
- "-oneshot"
- "-server=nfd-master:8080"

Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ rules:
- update
{{- end }}

{{- if and .Values.gc.enable .Values.gc.rbac.create (or .Values.featureGates.NodeFeatureAPI .Values.topologyUpdater.enable) }}
{{- if and .Values.gc.enable .Values.gc.rbac.create }}
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ subjects:
namespace: {{ include "node-feature-discovery.namespace" . }}
{{- end }}

{{- if and .Values.gc.enable .Values.gc.rbac.create (or .Values.featureGates.NodeFeatureAPI .Values.topologyUpdater.enable) }}
{{- if and .Values.gc.enable .Values.gc.rbac.create }}
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
Expand Down
2 changes: 0 additions & 2 deletions deployment/helm/node-feature-discovery/templates/master.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,6 @@ spec:
successThreshold: {{ . }}
{{- end }}
ports:
- containerPort: {{ .Values.master.port | default "8080" }}
name: grpc
- containerPort: {{ .Values.master.metricsPort | default "8081" }}
name: metrics
- containerPort: {{ .Values.master.healthPort | default "8082" }}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{{- if and .Values.gc.enable (or .Values.featureGates.NodeFeatureAPI .Values.topologyUpdater.enable) -}}
{{- if and .Values.gc.enable -}}
apiVersion: apps/v1
kind: Deployment
metadata:
Expand Down
20 changes: 0 additions & 20 deletions deployment/helm/node-feature-discovery/templates/service.yaml

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ metadata:
{{- end }}
{{- end }}

{{- if and .Values.gc.enable .Values.gc.serviceAccount.create (or .Values.featureGates.NodeFeatureAPI .Values.topologyUpdater.enable) }}
{{- if and .Values.gc.enable .Values.gc.serviceAccount.create }}
---
apiVersion: v1
kind: ServiceAccount
Expand Down
3 changes: 0 additions & 3 deletions deployment/helm/node-feature-discovery/templates/worker.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -100,9 +100,6 @@ spec:
command:
- "nfd-worker"
args:
{{- if not .Values.featureGates.NodeFeatureAPI }}
- "-server={{ include "node-feature-discovery.fullname" . }}-master:{{ .Values.master.service.port }}"
{{- end }}
# Go over featureGate and add the feature-gate flag
{{- range $key, $value := .Values.featureGates }}
- "-feature-gates={{ $key }}={{ $value }}"
Expand Down
5 changes: 0 additions & 5 deletions deployment/helm/node-feature-discovery/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ fullnameOverride: ""
namespaceOverride: ""

featureGates:
NodeFeatureAPI: true
NodeFeatureGroupAPI: false

priorityClassName: ""
Expand Down Expand Up @@ -106,10 +105,6 @@ master:
rbac:
create: true

service:
type: ClusterIP
port: 8080

resources:
limits:
memory: 4Gi
Expand Down
1 change: 0 additions & 1 deletion docs/deployment/helm.md
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,6 @@ Chart parameters are available.
| `imagePullSecrets` | array | [] | ImagePullSecrets is an optional list of references to secrets in the same namespace to use for pulling any of the images used by this PodSpec. [More info](https://kubernetes.io/docs/concepts/containers/images#specifying-imagepullsecrets-on-a-pod). |
| `nameOverride` | string | | Override the name of the chart |
| `fullnameOverride` | string | | Override a default fully qualified app name |
| `featureGates.NodeFeatureAPI` | bool | true | Enable the [NodeFeature](../usage/custom-resources.md#nodefeature) CRD API for communicating node features. This will automatically disable the gRPC communication. |
| `featureGates.NodeFeatureGroupAPI` | bool | false | Enable the [NodeFeatureGroup](../usage/custom-resources.md#nodefeaturegroup) CRD API. |
| `featureGates.DisableAutoPrefix` | bool | false | Enable [DisableAutoPrefix](../reference/feature-gates.md#disableautoprefix) feature gate. Disables automatic prefixing of unprefixed labels, annotations and extended resources. |
| `prometheus.enable` | bool | false | Specifies whether to expose metrics using prometheus operator |
Expand Down
65 changes: 30 additions & 35 deletions docs/developer-guide/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -173,58 +173,53 @@ e2e-tests:

### NFD-Master

When running as a standalone container labeling is expected to fail because
Kubernetes API is not available. Thus, it is recommended to use `-no-publish`.
For development and debugging it is possible to run nfd-master as a stand-alone
binary outside the cluster. The `-no-publish` flag can be used to prevent
nfd-master making changes to the nodes. If `-no-publish` is not set, nfd-master
also requires the `NODE_NAME` environment variable to be set for cleaning up
stale annotations.

```bash
$ export NFD_CONTAINER_IMAGE={{ site.container_image }}
$ docker run --rm --name=nfd-test ${NFD_CONTAINER_IMAGE} nfd-master -no-publish -crd-controller=false -feature-gates NodeFeatureAPI=false
2019/02/01 14:48:21 Node Feature Discovery Master <NFD_VERSION>
make build
NODE_NAME=<EXISTING_NODE> ./nfd-master -no-publish -kubeconfig ~/.kube/config
```

### NFD-Worker

To run nfd-worker as a "stand-alone" container you need to run it in the same
network namespace as the nfd-master container:
For development and debugging it is possible to run nfd-worker as a stand-alone
binary outside the cluster. The `-no-publish` flag can be used to prevent
nfd-worker from creating NodeFeature objects in the target cluster. If the
`-no-publish` is not set, nfd-worker also requires the `NODE_NAME` and
`KUBERNETES_NAMESPACE` environment variables to be defined to create the
NodeFeature object in the target cluster.

```bash
$ docker run --rm --network=container:nfd-test ${NFD_CONTAINER_IMAGE} nfd-worker -feature-gates NodeFeatureAPI=false
2019/02/01 14:48:56 Node Feature Discovery Worker <NFD_VERSION>
...
make build
KUBERNETES_NAMESPACE=default NODE_NAME=nonexistent-node ./bin/nfd-worker -kubeconfig ~/.kube/config
```

If you just want to try out feature discovery without connecting to nfd-master,
pass the `-no-publish` flag to nfd-worker.

> **NOTE:** Some feature sources need certain directories and/or files from the
> host mounted inside the NFD container. Thus, you need to provide Docker with
> the correct `--volume` options for them to work correctly when run
> stand-alone directly with `docker run`. See
> the [default deployment](https://github.com/kubernetes-sigs/node-feature-discovery/blob/{{site.release}}/deployment/components/common/worker-mounts.yaml)
> for up-to-date information about the required volume mounts.
> **NOTE:** Running nfd-worker locally this way discovers and publishes
> features of the local development system you're running nfd-worker on.
### NFD-Topology-Updater
To run nfd-topology-updater as a "stand-alone" container
you need to run it in with the `-no-publish` flag to disable communication to
the Kubernetes apiserver.
For development and debugging it is possible to run nfd-topology-updater as a
stand-alone binary outside the cluster. However, it requires access to the
kubelet's local pod-resources socket and the kubelet http api so in practice it
needs to be run on a host acting as a Kubernetes node and thus running
kubelet. Running kubelet with `--read-only-port=10255` (or `readOnlyPort:
10255` in config) makes it possible to connect to kubelet without auth-token
(never do this in a production cluster). Also, the `-no-publish` flag can be
used to prevent nfd-topology-updater from creating NodeResourceTopology objects
in the target cluster. If the `-no-publish` is not set, nfd-topology-updater
also requires the `NODE_NAME` and `KUBERNETES_NAMESPACE` environment variables
to be defined.

```bash
$ docker run --rm ${NFD_CONTAINER_IMAGE} nfd-topology-updater -no-publish
2019/02/01 14:48:56 Node Feature Discovery Topology Updater <NFD_VERSION>
...
make build
KUBERNETES_NAMESPACE=default NODE_NAME=nonexistent-node ./bin/nfd-topology-updater -kubeconfig ~/.kube/config -kubelet-config-uri http://127.0.0.1:10255
```

If you just want to try out resource topology discovery without connecting to
the Kubernetes API, pass the `-no-publish` flag to nfd-topology-updater.

> **NOTE:** NFD topology updater needs certain directories and/or files from
> the host mounted inside the NFD container. Thus, you need to provide Docker
> with the correct `--volume` options for them to work correctly when
> run stand-alone directly with `docker run`. See
> the [template spec](https://github.com/kubernetes-sigs/node-feature-discovery/blob/{{site.release}}/deployment/components/topology-updater/topologyupdater-mounts.yaml)
> for up-to-date information about the required volume mounts.

## Running with Tilt

Another option for building NFD locally is via Tilt tool, which can build container
Expand Down
1 change: 0 additions & 1 deletion docs/get-started/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ $ kubectl apply -k https://github.com/kubernetes-sigs/node-feature-discovery/dep
clusterrole.rbac.authorization.k8s.io/nfd-master created
clusterrolebinding.rbac.authorization.k8s.io/nfd-master created
configmap/nfd-worker-conf created
service/nfd-master created
deployment.apps/nfd-master created
daemonset.apps/nfd-worker created

Expand Down
3 changes: 1 addition & 2 deletions pkg/nfd-master/nfd-master.go
Original file line number Diff line number Diff line change
Expand Up @@ -521,8 +521,7 @@ func (m *nfdMaster) updateMasterNode() error {

// Filter labels by namespace and name whitelist, and, turn selected labels
// into extended resources. This function also handles proper namespacing of
// labels and ERs, i.e. adds the possibly missing default namespace for labels
// arriving through the gRPC API.
// labels and ERs, i.e. adds the possibly missing default namespace for labels.
func (m *nfdMaster) filterFeatureLabels(labels Labels, features *nfdv1alpha1.Features) Labels {
outLabels := Labels{}
for name, value := range labels {
Expand Down
9 changes: 1 addition & 8 deletions test/e2e/node_feature_discovery_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ import (
clientset "k8s.io/client-go/kubernetes"
taintutils "k8s.io/kubernetes/pkg/util/taints"
"k8s.io/kubernetes/test/e2e/framework"
e2enetwork "k8s.io/kubernetes/test/e2e/framework/network"
e2epod "k8s.io/kubernetes/test/e2e/framework/pod"
admissionapi "k8s.io/pod-security-admission/api"

Expand Down Expand Up @@ -242,19 +241,13 @@ var _ = NFDDescribe(Label("nfd-master"), func() {
cleanupNode(ctx, f.ClientSet)

// Launch nfd-master
By("Creating nfd master pod and nfd-master service")
By("Creating nfd master pod")
podSpecOpts := append(extraMasterPodSpecOpts, testpod.SpecWithContainerImage(dockerImage()))

masterPod := e2epod.NewPodClient(f).CreateSync(ctx, testpod.NFDMaster(podSpecOpts...))

// Create nfd-master service
nfdSvc, err := testutils.CreateService(ctx, f.ClientSet, f.Namespace.Name)
Expect(err).NotTo(HaveOccurred())

By("Waiting for the nfd-master pod to be running")
Expect(e2epod.WaitTimeoutForPodRunningInNamespace(ctx, f.ClientSet, masterPod.Name, masterPod.Namespace, time.Minute)).NotTo(HaveOccurred())
By("Waiting for the nfd-master service to be up")
Expect(e2enetwork.WaitForService(ctx, f.ClientSet, f.Namespace.Name, nfdSvc.Name, true, time.Second, 10*time.Second)).NotTo(HaveOccurred())
})

AfterEach(func(ctx context.Context) {
Expand Down
45 changes: 0 additions & 45 deletions test/e2e/utils/service.go

This file was deleted.

0 comments on commit 3e87c97

Please sign in to comment.