Moved all custom naming into one place
This commit is contained in:
@@ -4,7 +4,7 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
|
|
||||||
"undecided.project/monok8s/pkg/cmd/root"
|
"example.com/monok8s/pkg/cmd/root"
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
module undecided.project/monok8s
|
module example.com/monok8s
|
||||||
|
|
||||||
go 1.24.0
|
go 1.24.0
|
||||||
|
|
||||||
|
|||||||
@@ -6,12 +6,16 @@ import (
|
|||||||
"k8s.io/apimachinery/pkg/runtime/schema"
|
"k8s.io/apimachinery/pkg/runtime/schema"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
var (
|
||||||
Group = "monok8s.io"
|
Group = "monok8s.io"
|
||||||
Version = "v1alpha1"
|
Version = "v1alpha1"
|
||||||
)
|
MonoKSConfigCRD = "monoksconfigs.monok8s.io"
|
||||||
|
OSUpgradeCRD = "osupgrades.monok8s.io"
|
||||||
|
APIVersion = "monok8s.io/v1alpha1"
|
||||||
|
Label = "monok8s.io/label"
|
||||||
|
Annotation = "monok8s.io/annotation"
|
||||||
|
ControlAgentKey = "monok8s.io/control-agent"
|
||||||
|
|
||||||
var (
|
|
||||||
SchemeGroupVersion = schema.GroupVersion{Group: Group, Version: Version}
|
SchemeGroupVersion = schema.GroupVersion{Group: Group, Version: Version}
|
||||||
SchemeBuilder = runtime.NewSchemeBuilder(addKnownTypes)
|
SchemeBuilder = runtime.NewSchemeBuilder(addKnownTypes)
|
||||||
AddToScheme = SchemeBuilder.AddToScheme
|
AddToScheme = SchemeBuilder.AddToScheme
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ package bootstrap
|
|||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"undecided.project/monok8s/pkg/node"
|
"example.com/monok8s/pkg/node"
|
||||||
)
|
)
|
||||||
|
|
||||||
type Registry struct {
|
type Registry struct {
|
||||||
|
|||||||
@@ -5,9 +5,9 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"k8s.io/klog/v2"
|
"k8s.io/klog/v2"
|
||||||
monov1alpha1 "undecided.project/monok8s/pkg/apis/monok8s/v1alpha1"
|
monov1alpha1 "example.com/monok8s/pkg/apis/monok8s/v1alpha1"
|
||||||
"undecided.project/monok8s/pkg/node"
|
"example.com/monok8s/pkg/node"
|
||||||
"undecided.project/monok8s/pkg/system"
|
"example.com/monok8s/pkg/system"
|
||||||
)
|
)
|
||||||
|
|
||||||
type Runner struct {
|
type Runner struct {
|
||||||
|
|||||||
@@ -11,10 +11,10 @@ import (
|
|||||||
"k8s.io/cli-runtime/pkg/genericclioptions"
|
"k8s.io/cli-runtime/pkg/genericclioptions"
|
||||||
"k8s.io/klog/v2"
|
"k8s.io/klog/v2"
|
||||||
|
|
||||||
types "undecided.project/monok8s/pkg/apis/monok8s/v1alpha1"
|
monov1alpha1 "example.com/monok8s/pkg/apis/monok8s/v1alpha1"
|
||||||
mkscmd "undecided.project/monok8s/pkg/cmd"
|
mkscmd "example.com/monok8s/pkg/cmd"
|
||||||
"undecided.project/monok8s/pkg/kube"
|
"example.com/monok8s/pkg/kube"
|
||||||
"undecided.project/monok8s/pkg/templates"
|
"example.com/monok8s/pkg/templates"
|
||||||
)
|
)
|
||||||
|
|
||||||
func NewCmdAgent(flags *genericclioptions.ConfigFlags) *cobra.Command {
|
func NewCmdAgent(flags *genericclioptions.ConfigFlags) *cobra.Command {
|
||||||
@@ -26,7 +26,7 @@ func NewCmdAgent(flags *genericclioptions.ConfigFlags) *cobra.Command {
|
|||||||
Short: "Watch OSUpgrade resources and do nothing for now",
|
Short: "Watch OSUpgrade resources and do nothing for now",
|
||||||
RunE: func(cmd *cobra.Command, _ []string) error {
|
RunE: func(cmd *cobra.Command, _ []string) error {
|
||||||
|
|
||||||
var cfg *types.MonoKSConfig // or value, depending on your API
|
var cfg *monov1alpha1.MonoKSConfig // or value, depending on your API
|
||||||
|
|
||||||
if err := mkscmd.LoadEnvFile(envFile); err != nil {
|
if err := mkscmd.LoadEnvFile(envFile); err != nil {
|
||||||
return fmt.Errorf("load env file %q: %w", envFile, err)
|
return fmt.Errorf("load env file %q: %w", envFile, err)
|
||||||
@@ -41,7 +41,7 @@ func NewCmdAgent(flags *genericclioptions.ConfigFlags) *cobra.Command {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
gvr := schema.GroupVersionResource{Group: types.Group, Version: types.Version, Resource: "osupgrades"}
|
gvr := schema.GroupVersionResource{Group: monov1alpha1.Group, Version: monov1alpha1.Version, Resource: "osupgrades"}
|
||||||
ctx := cmd.Context()
|
ctx := cmd.Context()
|
||||||
for {
|
for {
|
||||||
list, err := clients.Dynamic.Resource(gvr).Namespace(namespace).List(ctx, metav1.ListOptions{})
|
list, err := clients.Dynamic.Resource(gvr).Namespace(namespace).List(ctx, metav1.ListOptions{})
|
||||||
|
|||||||
@@ -4,8 +4,8 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"undecided.project/monok8s/pkg/crds"
|
"example.com/monok8s/pkg/crds"
|
||||||
"undecided.project/monok8s/pkg/kube"
|
"example.com/monok8s/pkg/kube"
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
apiextensionsv1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1"
|
apiextensionsv1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1"
|
||||||
apierrors "k8s.io/apimachinery/pkg/api/errors"
|
apierrors "k8s.io/apimachinery/pkg/api/errors"
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ package checkconfig
|
|||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"undecided.project/monok8s/pkg/config"
|
"example.com/monok8s/pkg/config"
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
|
|
||||||
render "undecided.project/monok8s/pkg/render"
|
render "example.com/monok8s/pkg/render"
|
||||||
)
|
)
|
||||||
|
|
||||||
func NewCmdCreate() *cobra.Command {
|
func NewCmdCreate() *cobra.Command {
|
||||||
|
|||||||
@@ -10,12 +10,12 @@ import (
|
|||||||
"k8s.io/cli-runtime/pkg/genericclioptions"
|
"k8s.io/cli-runtime/pkg/genericclioptions"
|
||||||
"k8s.io/klog/v2"
|
"k8s.io/klog/v2"
|
||||||
|
|
||||||
"undecided.project/monok8s/pkg/bootstrap"
|
"example.com/monok8s/pkg/bootstrap"
|
||||||
"undecided.project/monok8s/pkg/config"
|
"example.com/monok8s/pkg/config"
|
||||||
|
|
||||||
types "undecided.project/monok8s/pkg/apis/monok8s/v1alpha1"
|
monov1alpha1 "example.com/monok8s/pkg/apis/monok8s/v1alpha1"
|
||||||
mkscmd "undecided.project/monok8s/pkg/cmd"
|
mkscmd "example.com/monok8s/pkg/cmd"
|
||||||
"undecided.project/monok8s/pkg/templates"
|
"example.com/monok8s/pkg/templates"
|
||||||
)
|
)
|
||||||
|
|
||||||
func NewCmdInit(_ *genericclioptions.ConfigFlags) *cobra.Command {
|
func NewCmdInit(_ *genericclioptions.ConfigFlags) *cobra.Command {
|
||||||
@@ -69,7 +69,7 @@ Supported formats:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var cfg *types.MonoKSConfig // or value, depending on your API
|
var cfg *monov1alpha1.MonoKSConfig // or value, depending on your API
|
||||||
|
|
||||||
switch {
|
switch {
|
||||||
case strings.TrimSpace(envFile) != "":
|
case strings.TrimSpace(envFile) != "":
|
||||||
|
|||||||
@@ -2,8 +2,8 @@ package internal
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
"undecided.project/monok8s/pkg/bootstrap"
|
"example.com/monok8s/pkg/bootstrap"
|
||||||
"undecided.project/monok8s/pkg/config"
|
"example.com/monok8s/pkg/config"
|
||||||
)
|
)
|
||||||
|
|
||||||
func NewCmdInternal() *cobra.Command {
|
func NewCmdInternal() *cobra.Command {
|
||||||
|
|||||||
@@ -7,13 +7,13 @@ import (
|
|||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
"k8s.io/cli-runtime/pkg/genericclioptions"
|
"k8s.io/cli-runtime/pkg/genericclioptions"
|
||||||
"k8s.io/klog/v2"
|
"k8s.io/klog/v2"
|
||||||
agentcmd "undecided.project/monok8s/pkg/cmd/agent"
|
agentcmd "example.com/monok8s/pkg/cmd/agent"
|
||||||
applycmd "undecided.project/monok8s/pkg/cmd/apply"
|
applycmd "example.com/monok8s/pkg/cmd/apply"
|
||||||
checkconfigcmd "undecided.project/monok8s/pkg/cmd/checkconfig"
|
checkconfigcmd "example.com/monok8s/pkg/cmd/checkconfig"
|
||||||
createcmd "undecided.project/monok8s/pkg/cmd/create"
|
createcmd "example.com/monok8s/pkg/cmd/create"
|
||||||
initcmd "undecided.project/monok8s/pkg/cmd/initcmd"
|
initcmd "example.com/monok8s/pkg/cmd/initcmd"
|
||||||
internalcmd "undecided.project/monok8s/pkg/cmd/internal"
|
internalcmd "example.com/monok8s/pkg/cmd/internal"
|
||||||
versioncmd "undecided.project/monok8s/pkg/cmd/version"
|
versioncmd "example.com/monok8s/pkg/cmd/version"
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import (
|
|||||||
|
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
|
|
||||||
buildInfo "undecided.project/monok8s/pkg/buildinfo"
|
buildInfo "example.com/monok8s/pkg/buildinfo"
|
||||||
)
|
)
|
||||||
|
|
||||||
func NewCmdVersion() *cobra.Command {
|
func NewCmdVersion() *cobra.Command {
|
||||||
|
|||||||
@@ -6,8 +6,8 @@ import (
|
|||||||
"os"
|
"os"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
monov1alpha1 "example.com/monok8s/pkg/apis/monok8s/v1alpha1"
|
||||||
"gopkg.in/yaml.v3"
|
"gopkg.in/yaml.v3"
|
||||||
monov1alpha1 "undecided.project/monok8s/pkg/apis/monok8s/v1alpha1"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
const EnvVar = "MONOKSCONFIG"
|
const EnvVar = "MONOKSCONFIG"
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package crds
|
package crds
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
monov1alpha1 "example.com/monok8s/pkg/apis/monok8s/v1alpha1"
|
||||||
apiextensionsv1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1"
|
apiextensionsv1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1"
|
||||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
)
|
)
|
||||||
@@ -14,9 +15,11 @@ func Definitions() []*apiextensionsv1.CustomResourceDefinition {
|
|||||||
|
|
||||||
func monoKSConfigCRD() *apiextensionsv1.CustomResourceDefinition {
|
func monoKSConfigCRD() *apiextensionsv1.CustomResourceDefinition {
|
||||||
return &apiextensionsv1.CustomResourceDefinition{
|
return &apiextensionsv1.CustomResourceDefinition{
|
||||||
ObjectMeta: metav1.ObjectMeta{Name: "monoksconfigs.monok8s.io"},
|
ObjectMeta: metav1.ObjectMeta{
|
||||||
|
Name: monov1alpha1.MonoKSConfigCRD,
|
||||||
|
},
|
||||||
Spec: apiextensionsv1.CustomResourceDefinitionSpec{
|
Spec: apiextensionsv1.CustomResourceDefinitionSpec{
|
||||||
Group: "monok8s.io",
|
Group: monov1alpha1.Group,
|
||||||
Scope: apiextensionsv1.NamespaceScoped,
|
Scope: apiextensionsv1.NamespaceScoped,
|
||||||
Names: apiextensionsv1.CustomResourceDefinitionNames{
|
Names: apiextensionsv1.CustomResourceDefinitionNames{
|
||||||
Plural: "monoksconfigs",
|
Plural: "monoksconfigs",
|
||||||
@@ -42,9 +45,11 @@ func monoKSConfigCRD() *apiextensionsv1.CustomResourceDefinition {
|
|||||||
|
|
||||||
func osUpgradeCRD() *apiextensionsv1.CustomResourceDefinition {
|
func osUpgradeCRD() *apiextensionsv1.CustomResourceDefinition {
|
||||||
return &apiextensionsv1.CustomResourceDefinition{
|
return &apiextensionsv1.CustomResourceDefinition{
|
||||||
ObjectMeta: metav1.ObjectMeta{Name: "osupgrades.monok8s.io"},
|
ObjectMeta: metav1.ObjectMeta{
|
||||||
|
Name: monov1alpha1.OSUpgradeCRD,
|
||||||
|
},
|
||||||
Spec: apiextensionsv1.CustomResourceDefinitionSpec{
|
Spec: apiextensionsv1.CustomResourceDefinitionSpec{
|
||||||
Group: "monok8s.io",
|
Group: monov1alpha1.Group,
|
||||||
Scope: apiextensionsv1.NamespaceScoped,
|
Scope: apiextensionsv1.NamespaceScoped,
|
||||||
Names: apiextensionsv1.CustomResourceDefinitionNames{
|
Names: apiextensionsv1.CustomResourceDefinitionNames{
|
||||||
Plural: "osupgrades",
|
Plural: "osupgrades",
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ import (
|
|||||||
utilruntime "k8s.io/apimachinery/pkg/util/runtime"
|
utilruntime "k8s.io/apimachinery/pkg/util/runtime"
|
||||||
kubernetes "k8s.io/client-go/kubernetes"
|
kubernetes "k8s.io/client-go/kubernetes"
|
||||||
clientgoscheme "k8s.io/client-go/kubernetes/scheme"
|
clientgoscheme "k8s.io/client-go/kubernetes/scheme"
|
||||||
monov1alpha1 "undecided.project/monok8s/pkg/apis/monok8s/v1alpha1"
|
monov1alpha1 "example.com/monok8s/pkg/apis/monok8s/v1alpha1"
|
||||||
|
|
||||||
"k8s.io/apimachinery/pkg/runtime"
|
"k8s.io/apimachinery/pkg/runtime"
|
||||||
"k8s.io/cli-runtime/pkg/genericclioptions"
|
"k8s.io/cli-runtime/pkg/genericclioptions"
|
||||||
|
|||||||
@@ -14,14 +14,14 @@ import (
|
|||||||
"k8s.io/client-go/kubernetes"
|
"k8s.io/client-go/kubernetes"
|
||||||
"k8s.io/klog/v2"
|
"k8s.io/klog/v2"
|
||||||
|
|
||||||
"undecided.project/monok8s/pkg/crds"
|
monov1alpha1 "example.com/monok8s/pkg/apis/monok8s/v1alpha1"
|
||||||
"undecided.project/monok8s/pkg/kube"
|
"example.com/monok8s/pkg/crds"
|
||||||
templates "undecided.project/monok8s/pkg/templates"
|
"example.com/monok8s/pkg/kube"
|
||||||
|
templates "example.com/monok8s/pkg/templates"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
controlAgentName = "control-agent"
|
controlAgentName = "control-agent"
|
||||||
controlAgentNodeSelectorKey = "monok8s.io/control-agent"
|
|
||||||
controlAgentNodeSelectorValue = "true"
|
controlAgentNodeSelectorValue = "true"
|
||||||
controlAgentImage = "localhost/monok8s/control-agent:dev"
|
controlAgentImage = "localhost/monok8s/control-agent:dev"
|
||||||
kubeconfig = "/etc/kubernetes/admin.conf"
|
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 {
|
func applyControlAgentClusterRole(ctx context.Context, kubeClient kubernetes.Interface, labels map[string]string) error {
|
||||||
wantRules := []rbacv1.PolicyRule{
|
wantRules := []rbacv1.PolicyRule{
|
||||||
{
|
{
|
||||||
APIGroups: []string{"monok8s.io"},
|
APIGroups: []string{monov1alpha1.Group},
|
||||||
Resources: []string{"osupgrades"},
|
Resources: []string{"osupgrades"},
|
||||||
Verbs: []string{"get", "list", "watch"},
|
Verbs: []string{"get", "list", "watch"},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
APIGroups: []string{"monok8s.io"},
|
APIGroups: []string{monov1alpha1.Group},
|
||||||
Resources: []string{"osupgrades/status"},
|
Resources: []string{"osupgrades/status"},
|
||||||
Verbs: []string{"get", "patch", "update"},
|
Verbs: []string{"get", "patch", "update"},
|
||||||
},
|
},
|
||||||
@@ -290,7 +290,7 @@ func applyControlAgentDaemonSet(ctx context.Context, kubeClient kubernetes.Inter
|
|||||||
HostPID: true,
|
HostPID: true,
|
||||||
DNSPolicy: corev1.DNSClusterFirstWithHostNet,
|
DNSPolicy: corev1.DNSClusterFirstWithHostNet,
|
||||||
NodeSelector: map[string]string{
|
NodeSelector: map[string]string{
|
||||||
controlAgentNodeSelectorKey: controlAgentNodeSelectorValue,
|
monov1alpha1.ControlAgentKey: controlAgentNodeSelectorValue,
|
||||||
},
|
},
|
||||||
Tolerations: []corev1.Toleration{
|
Tolerations: []corev1.Toleration{
|
||||||
{Operator: corev1.TolerationOpExists},
|
{Operator: corev1.TolerationOpExists},
|
||||||
|
|||||||
@@ -3,8 +3,8 @@ package node
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
|
||||||
monov1alpha1 "undecided.project/monok8s/pkg/apis/monok8s/v1alpha1"
|
monov1alpha1 "example.com/monok8s/pkg/apis/monok8s/v1alpha1"
|
||||||
"undecided.project/monok8s/pkg/system"
|
"example.com/monok8s/pkg/system"
|
||||||
)
|
)
|
||||||
|
|
||||||
type Step func(context.Context, *NodeContext) error
|
type Step func(context.Context, *NodeContext) error
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"k8s.io/klog/v2"
|
"k8s.io/klog/v2"
|
||||||
system "undecided.project/monok8s/pkg/system"
|
system "example.com/monok8s/pkg/system"
|
||||||
)
|
)
|
||||||
|
|
||||||
func ConfigureDefaultCNI(ctx context.Context, n *NodeContext) error {
|
func ConfigureDefaultCNI(ctx context.Context, n *NodeContext) error {
|
||||||
|
|||||||
@@ -17,8 +17,8 @@ import (
|
|||||||
"k8s.io/client-go/tools/clientcmd"
|
"k8s.io/client-go/tools/clientcmd"
|
||||||
"k8s.io/klog/v2"
|
"k8s.io/klog/v2"
|
||||||
|
|
||||||
types "undecided.project/monok8s/pkg/apis/monok8s/v1alpha1"
|
monov1alpha1 "example.com/monok8s/pkg/apis/monok8s/v1alpha1"
|
||||||
system "undecided.project/monok8s/pkg/system"
|
system "example.com/monok8s/pkg/system"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
@@ -482,7 +482,7 @@ func normalizeKubeVersion(v string) string {
|
|||||||
return v
|
return v
|
||||||
}
|
}
|
||||||
|
|
||||||
func buildNodeRegistration(spec types.MonoKSConfigSpec) NodeRegistrationOptions {
|
func buildNodeRegistration(spec monov1alpha1.MonoKSConfigSpec) NodeRegistrationOptions {
|
||||||
nodeName := strings.TrimSpace(spec.NodeName)
|
nodeName := strings.TrimSpace(spec.NodeName)
|
||||||
criSocket := strings.TrimSpace(spec.ContainerRuntimeEndpoint)
|
criSocket := strings.TrimSpace(spec.ContainerRuntimeEndpoint)
|
||||||
advertiseAddress := strings.TrimSpace(spec.APIServerAdvertiseAddress)
|
advertiseAddress := strings.TrimSpace(spec.APIServerAdvertiseAddress)
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
system "undecided.project/monok8s/pkg/system"
|
system "example.com/monok8s/pkg/system"
|
||||||
)
|
)
|
||||||
|
|
||||||
func StartKubelet(ctx context.Context, n *NodeContext) error {
|
func StartKubelet(ctx context.Context, n *NodeContext) error {
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ import (
|
|||||||
"k8s.io/client-go/tools/clientcmd"
|
"k8s.io/client-go/tools/clientcmd"
|
||||||
"k8s.io/klog/v2"
|
"k8s.io/klog/v2"
|
||||||
|
|
||||||
|
monov1alpah1 "example.com/monok8s/pkg/apis/monok8s/v1alpha1"
|
||||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
kubernetes "k8s.io/client-go/kubernetes"
|
kubernetes "k8s.io/client-go/kubernetes"
|
||||||
)
|
)
|
||||||
@@ -63,7 +64,7 @@ func ApplyLocalNodeMetadataIfPossible(ctx context.Context, nctx *NodeContext) er
|
|||||||
|
|
||||||
// Additional Labels
|
// Additional Labels
|
||||||
if spec.EnableControlAgent {
|
if spec.EnableControlAgent {
|
||||||
node.Labels[controlAgentNodeSelectorKey] = controlAgentNodeSelectorValue
|
node.Labels[monov1alpah1.ControlAgentKey] = controlAgentNodeSelectorValue
|
||||||
}
|
}
|
||||||
|
|
||||||
// Apply annotations
|
// Apply annotations
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"k8s.io/klog/v2"
|
"k8s.io/klog/v2"
|
||||||
system "undecided.project/monok8s/pkg/system"
|
system "example.com/monok8s/pkg/system"
|
||||||
)
|
)
|
||||||
|
|
||||||
type NetworkConfig struct {
|
type NetworkConfig struct {
|
||||||
|
|||||||
@@ -6,8 +6,8 @@ import (
|
|||||||
"k8s.io/apimachinery/pkg/runtime"
|
"k8s.io/apimachinery/pkg/runtime"
|
||||||
"k8s.io/apimachinery/pkg/runtime/serializer/json"
|
"k8s.io/apimachinery/pkg/runtime/serializer/json"
|
||||||
|
|
||||||
"undecided.project/monok8s/pkg/scheme"
|
monov1alpha1 "example.com/monok8s/pkg/apis/monok8s/v1alpha1"
|
||||||
"undecided.project/monok8s/pkg/templates"
|
"example.com/monok8s/pkg/templates"
|
||||||
)
|
)
|
||||||
|
|
||||||
func RenderMonoKSConfig() (string, error) {
|
func RenderMonoKSConfig() (string, error) {
|
||||||
@@ -15,7 +15,7 @@ func RenderMonoKSConfig() (string, error) {
|
|||||||
cfg := templates.DefaultMonoKSConfig(vals)
|
cfg := templates.DefaultMonoKSConfig(vals)
|
||||||
|
|
||||||
s := runtime.NewScheme()
|
s := runtime.NewScheme()
|
||||||
if err := scheme.AddToScheme(s); err != nil {
|
if err := monov1alpha1.AddToScheme(s); err != nil {
|
||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -36,7 +36,7 @@ func RenderOSUpgrade() (string, error) {
|
|||||||
cfg := templates.DefaultOSUpgrade(vals)
|
cfg := templates.DefaultOSUpgrade(vals)
|
||||||
|
|
||||||
s := runtime.NewScheme()
|
s := runtime.NewScheme()
|
||||||
if err := scheme.AddToScheme(s); err != nil {
|
if err := monov1alpha1.AddToScheme(s); err != nil {
|
||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,27 +0,0 @@
|
|||||||
package scheme
|
|
||||||
|
|
||||||
import (
|
|
||||||
"k8s.io/apimachinery/pkg/runtime"
|
|
||||||
"k8s.io/apimachinery/pkg/runtime/schema"
|
|
||||||
|
|
||||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
|
||||||
types "undecided.project/monok8s/pkg/apis/monok8s/v1alpha1"
|
|
||||||
)
|
|
||||||
|
|
||||||
var (
|
|
||||||
GroupVersion = schema.GroupVersion{
|
|
||||||
Group: "monok8s.io",
|
|
||||||
Version: "v1alpha1",
|
|
||||||
}
|
|
||||||
)
|
|
||||||
|
|
||||||
func AddToScheme(s *runtime.Scheme) error {
|
|
||||||
s.AddKnownTypes(GroupVersion,
|
|
||||||
&types.MonoKSConfig{},
|
|
||||||
)
|
|
||||||
|
|
||||||
// Required for meta stuff
|
|
||||||
metav1.AddToGroupVersion(s, GroupVersion)
|
|
||||||
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
@@ -3,23 +3,23 @@ package templates
|
|||||||
import (
|
import (
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
monov1alpha1 "example.com/monok8s/pkg/apis/monok8s/v1alpha1"
|
||||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
types "undecided.project/monok8s/pkg/apis/monok8s/v1alpha1"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
const DefaultNamespace = "kube-system"
|
const DefaultNamespace = "kube-system"
|
||||||
|
|
||||||
func DefaultMonoKSConfig(v TemplateValues) types.MonoKSConfig {
|
func DefaultMonoKSConfig(v TemplateValues) monov1alpha1.MonoKSConfig {
|
||||||
return types.MonoKSConfig{
|
return monov1alpha1.MonoKSConfig{
|
||||||
TypeMeta: metav1.TypeMeta{
|
TypeMeta: metav1.TypeMeta{
|
||||||
APIVersion: "monok8s.io/v1alpha1",
|
APIVersion: monov1alpha1.APIVersion,
|
||||||
Kind: "MonoKSConfig",
|
Kind: "MonoKSConfig",
|
||||||
},
|
},
|
||||||
ObjectMeta: metav1.ObjectMeta{
|
ObjectMeta: metav1.ObjectMeta{
|
||||||
Name: "example",
|
Name: "example",
|
||||||
Namespace: DefaultNamespace,
|
Namespace: DefaultNamespace,
|
||||||
},
|
},
|
||||||
Spec: types.MonoKSConfigSpec{
|
Spec: monov1alpha1.MonoKSConfigSpec{
|
||||||
KubernetesVersion: v.KubernetesVersion,
|
KubernetesVersion: v.KubernetesVersion,
|
||||||
NodeName: firstNonEmpty(v.NodeName, v.Hostname),
|
NodeName: firstNonEmpty(v.NodeName, v.Hostname),
|
||||||
|
|
||||||
@@ -53,7 +53,7 @@ func DefaultMonoKSConfig(v TemplateValues) types.MonoKSConfig {
|
|||||||
NodeLabels: copyStringMap(v.NodeLabels),
|
NodeLabels: copyStringMap(v.NodeLabels),
|
||||||
NodeAnnotations: copyStringMap(v.NodeAnnotations),
|
NodeAnnotations: copyStringMap(v.NodeAnnotations),
|
||||||
|
|
||||||
Network: types.NetworkSpec{
|
Network: monov1alpha1.NetworkSpec{
|
||||||
Hostname: firstNonEmpty(v.Hostname, v.NodeName),
|
Hostname: firstNonEmpty(v.Hostname, v.NodeName),
|
||||||
ManagementIface: v.MgmtIface,
|
ManagementIface: v.MgmtIface,
|
||||||
ManagementCIDR: v.MgmtAddress,
|
ManagementCIDR: v.MgmtAddress,
|
||||||
@@ -65,17 +65,17 @@ func DefaultMonoKSConfig(v TemplateValues) types.MonoKSConfig {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func DefaultOSUpgrade(v TemplateValues) types.OSUpgrade {
|
func DefaultOSUpgrade(v TemplateValues) monov1alpha1.OSUpgrade {
|
||||||
return types.OSUpgrade{
|
return monov1alpha1.OSUpgrade{
|
||||||
TypeMeta: metav1.TypeMeta{
|
TypeMeta: metav1.TypeMeta{
|
||||||
APIVersion: "monok8s.io/v1alpha1",
|
APIVersion: monov1alpha1.APIVersion,
|
||||||
Kind: "OSUpgrade",
|
Kind: "OSUpgrade",
|
||||||
},
|
},
|
||||||
ObjectMeta: metav1.ObjectMeta{
|
ObjectMeta: metav1.ObjectMeta{
|
||||||
Name: "example",
|
Name: "example",
|
||||||
Namespace: DefaultNamespace,
|
Namespace: DefaultNamespace,
|
||||||
},
|
},
|
||||||
Spec: types.OSUpgradeSpec{
|
Spec: monov1alpha1.OSUpgradeSpec{
|
||||||
Version: v.KubernetesVersion,
|
Version: v.KubernetesVersion,
|
||||||
ImageURL: "https://example.invalid/images/monok8s-v0.0.1.img.zst",
|
ImageURL: "https://example.invalid/images/monok8s-v0.0.1.img.zst",
|
||||||
NodeSelector: &metav1.LabelSelector{
|
NodeSelector: &metav1.LabelSelector{
|
||||||
|
|||||||
@@ -4,7 +4,8 @@ import (
|
|||||||
"os"
|
"os"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
buildinfo "undecided.project/monok8s/pkg/buildinfo"
|
monov1alpha1 "example.com/monok8s/pkg/apis/monok8s/v1alpha1"
|
||||||
|
buildinfo "example.com/monok8s/pkg/buildinfo"
|
||||||
)
|
)
|
||||||
|
|
||||||
type TemplateValues struct {
|
type TemplateValues struct {
|
||||||
@@ -75,10 +76,10 @@ func defaultTemplateValues() TemplateValues {
|
|||||||
SubjectAltNames: []string{"10.0.0.10", "localhost", "monok8s-master-1"},
|
SubjectAltNames: []string{"10.0.0.10", "localhost", "monok8s-master-1"},
|
||||||
|
|
||||||
NodeLabels: map[string]string{
|
NodeLabels: map[string]string{
|
||||||
"monok8s.io/label": "value",
|
monov1alpha1.Label: "value",
|
||||||
},
|
},
|
||||||
NodeAnnotations: map[string]string{
|
NodeAnnotations: map[string]string{
|
||||||
"monok8s.io/annotation": "value",
|
monov1alpha1.Annotation: "value",
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user