Moved all custom naming into one place

This commit is contained in:
2026-04-03 01:48:07 +08:00
parent 3c0df319d7
commit 1ce15e9ac5
27 changed files with 87 additions and 103 deletions

View File

@@ -14,14 +14,14 @@ import (
"k8s.io/client-go/kubernetes"
"k8s.io/klog/v2"
"undecided.project/monok8s/pkg/crds"
"undecided.project/monok8s/pkg/kube"
templates "undecided.project/monok8s/pkg/templates"
monov1alpha1 "example.com/monok8s/pkg/apis/monok8s/v1alpha1"
"example.com/monok8s/pkg/crds"
"example.com/monok8s/pkg/kube"
templates "example.com/monok8s/pkg/templates"
)
const (
controlAgentName = "control-agent"
controlAgentNodeSelectorKey = "monok8s.io/control-agent"
controlAgentNodeSelectorValue = "true"
controlAgentImage = "localhost/monok8s/control-agent:dev"
kubeconfig = "/etc/kubernetes/admin.conf"
@@ -152,12 +152,12 @@ func applyControlAgentServiceAccount(ctx context.Context, kubeClient kubernetes.
func applyControlAgentClusterRole(ctx context.Context, kubeClient kubernetes.Interface, labels map[string]string) error {
wantRules := []rbacv1.PolicyRule{
{
APIGroups: []string{"monok8s.io"},
APIGroups: []string{monov1alpha1.Group},
Resources: []string{"osupgrades"},
Verbs: []string{"get", "list", "watch"},
},
{
APIGroups: []string{"monok8s.io"},
APIGroups: []string{monov1alpha1.Group},
Resources: []string{"osupgrades/status"},
Verbs: []string{"get", "patch", "update"},
},
@@ -290,7 +290,7 @@ func applyControlAgentDaemonSet(ctx context.Context, kubeClient kubernetes.Inter
HostPID: true,
DNSPolicy: corev1.DNSClusterFirstWithHostNet,
NodeSelector: map[string]string{
controlAgentNodeSelectorKey: controlAgentNodeSelectorValue,
monov1alpha1.ControlAgentKey: controlAgentNodeSelectorValue,
},
Tolerations: []corev1.Toleration{
{Operator: corev1.TolerationOpExists},

View File

@@ -3,8 +3,8 @@ package node
import (
"context"
monov1alpha1 "undecided.project/monok8s/pkg/apis/monok8s/v1alpha1"
"undecided.project/monok8s/pkg/system"
monov1alpha1 "example.com/monok8s/pkg/apis/monok8s/v1alpha1"
"example.com/monok8s/pkg/system"
)
type Step func(context.Context, *NodeContext) error

View File

@@ -7,7 +7,7 @@ import (
"strings"
"k8s.io/klog/v2"
system "undecided.project/monok8s/pkg/system"
system "example.com/monok8s/pkg/system"
)
func ConfigureDefaultCNI(ctx context.Context, n *NodeContext) error {

View File

@@ -17,8 +17,8 @@ import (
"k8s.io/client-go/tools/clientcmd"
"k8s.io/klog/v2"
types "undecided.project/monok8s/pkg/apis/monok8s/v1alpha1"
system "undecided.project/monok8s/pkg/system"
monov1alpha1 "example.com/monok8s/pkg/apis/monok8s/v1alpha1"
system "example.com/monok8s/pkg/system"
)
const (
@@ -482,7 +482,7 @@ func normalizeKubeVersion(v string) string {
return v
}
func buildNodeRegistration(spec types.MonoKSConfigSpec) NodeRegistrationOptions {
func buildNodeRegistration(spec monov1alpha1.MonoKSConfigSpec) NodeRegistrationOptions {
nodeName := strings.TrimSpace(spec.NodeName)
criSocket := strings.TrimSpace(spec.ContainerRuntimeEndpoint)
advertiseAddress := strings.TrimSpace(spec.APIServerAdvertiseAddress)

View File

@@ -8,7 +8,7 @@ import (
"strings"
"time"
system "undecided.project/monok8s/pkg/system"
system "example.com/monok8s/pkg/system"
)
func StartKubelet(ctx context.Context, n *NodeContext) error {

View File

@@ -9,6 +9,7 @@ import (
"k8s.io/client-go/tools/clientcmd"
"k8s.io/klog/v2"
monov1alpah1 "example.com/monok8s/pkg/apis/monok8s/v1alpha1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
kubernetes "k8s.io/client-go/kubernetes"
)
@@ -63,7 +64,7 @@ func ApplyLocalNodeMetadataIfPossible(ctx context.Context, nctx *NodeContext) er
// Additional Labels
if spec.EnableControlAgent {
node.Labels[controlAgentNodeSelectorKey] = controlAgentNodeSelectorValue
node.Labels[monov1alpah1.ControlAgentKey] = controlAgentNodeSelectorValue
}
// Apply annotations

View File

@@ -8,7 +8,7 @@ import (
"strings"
"k8s.io/klog/v2"
system "undecided.project/monok8s/pkg/system"
system "example.com/monok8s/pkg/system"
)
type NetworkConfig struct {