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
40db1d19
Commit
40db1d19
authored
Apr 25, 2017
by
Kubernetes Submit Queue
Committed by
GitHub
Apr 25, 2017
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #44601 from xilabao/fix-certdir-in-kubeadm
Automatic merge from submit-queue fix kubeadm init when certdir changed If --cert-dir specified, `kubeadm init` failed.
parents
cd380b58
c1197924
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
94 additions
and
0 deletions
+94
-0
BUILD
cmd/kubeadm/app/master/BUILD
+1
-0
manifests.go
cmd/kubeadm/app/master/manifests.go
+22
-0
manifests_test.go
cmd/kubeadm/app/master/manifests_test.go
+71
-0
No files found.
cmd/kubeadm/app/master/BUILD
View file @
40db1d19
...
...
@@ -18,6 +18,7 @@ go_library(
tags = ["automanaged"],
deps = [
"//cmd/kubeadm/app/apis/kubeadm:go_default_library",
"//cmd/kubeadm/app/apis/kubeadm/v1alpha1:go_default_library",
"//cmd/kubeadm/app/constants:go_default_library",
"//cmd/kubeadm/app/images:go_default_library",
"//cmd/kubeadm/app/util/kubeconfig:go_default_library",
...
...
cmd/kubeadm/app/master/manifests.go
View file @
40db1d19
...
...
@@ -30,6 +30,7 @@ import (
"k8s.io/apimachinery/pkg/util/intstr"
api
"k8s.io/client-go/pkg/api/v1"
kubeadmapi
"k8s.io/kubernetes/cmd/kubeadm/app/apis/kubeadm"
kubeadmapiext
"k8s.io/kubernetes/cmd/kubeadm/app/apis/kubeadm/v1alpha1"
kubeadmconstants
"k8s.io/kubernetes/cmd/kubeadm/app/constants"
"k8s.io/kubernetes/cmd/kubeadm/app/images"
bootstrapapi
"k8s.io/kubernetes/pkg/bootstrap/api"
...
...
@@ -73,6 +74,11 @@ func WriteStaticPodManifests(cfg *kubeadmapi.MasterConfiguration) error {
volumeMounts
=
append
(
volumeMounts
,
pkiVolumeMount
())
}
if
cfg
.
CertificatesDir
!=
kubeadmapiext
.
DefaultCertificatesDir
{
volumes
=
append
(
volumes
,
newVolume
(
"certdir"
,
cfg
.
CertificatesDir
))
volumeMounts
=
append
(
volumeMounts
,
newVolumeMount
(
"certdir"
,
cfg
.
CertificatesDir
))
}
k8sVersion
,
err
:=
version
.
ParseSemantic
(
cfg
.
KubernetesVersion
)
if
err
!=
nil
{
return
err
...
...
@@ -146,6 +152,22 @@ func WriteStaticPodManifests(cfg *kubeadmapi.MasterConfiguration) error {
return
nil
}
func
newVolume
(
name
,
path
string
)
api
.
Volume
{
return
api
.
Volume
{
Name
:
name
,
VolumeSource
:
api
.
VolumeSource
{
HostPath
:
&
api
.
HostPathVolumeSource
{
Path
:
path
},
},
}
}
func
newVolumeMount
(
name
,
path
string
)
api
.
VolumeMount
{
return
api
.
VolumeMount
{
Name
:
name
,
MountPath
:
path
,
}
}
// etcdVolume exposes a path on the host in order to guarantee data survival during reboot.
func
etcdVolume
(
cfg
*
kubeadmapi
.
MasterConfiguration
)
api
.
Volume
{
return
api
.
Volume
{
...
...
cmd/kubeadm/app/master/manifests_test.go
View file @
40db1d19
...
...
@@ -124,6 +124,77 @@ func TestWriteStaticPodManifests(t *testing.T) {
}
}
func
TestNewVolume
(
t
*
testing
.
T
)
{
var
tests
=
[]
struct
{
name
string
path
string
expected
api
.
Volume
}{
{
name
:
"foo"
,
path
:
"/etc/foo"
,
expected
:
api
.
Volume
{
Name
:
"foo"
,
VolumeSource
:
api
.
VolumeSource
{
HostPath
:
&
api
.
HostPathVolumeSource
{
Path
:
"/etc/foo"
},
}},
},
}
for
_
,
rt
:=
range
tests
{
actual
:=
newVolume
(
rt
.
name
,
rt
.
path
)
if
actual
.
Name
!=
rt
.
expected
.
Name
{
t
.
Errorf
(
"failed newVolume:
\n\t
expected: %s
\n\t
actual: %s"
,
rt
.
expected
.
Name
,
actual
.
Name
,
)
}
if
actual
.
VolumeSource
.
HostPath
.
Path
!=
rt
.
expected
.
VolumeSource
.
HostPath
.
Path
{
t
.
Errorf
(
"failed newVolume:
\n\t
expected: %s
\n\t
actual: %s"
,
rt
.
expected
.
VolumeSource
.
HostPath
.
Path
,
actual
.
VolumeSource
.
HostPath
.
Path
,
)
}
}
}
func
TestNewVolumeMount
(
t
*
testing
.
T
)
{
var
tests
=
[]
struct
{
name
string
path
string
expected
api
.
VolumeMount
}{
{
name
:
"foo"
,
path
:
"/etc/foo"
,
expected
:
api
.
VolumeMount
{
Name
:
"foo"
,
MountPath
:
"/etc/foo"
,
},
},
}
for
_
,
rt
:=
range
tests
{
actual
:=
newVolumeMount
(
rt
.
name
,
rt
.
path
)
if
actual
.
Name
!=
rt
.
expected
.
Name
{
t
.
Errorf
(
"failed newVolumeMount:
\n\t
expected: %s
\n\t
actual: %s"
,
rt
.
expected
.
Name
,
actual
.
Name
,
)
}
if
actual
.
MountPath
!=
rt
.
expected
.
MountPath
{
t
.
Errorf
(
"failed newVolumeMount:
\n\t
expected: %s
\n\t
actual: %s"
,
rt
.
expected
.
MountPath
,
actual
.
MountPath
,
)
}
}
}
func
TestEtcdVolume
(
t
*
testing
.
T
)
{
var
tests
=
[]
struct
{
cfg
*
kubeadmapi
.
MasterConfiguration
...
...
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