mirror of
https://github.com/dsx-ai-factory/nvke.git
synced 2026-12-07 04:35:58 +08:00
The repository was renamed from dsx-ai-factory/nke to dsx-ai-factory/nvke on 2026-10-10. Its id is unchanged, so guards, rulesets, environments and the OIDC subject carried over, and GitHub redirects the old URLs. The tree still named the old repository where the name is a contract rather than a URL: the module lines of the 12 Go modules and about 1,700 import lines, the proto go_package (embedded in node_agent.pb.go, regenerated here), both THIRD_PARTY_NOTICES.md files (regenerated), the lint local-prefix and depguard entries, ldflags, the go-licenses ignore lists, the documented repository URLs and gh commands, and the ghcr.io/dsx-ai-factory/nke image paths in workflows, the chart default and the e2e defaults. Only the organisation and repository segments change. Directories, identifiers, binary, image, chart, package, label, namespace and environment variable names, the CODEOWNERS team slugs and CHANGELOG.md stay as they are. Closes #1448 Signed-off-by: Davanum Srinivas <dsrinivas@nvidia.com> Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com>
53 lines
1.9 KiB
Go
53 lines
1.9 KiB
Go
// SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
|
|
// SPDX-License-Identifier: Apache-2.0
|
|
|
|
package controllerdeploy
|
|
|
|
import (
|
|
"context"
|
|
"encoding/json"
|
|
"fmt"
|
|
|
|
"github.com/google/uuid"
|
|
|
|
"github.com/dsx-ai-factory/nvke/cli/internal/bootstrap/etcdkey"
|
|
)
|
|
|
|
// EtcdEncryptionKey reads the etcd encryption key the controller holds for clusterID and
|
|
// returns the Secret's data, decoded.
|
|
//
|
|
// The command's output is not placed in any error, unlike the other kubectl
|
|
// reads in this package: for this Secret the output is the key.
|
|
func (e *Engine) EtcdEncryptionKey(
|
|
ctx context.Context,
|
|
kubeconfigPath string,
|
|
clusterID uuid.UUID,
|
|
) (map[string][]byte, error) {
|
|
name := etcdkey.SecretName(clusterID)
|
|
out, err := e.Runner.Run(ctx, "kubectl", "--kubeconfig", kubeconfigPath,
|
|
"-n", cweNamespace, "get", "secret", name, "-o", "json")
|
|
if err != nil {
|
|
return nil, fmt.Errorf("controllerdeploy: reading %s/%s: %w", cweNamespace, name, err)
|
|
}
|
|
|
|
var secret struct {
|
|
Data map[string][]byte `json:"data"`
|
|
}
|
|
if err := json.Unmarshal([]byte(out), &secret); err != nil {
|
|
return nil, fmt.Errorf("controllerdeploy: %s/%s is not a Secret: %w", cweNamespace, name, err)
|
|
}
|
|
if len(secret.Data[etcdkey.FieldActive]) == 0 {
|
|
return nil, fmt.Errorf("controllerdeploy: %s/%s has no %q key", cweNamespace, name, etcdkey.FieldActive)
|
|
}
|
|
return secret.Data, nil
|
|
}
|
|
|
|
// EtcdEncryptionKeyCommand is a shell command that saves the key Secret of
|
|
// clusterID to outPath, as the bootstrap cluster holds it. It names the same
|
|
// Secret EtcdEncryptionKey reads, so what is printed cannot drift from what
|
|
// the command does; umask keeps the file readable by its owner only.
|
|
func EtcdEncryptionKeyCommand(kubeconfigPath string, clusterID uuid.UUID, outPath string) string {
|
|
return fmt.Sprintf("umask 077 && kubectl --kubeconfig %s -n %s get secret %s -o json > %s",
|
|
kubeconfigPath, cweNamespace, etcdkey.SecretName(clusterID), outPath)
|
|
}
|