-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from ykulazhenkov/impl
Add initial implementation
- Loading branch information
Showing
12 changed files
with
801 additions
and
56 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,73 @@ | ||
# network-operator-init-container | ||
Init container for NVIDIA Network Operator | ||
|
||
The network-operator-init-container container has two required command line arguments: | ||
|
||
- `--config` path to the configuration file | ||
- `--node-name` name of the k8s node on which this app runs | ||
|
||
The configuration file should be in JSON format: | ||
|
||
``` | ||
{ | ||
"safeDriverLoad": { | ||
"enable": true, | ||
"annotation": "some-annotation" | ||
} | ||
} | ||
``` | ||
|
||
- `safeDriverLoad` - contains settings related to safeDriverLoad feature | ||
- `safeDriverLoad.enable` - enable safeDriveLoad feature | ||
- `safeDriverLoad.annotation` - annotation to use for safeDriverLoad feature | ||
|
||
|
||
If `safeDriverLoad` feature is enabled then the network-operator-init-container container will set annotation | ||
provided in `safeDriverLoad.annotation` on the Kubernetes Node object identified by `--node-name`. | ||
The container exits with code 0 when the annotation is removed from the Node object. | ||
|
||
If `safeDriverLoad` feature is disabled then the container will immediately exit with code 0. | ||
|
||
``` | ||
NVIDIA Network Operator init container | ||
Usage: | ||
network-operator-init-container [flags] | ||
Config flags: | ||
--config string | ||
path to the configuration file | ||
--node-name string | ||
name of the k8s node on which this app runs | ||
Logging flags: | ||
--log-flush-frequency duration | ||
Maximum number of seconds between log flushes (default 5s) | ||
--log-json-info-buffer-size quantity | ||
[Alpha] In JSON format with split output streams, the info messages can be buffered for a while to increase performance. The default value of zero bytes disables buffering. The size can | ||
be specified as number of bytes (512), multiples of 1000 (1K), multiples of 1024 (2Ki), or powers of those (3M, 4G, 5Mi, 6Gi). Enable the LoggingAlphaOptions feature gate to use this. | ||
--log-json-split-stream | ||
[Alpha] In JSON format, write error messages to stderr and info messages to stdout. The default is to write a single stream to stdout. Enable the LoggingAlphaOptions feature gate to use | ||
this. | ||
--logging-format string | ||
Sets the log format. Permitted formats: "json" (gated by LoggingBetaOptions), "text". (default "text") | ||
-v, --v Level | ||
number for the log level verbosity | ||
--vmodule pattern=N,... | ||
comma-separated list of pattern=N settings for file-filtered logging (only works for text log format) | ||
General flags: | ||
-h, --help | ||
print help and exit | ||
--version | ||
print version and exit | ||
Kubernetes flags: | ||
--kubeconfig string | ||
Paths to a kubeconfig. Only required if out-of-cluster. | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
/* | ||
Copyright 2023, NVIDIA CORPORATION & AFFILIATES | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
|
||
package app_test | ||
|
||
import ( | ||
"context" | ||
"testing" | ||
|
||
. "github.com/onsi/ginkgo/v2" | ||
. "github.com/onsi/gomega" | ||
"k8s.io/client-go/kubernetes/scheme" | ||
"k8s.io/client-go/rest" | ||
"sigs.k8s.io/controller-runtime/pkg/client" | ||
"sigs.k8s.io/controller-runtime/pkg/envtest" | ||
) | ||
|
||
var ( | ||
cfg *rest.Config | ||
k8sClient client.Client | ||
testEnv *envtest.Environment | ||
cFunc context.CancelFunc | ||
ctx context.Context | ||
) | ||
|
||
func TestApp(t *testing.T) { | ||
RegisterFailHandler(Fail) | ||
RunSpecs(t, "Network Operator Init Container Suite") | ||
} | ||
|
||
var _ = BeforeSuite(func() { | ||
By("bootstrapping test environment") | ||
testEnv = &envtest.Environment{} | ||
ctx, cFunc = context.WithCancel(context.Background()) | ||
|
||
var err error | ||
// cfg is defined in this file globally. | ||
cfg, err = testEnv.Start() | ||
Expect(err).NotTo(HaveOccurred()) | ||
Expect(cfg).NotTo(BeNil()) | ||
|
||
k8sClient, err = client.New(cfg, client.Options{Scheme: scheme.Scheme}) | ||
Expect(err).NotTo(HaveOccurred()) | ||
Expect(k8sClient).NotTo(BeNil()) | ||
|
||
createNode(testNodeName) | ||
}) | ||
|
||
var _ = AfterSuite(func() { | ||
cFunc() | ||
By("tearing down the test environment") | ||
err := testEnv.Stop() | ||
Expect(err).NotTo(HaveOccurred()) | ||
}) |
Oops, something went wrong.