mirror of
https://github.com/siderolabs/talos.git
synced 2025-09-14 18:31:10 +02:00
The gist is that `kubelet` service code only manages the container lifecycle, while `kubelet` configuration is managed now in the controllers and resources. New resources: * `secrets.Kubelet` contains Kubelet PKI derived directly from the machine configuration * `k8s.KubeletConfig` contains Kubelet non-secret config derived directly from the machine configuration * `k8s.NodeIPConfig` contains configuration on picking up Node IP for the kubelet (from machine configuration) * `k8s.NodeIP` contains actual Node IPs picked from the node addresses based on `NodeIPConfig` * `k8s.KubeletSpec` contains final `kubelet` container configuration, including merged arguments, KubeletConfig, etc. It is derived from `KubeletConfig`, `Nodename` and `NodeIP`. Final controller `KubeletServiceController` writes down configuration and PKI to disk, and manages restart/start of the `kubelet` service which is a pure wrapper around container lifecycle. Signed-off-by: Andrey Smirnov <andrey.smirnov@talos-systems.com>
86 lines
2.1 KiB
Go
86 lines
2.1 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 secrets
|
|
|
|
import (
|
|
"fmt"
|
|
"net/url"
|
|
|
|
"github.com/cosi-project/runtime/pkg/resource"
|
|
"github.com/cosi-project/runtime/pkg/resource/meta"
|
|
"github.com/talos-systems/crypto/x509"
|
|
)
|
|
|
|
// KubeletType is type of Kubelet secret resource.
|
|
const KubeletType = resource.Type("KubeletSecrets.secrets.talos.dev")
|
|
|
|
// KubeletID is the ID of KubeletType resource.
|
|
const KubeletID = resource.ID("kubelet")
|
|
|
|
// Kubelet contains root (not generated) secrets.
|
|
type Kubelet struct {
|
|
md resource.Metadata
|
|
spec KubeletSpec
|
|
}
|
|
|
|
// KubeletSpec describes root Kubernetes secrets.
|
|
type KubeletSpec struct {
|
|
Endpoint *url.URL `yaml:"endpoint"`
|
|
|
|
CA *x509.PEMEncodedCertificateAndKey `yaml:"ca"`
|
|
|
|
BootstrapTokenID string `yaml:"bootstrapTokenID"`
|
|
BootstrapTokenSecret string `yaml:"bootstrapTokenSecret"`
|
|
}
|
|
|
|
// NewKubelet initializes a Kubelet resource.
|
|
func NewKubelet(id resource.ID) *Kubelet {
|
|
r := &Kubelet{
|
|
md: resource.NewMetadata(NamespaceName, KubeletType, id, resource.VersionUndefined),
|
|
spec: KubeletSpec{},
|
|
}
|
|
|
|
r.md.BumpVersion()
|
|
|
|
return r
|
|
}
|
|
|
|
// Metadata implements resource.Resource.
|
|
func (r *Kubelet) Metadata() *resource.Metadata {
|
|
return &r.md
|
|
}
|
|
|
|
// Spec implements resource.Resource.
|
|
func (r *Kubelet) Spec() interface{} {
|
|
return &r.spec
|
|
}
|
|
|
|
func (r *Kubelet) String() string {
|
|
return fmt.Sprintf("secrets.Kubelet(%q)", r.md.ID())
|
|
}
|
|
|
|
// DeepCopy implements resource.Resource.
|
|
func (r *Kubelet) DeepCopy() resource.Resource {
|
|
return &Kubelet{
|
|
md: r.md,
|
|
spec: r.spec,
|
|
}
|
|
}
|
|
|
|
// ResourceDefinition implements meta.ResourceDefinitionProvider interface.
|
|
func (r *Kubelet) ResourceDefinition() meta.ResourceDefinitionSpec {
|
|
return meta.ResourceDefinitionSpec{
|
|
Type: KubeletType,
|
|
Aliases: []resource.Type{},
|
|
DefaultNamespace: NamespaceName,
|
|
Sensitivity: meta.Sensitive,
|
|
}
|
|
}
|
|
|
|
// TypedSpec returns .spec.
|
|
func (r *Kubelet) TypedSpec() *KubeletSpec {
|
|
return &r.spec
|
|
}
|