@@ -18,6 +18,7 @@ package etcd
18
18
19
19
import (
20
20
"fmt"
21
+ "os"
21
22
"path/filepath"
22
23
"strings"
23
24
@@ -48,6 +49,12 @@ func CreateLocalEtcdStaticPodManifestFile(manifestDir string, cfg *kubeadmapi.In
48
49
}
49
50
// gets etcd StaticPodSpec
50
51
emptyInitialCluster := []etcdutil.Member {}
52
+
53
+ // creates target folder if not already exists
54
+ if err := os .MkdirAll (cfg .Etcd .Local .DataDir , 0700 ); err != nil {
55
+ return errors .Wrapf (err , "failed to create etcd directory %q" , cfg .Etcd .Local .DataDir )
56
+ }
57
+
51
58
spec := GetEtcdPodSpec (cfg , emptyInitialCluster )
52
59
// writes etcd StaticPod to disk
53
60
if err := staticpodutil .WriteStaticPodToDisk (kubeadmconstants .Etcd , manifestDir , spec ); err != nil {
@@ -100,6 +107,11 @@ func CreateStackedEtcdStaticPodManifestFile(client clientset.Interface, manifest
100
107
fmt .Println ("[etcd] Announced new etcd member joining to the existing etcd cluster" )
101
108
klog .V (1 ).Infof ("Updated etcd member list: %v" , initialCluster )
102
109
110
+ // creates target folder if not already exists
111
+ if err := os .MkdirAll (cfg .Etcd .Local .DataDir , 0700 ); err != nil {
112
+ return errors .Wrapf (err , "failed to create etcd directory %q" , cfg .Etcd .Local .DataDir )
113
+ }
114
+
103
115
klog .V (1 ).Info ("Creating local etcd static pod manifest file" )
104
116
// gets etcd StaticPodSpec, actualized for the current InitConfiguration and the new list of etcd members
105
117
spec := GetEtcdPodSpec (cfg , initialCluster )
0 commit comments