-
Notifications
You must be signed in to change notification settings - Fork 159
feat(machine-a-tron): k8s controller for mock BMC services #3955
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
akorobkov-nvda
wants to merge
15
commits into
NVIDIA:main
Choose a base branch
from
akorobkov-nvda:feat/machine-a-tron-k8s-ctrl
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+2,365
−8
Open
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
5930f36
feat(machine-a-tron): k8s controller
akorobkov-nvda 6d1ccdc
feat(helm): machine-a-tron controller subchart
akorobkov-nvda f1fea7e
fix(mat-ctrl): machine-a-tron controller update
akorobkov-nvda 18c3681
fix(helm): machine-a-tron controller chart
akorobkov-nvda 4ebbfd9
fix: machine-a-tron controller clusterip logic
akorobkov-nvda 3e15221
fix: machine-a-tron controller pod discovery
akorobkov-nvda b3f6a4f
fix: machine-a-tron controller pod selector
akorobkov-nvda 417d1c2
fix(machine-a-tron-ctrl): pr review issues
akorobkov-nvda 0c7d2e6
feat(machine-a-tron-ctrl): image build
akorobkov-nvda f460d8c
fix(machine-a-tron-ctrl): dockerfile
akorobkov-nvda 95f5118
fix(machine-a-tron-ctrl): pr review
akorobkov-nvda 02fbec4
fix(machine-a-tron-ctrl): pr review
akorobkov-nvda 5068f1b
fix(machine-a-tron-ctrl): pr review
akorobkov-nvda c6f79b9
fix(machine-a-tron-ctrl): services and target selectore
akorobkov-nvda 188faa6
fix(machine-a-tron-ctrl): service short name
akorobkov-nvda File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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,22 @@ | ||
| # SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. | ||
| # SPDX-License-Identifier: Apache-2.0 | ||
|
|
||
| # Build stage | ||
| FROM golang:1.26.4-alpine@sha256:3ad57304ad93bbec8548a0437ad9e06a455660655d9af011d58b993f6f615648 AS builder | ||
|
|
||
| WORKDIR /app | ||
|
|
||
| COPY go.mod go.sum ./ | ||
| RUN go mod download | ||
|
|
||
| COPY . . | ||
| RUN CGO_ENABLED=0 GOOS=linux go build -ldflags="-s -w" -o mat-k8s-controller ./cmd/mat-k8s-controller | ||
|
|
||
| # Runtime stage | ||
| FROM gcr.io/distroless/static:nonroot@sha256:f7f8f729987ad0fdf6b05eeeae94b26e6a0f613bdf46feea7fc40f7bd72953e6 | ||
|
|
||
| COPY --from=builder /app/mat-k8s-controller /mat-k8s-controller | ||
|
|
||
| USER nonroot:nonroot | ||
|
|
||
| ENTRYPOINT ["/mat-k8s-controller"] |
This file contains hidden or 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,39 @@ | ||
| # SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. | ||
| # SPDX-License-Identifier: Apache-2.0 | ||
|
|
||
| .PHONY: all build test test-coverage lint fmt docker-build docker-build-latest clean run verify | ||
|
|
||
| TAG ?= dev | ||
|
|
||
| all: build | ||
|
|
||
| build: | ||
| @mkdir -p bin | ||
| go build -o bin/mat-k8s-controller ./cmd/mat-k8s-controller | ||
|
|
||
| test: | ||
| go test -v ./... | ||
|
|
||
| test-coverage: | ||
| go test -coverprofile=coverage.out ./... | ||
| go tool cover -html=coverage.out -o coverage.html | ||
|
|
||
| lint: | ||
| golangci-lint run ./... | ||
|
|
||
| fmt: | ||
| go fmt ./... | ||
|
|
||
| docker-build: | ||
| docker build -t mat-k8s-controller:$(TAG) . | ||
|
|
||
| docker-build-latest: | ||
| docker build -t mat-k8s-controller:latest . | ||
|
|
||
| clean: | ||
| rm -rf bin/ coverage.out coverage.html | ||
|
|
||
| run: | ||
| go run ./cmd/mat-k8s-controller --kubeconfig=$(KUBECONFIG) --log-level=debug | ||
|
|
||
| verify: lint test |
This file contains hidden or 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,114 @@ | ||
| # Machine-a-tron Kubernetes Controller | ||
|
|
||
| Kubernetes controller that auto-discovers machine-a-tron pods and creates | ||
| Services for mock BMC endpoints. | ||
|
|
||
| ## Features | ||
|
|
||
| - Auto-discovers machine-a-tron pods via `nvidia-infra-controller/mat-service=true` | ||
| label | ||
| - Creates ClusterIP Services with BMC IP for each mock BMC | ||
| - Supports Redfish (TCP 443) ports | ||
| - Multi-pod deployments with pod-specific routing | ||
| - Automatic cleanup of stale Services | ||
|
|
||
| ## Build | ||
|
|
||
| ```bash | ||
| docker build -t mat-k8s-controller:latest . | ||
| kind load docker-image mat-k8s-controller:latest --name <cluster> | ||
| ``` | ||
|
|
||
| ## Configuration | ||
|
|
||
| | Flag | Env Var | Default | Description | | ||
| |------|---------|---------|-------------| | ||
| | `--namespace` | `NAMESPACE` | `nico-system` | Kubernetes namespace | | ||
| | `--discovery-selector` | `DISCOVERY_SELECTOR` | `nvidia-infra-controller/mat-service=true` | Label selector for discovery | | ||
| | `--sync-interval` | `SYNC_INTERVAL` | `30s` | Reconciliation interval | | ||
| | `--target-selector` | `TARGET_SELECTOR` | `app.kubernetes.io/name=nico-machine-a-tron` | Pod selector for Services | | ||
| | `--insecure-skip-verify` | `INSECURE_SKIP_VERIFY` | `false` | Skip TLS verification (dev only) | | ||
| | `--log-level` | `LOG_LEVEL` | `info` | Log level | | ||
| | `--bmc-mock-port` | `BMC_MOCK_PORT` | `1266` | BMC mock service port | | ||
| | `--kubeconfig` | `KUBECONFIG` | (empty) | Path to kubeconfig (dev only, uses in-cluster config if empty) | | ||
|
|
||
| ## Helm Deployment | ||
|
|
||
| Enable in parent chart: | ||
|
|
||
| ```yaml | ||
| mat-k8s-controller: | ||
| enabled: true | ||
| image: | ||
| pullPolicy: Never # For local images | ||
| config: | ||
| insecureSkipVerify: true # Only for dev with self-signed certs | ||
| ``` | ||
|
|
||
| ## Service Structure | ||
|
|
||
| Created Services have: | ||
|
|
||
| **Labels:** | ||
|
|
||
| - `app.kubernetes.io/managed-by: mat-k8s-controller` | ||
| - `nvidia-infra-controller/mat-id: <uuid>` | ||
| - `nvidia-infra-controller/mat-machine-type: host|dpu` | ||
| - `nvidia-infra-controller/pod-name: <pod>` (multi-pod) | ||
|
|
||
| **Annotations:** | ||
|
|
||
| - `nvidia-infra-controller/mat-bmc-ip` | ||
| - `nvidia-infra-controller/mat-api-state` | ||
| - `nvidia-infra-controller/mat-power-state` | ||
| - `nvidia-infra-controller/mat-hardware-type` | ||
|
|
||
| ## Development | ||
|
|
||
| ```bash | ||
| make build | ||
| make test | ||
| make run KUBECONFIG="$HOME/.kube/config" | ||
| ``` | ||
|
coderabbitai[bot] marked this conversation as resolved.
|
||
|
|
||
| ## Troubleshooting | ||
|
|
||
| ### ClusterIP already allocated | ||
|
|
||
| BMC IP is outside ServiceCIDR or already in use. | ||
|
|
||
| **Solutions:** | ||
|
|
||
| 1. Reserve a ServiceCIDR for machine-a-tron (K8s 1.29+) | ||
| 2. Use a CIDR within the cluster's ServiceCIDR | ||
| 3. Delete conflicting Services | ||
|
|
||
| ### ClusterIP change detected | ||
|
|
||
| BMC IP changed but ClusterIP is immutable. Controller will delete and recreate | ||
| the Service. | ||
|
|
||
| ## Architecture | ||
|
|
||
| ```mermaid | ||
| flowchart LR | ||
| subgraph MAT[machine-a-tron pods] | ||
| MAT0[mat-0/bmc-mock] | ||
| MAT1[mat-1/bmc-mock] | ||
| end | ||
|
|
||
| subgraph Controller | ||
| Discovery[Service Discovery] | ||
| Reconciler[Reconciler] | ||
| end | ||
|
|
||
| subgraph K8s[Kubernetes Services] | ||
| SVC1[mat-bmc-host-xxx] | ||
| SVC2[mat-bmc-dpu-yyy] | ||
| end | ||
|
|
||
| Discovery -->|discovers| MAT0 | ||
| Discovery -->|discovers| MAT1 | ||
| Reconciler -->|polls /machines/status| MAT | ||
| Reconciler -->|creates/updates/deletes| K8s | ||
| ``` | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.