Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
K
k3s
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jacklull
k3s
Commits
981bf193
Unverified
Commit
981bf193
authored
Feb 03, 2019
by
Rafael Fernández López
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
kubeadm: do not create etcd datastore if we are in dryrun mode
This allows for kubeadm tests to pass when run with an unprivileged user.
parent
76722926
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
17 additions
and
14 deletions
+17
-14
join.go
cmd/kubeadm/app/cmd/join.go
+5
-0
etcd.go
cmd/kubeadm/app/cmd/phases/init/etcd.go
+11
-1
local.go
cmd/kubeadm/app/phases/etcd/local.go
+1
-13
No files found.
cmd/kubeadm/app/cmd/join.go
View file @
981bf193
...
...
@@ -571,6 +571,11 @@ func (j *joinData) PostInstallControlPlane(initConfiguration *kubeadmapi.InitCon
// in case of local etcd
if
initConfiguration
.
Etcd
.
External
==
nil
{
// creates target folder if doesn't exist already
if
err
:=
os
.
MkdirAll
(
initConfiguration
.
Etcd
.
Local
.
DataDir
,
0700
);
err
!=
nil
{
return
errors
.
Wrapf
(
err
,
"failed to create etcd directory %q"
,
initConfiguration
.
Etcd
.
Local
.
DataDir
)
}
// Adds a new etcd instance; in order to do this the new etcd instance should be "announced" to
// the existing etcd members before being created.
// This operation must be executed after kubelet is already started in order to minimize the time
...
...
cmd/kubeadm/app/cmd/phases/init/etcd.go
View file @
981bf193
...
...
@@ -18,6 +18,7 @@ package phases
import
(
"fmt"
"os"
"github.com/pkg/errors"
"k8s.io/klog"
...
...
@@ -31,7 +32,7 @@ import (
var
(
etcdLocalExample
=
normalizer
.
Examples
(
`
# Generates the static Pod manifest file for etcd, functionally
# Generates the static Pod manifest file for etcd, functionally
# equivalent to what is generated by kubeadm init.
kubeadm init phase etcd local
...
...
@@ -43,6 +44,7 @@ var (
type
etcdData
interface
{
Cfg
()
*
kubeadmapi
.
InitConfiguration
DryRun
()
bool
ManifestDir
()
string
}
...
...
@@ -89,6 +91,14 @@ func runEtcdPhaseLocal() func(c workflow.RunData) error {
// Add etcd static pod spec only if external etcd is not configured
if
cfg
.
Etcd
.
External
==
nil
{
// creates target folder if doesn't exist already
if
!
data
.
DryRun
()
{
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
)
}
}
else
{
fmt
.
Printf
(
"[dryrun] Would ensure that %q directory is present
\n
"
,
cfg
.
Etcd
.
Local
.
DataDir
)
}
fmt
.
Printf
(
"[etcd] Creating static Pod manifest for local etcd in %q
\n
"
,
data
.
ManifestDir
())
if
err
:=
etcdphase
.
CreateLocalEtcdStaticPodManifestFile
(
data
.
ManifestDir
(),
cfg
.
NodeRegistration
.
Name
,
&
cfg
.
ClusterConfiguration
,
&
cfg
.
LocalAPIEndpoint
);
err
!=
nil
{
return
errors
.
Wrap
(
err
,
"error creating local etcd static pod manifest file"
)
...
...
cmd/kubeadm/app/phases/etcd/local.go
View file @
981bf193
...
...
@@ -18,7 +18,6 @@ package etcd
import
(
"fmt"
"os"
"path/filepath"
"strings"
"time"
...
...
@@ -51,14 +50,8 @@ func CreateLocalEtcdStaticPodManifestFile(manifestDir string, nodeName string, c
return
errors
.
New
(
"etcd static pod manifest cannot be generated for cluster using external etcd"
)
}
// gets etcd StaticPodSpec
emptyInitialCluster
:=
[]
etcdutil
.
Member
{}
spec
:=
GetEtcdPodSpec
(
cfg
,
endpoint
,
nodeName
,
[]
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
,
endpoint
,
nodeName
,
emptyInitialCluster
)
// writes etcd StaticPod to disk
if
err
:=
staticpodutil
.
WriteStaticPodToDisk
(
kubeadmconstants
.
Etcd
,
manifestDir
,
spec
);
err
!=
nil
{
return
err
...
...
@@ -110,11 +103,6 @@ func CreateStackedEtcdStaticPodManifestFile(client clientset.Interface, manifest
fmt
.
Println
(
"[etcd] Announced new etcd member joining to the existing etcd cluster"
)
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"
)
// gets etcd StaticPodSpec, actualized for the current InitConfiguration and the new list of etcd members
spec
:=
GetEtcdPodSpec
(
cfg
,
endpoint
,
nodeName
,
initialCluster
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment