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
7e82985f
Commit
7e82985f
authored
Feb 28, 2017
by
Jamie Hannaford
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Allow configurable etcd options
parent
5b4a814d
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
103 additions
and
26 deletions
+103
-26
env.go
cmd/kubeadm/app/apis/kubeadm/env.go
+0
-2
fuzzer.go
cmd/kubeadm/app/apis/kubeadm/fuzzer/fuzzer.go
+1
-0
types.go
cmd/kubeadm/app/apis/kubeadm/types.go
+2
-1
defaults.go
cmd/kubeadm/app/apis/kubeadm/v1alpha1/defaults.go
+5
-0
types.go
cmd/kubeadm/app/apis/kubeadm/v1alpha1/types.go
+6
-4
manifests.go
cmd/kubeadm/app/master/manifests.go
+22
-12
manifests_test.go
cmd/kubeadm/app/master/manifests_test.go
+66
-6
checks.go
cmd/kubeadm/app/preflight/checks.go
+1
-1
No files found.
cmd/kubeadm/app/apis/kubeadm/env.go
View file @
7e82985f
...
...
@@ -31,7 +31,6 @@ func SetEnvParams() *EnvParams {
envParams
:=
map
[
string
]
string
{
"kubernetes_dir"
:
"/etc/kubernetes"
,
"host_etcd_path"
:
"/var/lib/etcd"
,
"hyperkube_image"
:
""
,
"repo_prefix"
:
"gcr.io/google_containers"
,
"etcd_image"
:
""
,
...
...
@@ -45,7 +44,6 @@ func SetEnvParams() *EnvParams {
return
&
EnvParams
{
KubernetesDir
:
path
.
Clean
(
envParams
[
"kubernetes_dir"
]),
HostEtcdPath
:
path
.
Clean
(
envParams
[
"host_etcd_path"
]),
HyperkubeImage
:
envParams
[
"hyperkube_image"
],
RepositoryPrefix
:
envParams
[
"repo_prefix"
],
EtcdImage
:
envParams
[
"etcd_image"
],
...
...
cmd/kubeadm/app/apis/kubeadm/fuzzer/fuzzer.go
View file @
7e82985f
...
...
@@ -36,6 +36,7 @@ func KubeadmFuzzerFuncs(t apitesting.TestingCommon) []interface{} {
obj
.
CertificatesDir
=
"foo"
obj
.
APIServerCertSANs
=
[]
string
{}
obj
.
Token
=
"foo"
obj
.
Etcd
.
DataDir
=
"foo"
},
func
(
obj
*
kubeadm
.
NodeConfiguration
,
c
fuzz
.
Continue
)
{
c
.
FuzzNoCustom
(
obj
)
...
...
cmd/kubeadm/app/apis/kubeadm/types.go
View file @
7e82985f
...
...
@@ -24,7 +24,6 @@ import (
type
EnvParams
struct
{
KubernetesDir
string
HostEtcdPath
string
HyperkubeImage
string
RepositoryPrefix
string
EtcdImage
string
...
...
@@ -82,6 +81,8 @@ type Etcd struct {
CAFile
string
CertFile
string
KeyFile
string
DataDir
string
ExtraArgs
map
[
string
]
string
}
type
NodeConfiguration
struct
{
...
...
cmd/kubeadm/app/apis/kubeadm/v1alpha1/defaults.go
View file @
7e82985f
...
...
@@ -32,6 +32,7 @@ const (
DefaultAuthorizationMode
=
"RBAC"
DefaultCACertPath
=
"/etc/kubernetes/pki/ca.crt"
DefaultCertificatesDir
=
"/etc/kubernetes/pki"
DefaultEtcdDataDir
=
"/var/lib/etcd"
)
func
addDefaultingFuncs
(
scheme
*
runtime
.
Scheme
)
error
{
...
...
@@ -70,6 +71,10 @@ func SetDefaults_MasterConfiguration(obj *MasterConfiguration) {
if
obj
.
TokenTTL
==
0
{
obj
.
TokenTTL
=
constants
.
DefaultTokenDuration
}
if
obj
.
Etcd
.
DataDir
==
""
{
obj
.
Etcd
.
DataDir
=
DefaultEtcdDataDir
}
}
func
SetDefaults_NodeConfiguration
(
obj
*
NodeConfiguration
)
{
...
...
cmd/kubeadm/app/apis/kubeadm/v1alpha1/types.go
View file @
7e82985f
...
...
@@ -70,10 +70,12 @@ type Networking struct {
}
type
Etcd
struct
{
Endpoints
[]
string
`json:"endpoints"`
CAFile
string
`json:"caFile"`
CertFile
string
`json:"certFile"`
KeyFile
string
`json:"keyFile"`
Endpoints
[]
string
`json:"endpoints"`
CAFile
string
`json:"caFile"`
CertFile
string
`json:"certFile"`
KeyFile
string
`json:"keyFile"`
DataDir
string
`json:"dataDir"`
ExtraArgs
map
[
string
]
string
`json:"extraArgs"`
}
type
NodeConfiguration
struct
{
...
...
cmd/kubeadm/app/master/manifests.go
View file @
7e82985f
...
...
@@ -102,21 +102,16 @@ func WriteStaticPodManifests(cfg *kubeadmapi.MasterConfiguration) error {
// Add etcd static pod spec only if external etcd is not configured
if
len
(
cfg
.
Etcd
.
Endpoints
)
==
0
{
etcdPod
:=
componentPod
(
api
.
Container
{
Name
:
etcd
,
Command
:
[]
string
{
"etcd"
,
"--listen-client-urls=http://127.0.0.1:2379"
,
"--advertise-client-urls=http://127.0.0.1:2379"
,
"--data-dir=/var/lib/etcd"
,
},
VolumeMounts
:
[]
api
.
VolumeMount
{
certsVolumeMount
(),
etcdVolumeMount
(),
k8sVolumeMount
()},
Name
:
etcd
,
Command
:
getEtcdCommand
(
cfg
),
VolumeMounts
:
[]
api
.
VolumeMount
{
certsVolumeMount
(),
etcdVolumeMount
(
cfg
.
Etcd
.
DataDir
),
k8sVolumeMount
()},
Image
:
images
.
GetCoreImage
(
images
.
KubeEtcdImage
,
cfg
,
kubeadmapi
.
GlobalEnvParams
.
EtcdImage
),
LivenessProbe
:
componentProbe
(
2379
,
"/health"
,
api
.
URISchemeHTTP
),
},
certsVolume
(
cfg
),
etcdVolume
(
cfg
),
k8sVolume
(
cfg
))
etcdPod
.
Spec
.
SecurityContext
=
&
api
.
PodSecurityContext
{
SELinuxOptions
:
&
api
.
SELinuxOptions
{
// Unconfine the etcd container so it can write to
/var/lib/etcd
with SELinux enforcing:
// Unconfine the etcd container so it can write to
the data dir
with SELinux enforcing:
Type
:
"spc_t"
,
},
}
...
...
@@ -146,15 +141,15 @@ func etcdVolume(cfg *kubeadmapi.MasterConfiguration) api.Volume {
return
api
.
Volume
{
Name
:
"etcd"
,
VolumeSource
:
api
.
VolumeSource
{
HostPath
:
&
api
.
HostPathVolumeSource
{
Path
:
kubeadmapi
.
GlobalEnvParams
.
HostEtcdPath
},
HostPath
:
&
api
.
HostPathVolumeSource
{
Path
:
cfg
.
Etcd
.
DataDir
},
},
}
}
func
etcdVolumeMount
()
api
.
VolumeMount
{
func
etcdVolumeMount
(
dataDir
string
)
api
.
VolumeMount
{
return
api
.
VolumeMount
{
Name
:
"etcd"
,
MountPath
:
"/var/lib/etcd"
,
MountPath
:
dataDir
,
}
}
...
...
@@ -367,6 +362,21 @@ func getAPIServerCommand(cfg *kubeadmapi.MasterConfiguration, selfHosted bool) [
return
command
}
func
getEtcdCommand
(
cfg
*
kubeadmapi
.
MasterConfiguration
)
[]
string
{
var
command
[]
string
defaultArguments
:=
map
[
string
]
string
{
"listen-client-urls"
:
"http://127.0.0.1:2379"
,
"advertise-client-urls"
:
"http://127.0.0.1:2379"
,
"data-dir"
:
cfg
.
Etcd
.
DataDir
,
}
command
=
append
(
command
,
"etcd"
)
command
=
append
(
command
,
getExtraParameters
(
cfg
.
Etcd
.
ExtraArgs
,
defaultArguments
)
...
)
return
command
}
func
getControllerManagerCommand
(
cfg
*
kubeadmapi
.
MasterConfiguration
,
selfHosted
bool
)
[]
string
{
var
command
[]
string
...
...
cmd/kubeadm/app/master/manifests_test.go
View file @
7e82985f
...
...
@@ -31,7 +31,10 @@ import (
kubeadmapi
"k8s.io/kubernetes/cmd/kubeadm/app/apis/kubeadm"
)
const
testCertsDir
=
"/var/lib/certs"
const
(
testCertsDir
=
"/var/lib/certs"
etcdDataDir
=
"/var/lib/etcd"
)
func
TestWriteStaticPodManifests
(
t
*
testing
.
T
)
{
tmpdir
,
err
:=
ioutil
.
TempDir
(
""
,
""
)
...
...
@@ -122,12 +125,13 @@ func TestEtcdVolume(t *testing.T) {
expected
api
.
Volume
}{
{
cfg
:
&
kubeadmapi
.
MasterConfiguration
{},
cfg
:
&
kubeadmapi
.
MasterConfiguration
{
Etcd
:
kubeadmapi
.
Etcd
{
DataDir
:
etcdDataDir
},
},
expected
:
api
.
Volume
{
Name
:
"etcd"
,
VolumeSource
:
api
.
VolumeSource
{
HostPath
:
&
api
.
HostPathVolumeSource
{
Path
:
kubeadmapi
.
GlobalEnvParams
.
HostEtcdPath
},
HostPath
:
&
api
.
HostPathVolumeSource
{
Path
:
etcdDataDir
},
}},
},
}
...
...
@@ -158,13 +162,13 @@ func TestEtcdVolumeMount(t *testing.T) {
{
expected
:
api
.
VolumeMount
{
Name
:
"etcd"
,
MountPath
:
"/var/lib/etcd"
,
MountPath
:
etcdDataDir
,
},
},
}
for
_
,
rt
:=
range
tests
{
actual
:=
etcdVolumeMount
()
actual
:=
etcdVolumeMount
(
etcdDataDir
)
if
actual
.
Name
!=
rt
.
expected
.
Name
{
t
.
Errorf
(
"failed etcdVolumeMount:
\n\t
expected: %s
\n\t
actual: %s"
,
...
...
@@ -624,6 +628,62 @@ func TestGetControllerManagerCommand(t *testing.T) {
}
}
func
TestGetEtcdCommand
(
t
*
testing
.
T
)
{
var
tests
=
[]
struct
{
cfg
*
kubeadmapi
.
MasterConfiguration
expected
[]
string
}{
{
cfg
:
&
kubeadmapi
.
MasterConfiguration
{
Etcd
:
kubeadmapi
.
Etcd
{
DataDir
:
"/var/lib/etcd"
},
},
expected
:
[]
string
{
"etcd"
,
"--listen-client-urls=http://127.0.0.1:2379"
,
"--advertise-client-urls=http://127.0.0.1:2379"
,
"--data-dir=/var/lib/etcd"
,
},
},
{
cfg
:
&
kubeadmapi
.
MasterConfiguration
{
Etcd
:
kubeadmapi
.
Etcd
{
DataDir
:
"/var/lib/etcd"
,
ExtraArgs
:
map
[
string
]
string
{
"listen-client-urls"
:
"http://10.0.1.10:2379"
,
"advertise-client-urls"
:
"http://10.0.1.10:2379"
,
},
},
},
expected
:
[]
string
{
"etcd"
,
"--listen-client-urls=http://10.0.1.10:2379"
,
"--advertise-client-urls=http://10.0.1.10:2379"
,
"--data-dir=/var/lib/etcd"
,
},
},
{
cfg
:
&
kubeadmapi
.
MasterConfiguration
{
Etcd
:
kubeadmapi
.
Etcd
{
DataDir
:
"/etc/foo"
},
},
expected
:
[]
string
{
"etcd"
,
"--listen-client-urls=http://127.0.0.1:2379"
,
"--advertise-client-urls=http://127.0.0.1:2379"
,
"--data-dir=/etc/foo"
,
},
},
}
for
_
,
rt
:=
range
tests
{
actual
:=
getEtcdCommand
(
rt
.
cfg
)
sort
.
Strings
(
actual
)
sort
.
Strings
(
rt
.
expected
)
if
!
reflect
.
DeepEqual
(
actual
,
rt
.
expected
)
{
t
.
Errorf
(
"failed getEtcdCommand:
\n
expected:
\n
%v
\n
saw:
\n
%v"
,
rt
.
expected
,
actual
)
}
}
}
func
TestGetSchedulerCommand
(
t
*
testing
.
T
)
{
var
tests
=
[]
struct
{
cfg
*
kubeadmapi
.
MasterConfiguration
...
...
cmd/kubeadm/app/preflight/checks.go
View file @
7e82985f
...
...
@@ -515,7 +515,7 @@ func RunInitMasterChecks(cfg *kubeadmapi.MasterConfiguration) error {
// Only do etcd related checks when no external endpoints were specified
checks
=
append
(
checks
,
PortOpenCheck
{
port
:
2379
},
DirAvailableCheck
{
Path
:
"/var/lib/etcd"
},
DirAvailableCheck
{
Path
:
cfg
.
Etcd
.
DataDir
},
)
}
else
{
// Only check etcd version when external endpoints are specified
...
...
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