@@ -22,31 +22,38 @@ import (
22
22
"github.com/talos-systems/talos/pkg/config/types/v1alpha1/generate"
23
23
"gopkg.in/yaml.v2"
24
24
corev1 "k8s.io/api/core/v1"
25
- k8serrors "k8s.io/apimachinery/pkg/api/errors"
26
25
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
27
26
"sigs.k8s.io/controller-runtime/pkg/client"
28
27
)
29
28
30
- func (r * TalosConfigReconciler ) fetchCertSecret (ctx context.Context , config * bootstrapv1alpha2.TalosConfig , clusterName string ) (* corev1.Secret , error ) {
29
+ func (r * TalosConfigReconciler ) fetchInputSecret (ctx context.Context , config * bootstrapv1alpha2.TalosConfig , clusterName string ) (* corev1.Secret , error ) {
31
30
32
- certSecret := & corev1.Secret {}
31
+ inputSecret := & corev1.Secret {}
33
32
err := r .Client .Get (context .Background (), client.ObjectKey {
34
33
Namespace : config .GetNamespace (),
35
34
Name : clusterName ,
36
- }, certSecret )
35
+ }, inputSecret )
37
36
38
- if err != nil && k8serrors .IsNotFound (err ) {
39
- return nil , nil
40
- } else if err != nil {
37
+ if err != nil {
41
38
return nil , err
42
39
}
43
40
44
- return certSecret , nil
41
+ return inputSecret , nil
45
42
}
46
43
47
- func (r * TalosConfigReconciler ) writeCertSecret (ctx context.Context , config * bootstrapv1alpha2.TalosConfig , clusterName string , certs * generate.Certs ) error {
44
+ func (r * TalosConfigReconciler ) writeInputSecret (ctx context.Context , config * bootstrapv1alpha2.TalosConfig , clusterName string , input * generate.Input ) error {
45
+
46
+ certMarshal , err := yaml .Marshal (input .Certs )
47
+ if err != nil {
48
+ return err
49
+ }
50
+
51
+ kubeTokenMarshal , err := yaml .Marshal (input .KubeadmTokens )
52
+ if err != nil {
53
+ return err
54
+ }
48
55
49
- certMarshal , err := yaml .Marshal (certs )
56
+ trustdInfoMarshal , err := yaml .Marshal (input . TrustdInfo )
50
57
if err != nil {
51
58
return err
52
59
}
@@ -56,7 +63,11 @@ func (r *TalosConfigReconciler) writeCertSecret(ctx context.Context, config *boo
56
63
Namespace : config .GetNamespace (),
57
64
Name : clusterName ,
58
65
},
59
- Data : map [string ][]byte {"certs" : certMarshal },
66
+ Data : map [string ][]byte {
67
+ "certs" : certMarshal ,
68
+ "kubeTokens" : kubeTokenMarshal ,
69
+ "trustdInfo" : trustdInfoMarshal ,
70
+ },
60
71
}
61
72
62
73
err = r .Client .Create (ctx , certSecret )
0 commit comments