mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-20 18:31:15 +00:00
Merge pull request #71885 from dims/create-etcd-with-0700-permissions
Create /var/lib/etcd with 0700
This commit is contained in:
commit
0b13221f68
@ -18,6 +18,7 @@ package etcd
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
@ -48,6 +49,12 @@ func CreateLocalEtcdStaticPodManifestFile(manifestDir string, cfg *kubeadmapi.In
|
|||||||
}
|
}
|
||||||
// gets etcd StaticPodSpec
|
// gets etcd StaticPodSpec
|
||||||
emptyInitialCluster := []etcdutil.Member{}
|
emptyInitialCluster := []etcdutil.Member{}
|
||||||
|
|
||||||
|
// creates target folder if not already exists
|
||||||
|
if err := os.MkdirAll(cfg.Etcd.Local.DataDir, 0700); err != nil {
|
||||||
|
return errors.Wrapf(err, "failed to create etcd directory %q", cfg.Etcd.Local.DataDir)
|
||||||
|
}
|
||||||
|
|
||||||
spec := GetEtcdPodSpec(cfg, emptyInitialCluster)
|
spec := GetEtcdPodSpec(cfg, emptyInitialCluster)
|
||||||
// writes etcd StaticPod to disk
|
// writes etcd StaticPod to disk
|
||||||
if err := staticpodutil.WriteStaticPodToDisk(kubeadmconstants.Etcd, manifestDir, spec); err != nil {
|
if err := staticpodutil.WriteStaticPodToDisk(kubeadmconstants.Etcd, manifestDir, spec); err != nil {
|
||||||
@ -100,6 +107,11 @@ func CreateStackedEtcdStaticPodManifestFile(client clientset.Interface, manifest
|
|||||||
fmt.Println("[etcd] Announced new etcd member joining to the existing etcd cluster")
|
fmt.Println("[etcd] Announced new etcd member joining to the existing etcd cluster")
|
||||||
klog.V(1).Infof("Updated etcd member list: %v", initialCluster)
|
klog.V(1).Infof("Updated etcd member list: %v", initialCluster)
|
||||||
|
|
||||||
|
// creates target folder if not already exists
|
||||||
|
if err := os.MkdirAll(cfg.Etcd.Local.DataDir, 0700); err != nil {
|
||||||
|
return errors.Wrapf(err, "failed to create etcd directory %q", cfg.Etcd.Local.DataDir)
|
||||||
|
}
|
||||||
|
|
||||||
klog.V(1).Info("Creating local etcd static pod manifest file")
|
klog.V(1).Info("Creating local etcd static pod manifest file")
|
||||||
// gets etcd StaticPodSpec, actualized for the current InitConfiguration and the new list of etcd members
|
// gets etcd StaticPodSpec, actualized for the current InitConfiguration and the new list of etcd members
|
||||||
spec := GetEtcdPodSpec(cfg, initialCluster)
|
spec := GetEtcdPodSpec(cfg, initialCluster)
|
||||||
|
@ -67,7 +67,7 @@ func TestCreateLocalEtcdStaticPodManifestFile(t *testing.T) {
|
|||||||
KubernetesVersion: "v1.7.0",
|
KubernetesVersion: "v1.7.0",
|
||||||
Etcd: kubeadmapi.Etcd{
|
Etcd: kubeadmapi.Etcd{
|
||||||
Local: &kubeadmapi.LocalEtcd{
|
Local: &kubeadmapi.LocalEtcd{
|
||||||
DataDir: "/var/lib/etcd",
|
DataDir: tmpdir + "/etcd",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
Loading…
Reference in New Issue
Block a user