-
Notifications
You must be signed in to change notification settings - Fork 452
/
kubernetes.go
67 lines (54 loc) · 2.32 KB
/
kubernetes.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
// 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 (
"github.com/cosi-project/runtime/pkg/resource"
"github.com/cosi-project/runtime/pkg/resource/meta"
"github.com/cosi-project/runtime/pkg/resource/protobuf"
"github.com/cosi-project/runtime/pkg/resource/typed"
"github.com/siderolabs/talos/pkg/machinery/proto"
)
// KubernetesType is type of Kubernetes resource.
const KubernetesType = resource.Type("KubernetesSecrets.secrets.talos.dev")
// KubernetesID is a resource ID of singleton instance.
const KubernetesID = resource.ID("k8s-certs")
// Kubernetes contains K8s generated secrets.
//
// Kubernetes resource contains secrets which require reload of the control plane pods if updated.
type Kubernetes = typed.Resource[KubernetesCertsSpec, KubernetesExtension]
// KubernetesCertsSpec describes generated Kubernetes certificates.
//
//gotagsrewrite:gen
type KubernetesCertsSpec struct {
SchedulerKubeconfig string `yaml:"schedulerKubeconfig" protobuf:"4"`
ControllerManagerKubeconfig string `yaml:"controllerManagerKubeconfig" protobuf:"5"`
// Admin-level kubeconfig with access through the localhost endpoint and cluster endpoints.
LocalhostAdminKubeconfig string `yaml:"localhostAdminKubeconfig" protobuf:"6"`
AdminKubeconfig string `yaml:"adminKubeconfig" protobuf:"7"`
}
// NewKubernetes initializes a Kubernetes resource.
func NewKubernetes() *Kubernetes {
return typed.NewResource[KubernetesCertsSpec, KubernetesExtension](
resource.NewMetadata(NamespaceName, KubernetesType, KubernetesID, resource.VersionUndefined),
KubernetesCertsSpec{},
)
}
// KubernetesExtension provides auxiliary methods for Kubernetes.
type KubernetesExtension struct{}
// ResourceDefinition implements meta.ResourceDefinitionProvider interface.
func (KubernetesExtension) ResourceDefinition() meta.ResourceDefinitionSpec {
return meta.ResourceDefinitionSpec{
Type: KubernetesType,
Aliases: []resource.Type{},
DefaultNamespace: NamespaceName,
Sensitivity: meta.Sensitive,
}
}
func init() {
proto.RegisterDefaultTypes()
err := protobuf.RegisterDynamic[KubernetesCertsSpec](KubernetesType, &Kubernetes{})
if err != nil {
panic(err)
}
}