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
545cd055
Commit
545cd055
authored
Feb 22, 2018
by
Rostislav M. Georgiev
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
kubeadm: Add writable parameter to *ExtraVolumes init config
Signed-off-by:
Rostislav M. Georgiev
<
rostislavg@vmware.com
>
parent
891b4710
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
45 additions
and
25 deletions
+45
-25
fuzzer.go
cmd/kubeadm/app/apis/kubeadm/fuzzer/fuzzer.go
+1
-0
types.go
cmd/kubeadm/app/apis/kubeadm/types.go
+2
-0
types.go
cmd/kubeadm/app/apis/kubeadm/v1alpha1/types.go
+2
-0
zz_generated.conversion.go
...eadm/app/apis/kubeadm/v1alpha1/zz_generated.conversion.go
+2
-0
volumes.go
cmd/kubeadm/app/phases/controlplane/volumes.go
+5
-5
volumes_test.go
cmd/kubeadm/app/phases/controlplane/volumes_test.go
+33
-20
No files found.
cmd/kubeadm/app/apis/kubeadm/fuzzer/fuzzer.go
View file @
545cd055
...
@@ -60,6 +60,7 @@ func Funcs(codecs runtimeserializer.CodecFactory) []interface{} {
...
@@ -60,6 +60,7 @@ func Funcs(codecs runtimeserializer.CodecFactory) []interface{} {
Name
:
"foo"
,
Name
:
"foo"
,
HostPath
:
"foo"
,
HostPath
:
"foo"
,
MountPath
:
"foo"
,
MountPath
:
"foo"
,
Writable
:
false
,
}}
}}
obj
.
Etcd
.
ExtraArgs
=
map
[
string
]
string
{
"foo"
:
"foo"
}
obj
.
Etcd
.
ExtraArgs
=
map
[
string
]
string
{
"foo"
:
"foo"
}
obj
.
Etcd
.
SelfHosted
=
&
kubeadm
.
SelfHostedEtcd
{
obj
.
Etcd
.
SelfHosted
=
&
kubeadm
.
SelfHostedEtcd
{
...
...
cmd/kubeadm/app/apis/kubeadm/types.go
View file @
545cd055
...
@@ -281,6 +281,8 @@ type HostPathMount struct {
...
@@ -281,6 +281,8 @@ type HostPathMount struct {
HostPath
string
HostPath
string
// MountPath is the path inside the pod where hostPath will be mounted.
// MountPath is the path inside the pod where hostPath will be mounted.
MountPath
string
MountPath
string
// Writable controls write access to the volume
Writable
bool
}
}
// KubeProxy contains elements describing the proxy configuration.
// KubeProxy contains elements describing the proxy configuration.
...
...
cmd/kubeadm/app/apis/kubeadm/v1alpha1/types.go
View file @
545cd055
...
@@ -259,6 +259,8 @@ type HostPathMount struct {
...
@@ -259,6 +259,8 @@ type HostPathMount struct {
HostPath
string
`json:"hostPath"`
HostPath
string
`json:"hostPath"`
// MountPath is the path inside the pod where hostPath will be mounted.
// MountPath is the path inside the pod where hostPath will be mounted.
MountPath
string
`json:"mountPath"`
MountPath
string
`json:"mountPath"`
// Writable controls write access to the volume
Writable
bool
`json:"writable,omitempty"`
}
}
// KubeProxy contains elements describing the proxy configuration.
// KubeProxy contains elements describing the proxy configuration.
...
...
cmd/kubeadm/app/apis/kubeadm/v1alpha1/zz_generated.conversion.go
View file @
545cd055
...
@@ -155,6 +155,7 @@ func autoConvert_v1alpha1_HostPathMount_To_kubeadm_HostPathMount(in *HostPathMou
...
@@ -155,6 +155,7 @@ func autoConvert_v1alpha1_HostPathMount_To_kubeadm_HostPathMount(in *HostPathMou
out
.
Name
=
in
.
Name
out
.
Name
=
in
.
Name
out
.
HostPath
=
in
.
HostPath
out
.
HostPath
=
in
.
HostPath
out
.
MountPath
=
in
.
MountPath
out
.
MountPath
=
in
.
MountPath
out
.
Writable
=
in
.
Writable
return
nil
return
nil
}
}
...
@@ -167,6 +168,7 @@ func autoConvert_kubeadm_HostPathMount_To_v1alpha1_HostPathMount(in *kubeadm.Hos
...
@@ -167,6 +168,7 @@ func autoConvert_kubeadm_HostPathMount_To_v1alpha1_HostPathMount(in *kubeadm.Hos
out
.
Name
=
in
.
Name
out
.
Name
=
in
.
Name
out
.
HostPath
=
in
.
HostPath
out
.
HostPath
=
in
.
HostPath
out
.
MountPath
=
in
.
MountPath
out
.
MountPath
=
in
.
MountPath
out
.
Writable
=
in
.
Writable
return
nil
return
nil
}
}
...
...
cmd/kubeadm/app/phases/controlplane/volumes.go
View file @
545cd055
...
@@ -105,9 +105,9 @@ func getHostPathVolumesForTheControlPlane(cfg *kubeadmapi.MasterConfiguration) c
...
@@ -105,9 +105,9 @@ func getHostPathVolumesForTheControlPlane(cfg *kubeadmapi.MasterConfiguration) c
// Merge user defined mounts and ensure unique volume and volume mount
// Merge user defined mounts and ensure unique volume and volume mount
// names
// names
mounts
.
AddExtraHostPathMounts
(
kubeadmconstants
.
KubeAPIServer
,
cfg
.
APIServerExtraVolumes
,
true
,
&
hostPathDirectoryOrCreate
)
mounts
.
AddExtraHostPathMounts
(
kubeadmconstants
.
KubeAPIServer
,
cfg
.
APIServerExtraVolumes
,
&
hostPathDirectoryOrCreate
)
mounts
.
AddExtraHostPathMounts
(
kubeadmconstants
.
KubeControllerManager
,
cfg
.
ControllerManagerExtraVolumes
,
true
,
&
hostPathDirectoryOrCreate
)
mounts
.
AddExtraHostPathMounts
(
kubeadmconstants
.
KubeControllerManager
,
cfg
.
ControllerManagerExtraVolumes
,
&
hostPathDirectoryOrCreate
)
mounts
.
AddExtraHostPathMounts
(
kubeadmconstants
.
KubeScheduler
,
cfg
.
SchedulerExtraVolumes
,
true
,
&
hostPathDirectoryOrCreate
)
mounts
.
AddExtraHostPathMounts
(
kubeadmconstants
.
KubeScheduler
,
cfg
.
SchedulerExtraVolumes
,
&
hostPathDirectoryOrCreate
)
return
mounts
return
mounts
}
}
...
@@ -153,10 +153,10 @@ func (c *controlPlaneHostPathMounts) AddHostPathMounts(component string, vols []
...
@@ -153,10 +153,10 @@ func (c *controlPlaneHostPathMounts) AddHostPathMounts(component string, vols []
// AddExtraHostPathMounts adds host path mounts and overwrites the default
// AddExtraHostPathMounts adds host path mounts and overwrites the default
// paths in the case that a user specifies the same volume/volume mount name.
// paths in the case that a user specifies the same volume/volume mount name.
func
(
c
*
controlPlaneHostPathMounts
)
AddExtraHostPathMounts
(
component
string
,
extraVols
[]
kubeadmapi
.
HostPathMount
,
readOnly
bool
,
hostPathType
*
v1
.
HostPathType
)
{
func
(
c
*
controlPlaneHostPathMounts
)
AddExtraHostPathMounts
(
component
string
,
extraVols
[]
kubeadmapi
.
HostPathMount
,
hostPathType
*
v1
.
HostPathType
)
{
for
_
,
extraVol
:=
range
extraVols
{
for
_
,
extraVol
:=
range
extraVols
{
fmt
.
Printf
(
"[controlplane] Adding extra host path mount %q to %q
\n
"
,
extraVol
.
Name
,
component
)
fmt
.
Printf
(
"[controlplane] Adding extra host path mount %q to %q
\n
"
,
extraVol
.
Name
,
component
)
c
.
NewHostPathMount
(
component
,
extraVol
.
Name
,
extraVol
.
HostPath
,
extraVol
.
MountPath
,
readOnly
,
hostPathType
)
c
.
NewHostPathMount
(
component
,
extraVol
.
Name
,
extraVol
.
HostPath
,
extraVol
.
MountPath
,
!
extraVol
.
Writable
,
hostPathType
)
}
}
}
}
...
...
cmd/kubeadm/app/phases/controlplane/volumes_test.go
View file @
545cd055
...
@@ -618,27 +618,40 @@ func TestAddExtraHostPathMounts(t *testing.T) {
...
@@ -618,27 +618,40 @@ func TestAddExtraHostPathMounts(t *testing.T) {
Name
:
"foo"
,
Name
:
"foo"
,
HostPath
:
"/tmp/qux"
,
HostPath
:
"/tmp/qux"
,
MountPath
:
"/tmp/qux"
,
MountPath
:
"/tmp/qux"
,
Writable
:
false
,
},
{
Name
:
"bar"
,
HostPath
:
"/tmp/asd"
,
MountPath
:
"/tmp/asd"
,
Writable
:
true
,
},
},
}
}
mounts
.
AddExtraHostPathMounts
(
"component"
,
hostPathMounts
,
true
,
&
hostPathDirectoryOrCreate
)
mounts
.
AddExtraHostPathMounts
(
"component"
,
hostPathMounts
,
&
hostPathDirectoryOrCreate
)
if
_
,
ok
:=
mounts
.
volumes
[
"component"
][
"foo"
];
!
ok
{
for
_
,
hostMount
:=
range
hostPathMounts
{
t
.
Errorf
(
"Expected to find volume %q"
,
"foo"
)
volumeName
:=
hostMount
.
Name
}
if
_
,
ok
:=
mounts
.
volumes
[
"component"
][
volumeName
];
!
ok
{
vol
,
_
:=
mounts
.
volumes
[
"component"
][
"foo"
]
t
.
Errorf
(
"Expected to find volume %q"
,
volumeName
)
if
vol
.
Name
!=
"foo"
{
}
t
.
Errorf
(
"Expected volume name %q"
,
"foo"
)
vol
:=
mounts
.
volumes
[
"component"
][
volumeName
]
}
if
vol
.
Name
!=
volumeName
{
if
vol
.
HostPath
.
Path
!=
"/tmp/qux"
{
t
.
Errorf
(
"Expected volume name %q"
,
volumeName
)
t
.
Errorf
(
"Expected host path %q"
,
"/tmp/qux"
)
}
}
if
vol
.
HostPath
.
Path
!=
hostMount
.
HostPath
{
if
_
,
ok
:=
mounts
.
volumeMounts
[
"component"
][
"foo"
];
!
ok
{
t
.
Errorf
(
"Expected host path %q"
,
hostMount
.
HostPath
)
t
.
Errorf
(
"Expected to find volume mount %q"
,
"foo"
)
}
}
if
_
,
ok
:=
mounts
.
volumeMounts
[
"component"
][
volumeName
];
!
ok
{
volMount
,
_
:=
mounts
.
volumeMounts
[
"component"
][
"foo"
]
t
.
Errorf
(
"Expected to find volume mount %q"
,
volumeName
)
if
volMount
.
Name
!=
"foo"
{
}
t
.
Errorf
(
"Expected volume mount name %q"
,
"foo"
)
volMount
,
_
:=
mounts
.
volumeMounts
[
"component"
][
volumeName
]
}
if
volMount
.
Name
!=
volumeName
{
if
volMount
.
MountPath
!=
"/tmp/qux"
{
t
.
Errorf
(
"Expected volume mount name %q"
,
volumeName
)
t
.
Errorf
(
"Expected container path %q"
,
"/tmp/qux"
)
}
if
volMount
.
MountPath
!=
hostMount
.
MountPath
{
t
.
Errorf
(
"Expected container path %q"
,
hostMount
.
MountPath
)
}
if
volMount
.
ReadOnly
!=
!
hostMount
.
Writable
{
t
.
Errorf
(
"Expected volume writable setting %t"
,
hostMount
.
Writable
)
}
}
}
}
}
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