mirror of
https://github.com/siderolabs/talos.git
synced 2025-10-03 03:31:12 +02:00
Clear the kubelet certificates and kubeconfig when hostname changes so that on next start, kubelet goes through the bootstrap process and new certificates are generated and the node is joined to the cluster with the new name. Fixes siderolabs/talos#5834. Signed-off-by: Utku Ozdemir <utku.ozdemir@siderolabs.com>
48 lines
1.8 KiB
Go
48 lines
1.8 KiB
Go
// This Source Code Form is subject to the terms of the Mozilla Public
|
|
// License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
|
|
package k8s
|
|
|
|
import (
|
|
"github.com/cosi-project/runtime/pkg/resource"
|
|
"github.com/cosi-project/runtime/pkg/resource/meta"
|
|
"github.com/cosi-project/runtime/pkg/resource/typed"
|
|
"github.com/opencontainers/runtime-spec/specs-go"
|
|
)
|
|
|
|
// KubeletSpecType is type of KubeletSpec resource.
|
|
const KubeletSpecType = resource.Type("KubeletSpecs.kubernetes.talos.dev")
|
|
|
|
// KubeletSpec resource holds final definition of kubelet runtime configuration.
|
|
type KubeletSpec = typed.Resource[KubeletSpecSpec, KubeletSpecRD]
|
|
|
|
// KubeletSpecSpec holds the source of kubelet configuration.
|
|
type KubeletSpecSpec struct {
|
|
Image string `yaml:"image"`
|
|
Args []string `yaml:"args,omitempty"`
|
|
ExtraMounts []specs.Mount `yaml:"extraMounts,omitempty"`
|
|
ExpectedNodename string `yaml:"expectedNodename,omitempty"`
|
|
Config map[string]interface{} `yaml:"config"`
|
|
}
|
|
|
|
// NewKubeletSpec initializes an empty KubeletSpec resource.
|
|
func NewKubeletSpec(namespace resource.Namespace, id resource.ID) *KubeletSpec {
|
|
return typed.NewResource[KubeletSpecSpec, KubeletSpecRD](
|
|
resource.NewMetadata(namespace, KubeletSpecType, id, resource.VersionUndefined),
|
|
KubeletSpecSpec{},
|
|
)
|
|
}
|
|
|
|
// KubeletSpecRD provides auxiliary methods for KubeletSpec.
|
|
type KubeletSpecRD struct{}
|
|
|
|
// ResourceDefinition implements typed.ResourceDefinition interface.
|
|
func (KubeletSpecRD) ResourceDefinition(resource.Metadata, KubeletSpecSpec) meta.ResourceDefinitionSpec {
|
|
return meta.ResourceDefinitionSpec{
|
|
Type: KubeletSpecType,
|
|
Aliases: []resource.Type{},
|
|
DefaultNamespace: NamespaceName,
|
|
}
|
|
}
|