|
| 1 | +// Copyright (c) 2025, NVIDIA CORPORATION. All rights reserved. |
| 2 | +// |
| 3 | +// Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | +// you may not use this file except in compliance with the License. |
| 5 | +// You may obtain a copy of the License at |
| 6 | +// |
| 7 | +// http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | +// |
| 9 | +// Unless required by applicable law or agreed to in writing, software |
| 10 | +// distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | +// See the License for the specific language governing permissions and |
| 13 | +// limitations under the License. |
| 14 | +package main |
| 15 | + |
| 16 | +import ( |
| 17 | + "context" |
| 18 | + "log/slog" |
| 19 | + "os" |
| 20 | + "os/signal" |
| 21 | + "syscall" |
| 22 | + |
| 23 | + "github.com/nvidia/nvsentinel/commons/pkg/logger" |
| 24 | +) |
| 25 | + |
| 26 | +const ( |
| 27 | + defaultAgentName = "kubernetes-object-monitor" |
| 28 | +) |
| 29 | + |
| 30 | +var ( |
| 31 | + version = "dev" |
| 32 | + commit = "none" |
| 33 | + date = "unknown" |
| 34 | +) |
| 35 | + |
| 36 | +func main() { |
| 37 | + logLevel := os.Getenv("LOG_LEVEL") |
| 38 | + if logLevel == "" { |
| 39 | + logLevel = "info" |
| 40 | + } |
| 41 | + |
| 42 | + logger.SetDefaultStructuredLogger(defaultAgentName, version) |
| 43 | + slog.Info("Starting kubernetes-object-monitor", "version", |
| 44 | + version, "commit", commit, "date", date, "log_level", logLevel) |
| 45 | + |
| 46 | + if err := run(); err != nil { |
| 47 | + slog.Error("Fatal error", "error", err) |
| 48 | + os.Exit(1) |
| 49 | + } |
| 50 | +} |
| 51 | + |
| 52 | +func run() error { |
| 53 | + ctx, stop := signal.NotifyContext(context.Background(), os.Interrupt, syscall.SIGTERM) |
| 54 | + defer stop() |
| 55 | + |
| 56 | + slog.Info("Kubernetes Object Monitor started successfully") |
| 57 | + slog.Info("TODO: Implement controller-runtime based monitor with CEL policy evaluation") |
| 58 | + |
| 59 | + <-ctx.Done() |
| 60 | + |
| 61 | + slog.Info("Shutdown signal received, exiting gracefully") |
| 62 | + |
| 63 | + return nil |
| 64 | +} |
0 commit comments