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
01e4b960
Commit
01e4b960
authored
Aug 24, 2017
by
Di Xu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update kubeadm to use hostpath type
parent
7c72594c
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
136 additions
and
38 deletions
+136
-38
volumes.go
cmd/kubeadm/app/phases/controlplane/volumes.go
+14
-11
volumes_test.go
cmd/kubeadm/app/phases/controlplane/volumes_test.go
+91
-22
local.go
cmd/kubeadm/app/phases/etcd/local.go
+2
-1
podspec_mutation_test.go
cmd/kubeadm/app/phases/selfhosting/podspec_mutation_test.go
+12
-0
selfhosting_test.go
cmd/kubeadm/app/phases/selfhosting/selfhosting_test.go
+4
-0
utils.go
cmd/kubeadm/app/util/staticpod/utils.go
+5
-2
utils_test.go
cmd/kubeadm/app/util/staticpod/utils_test.go
+8
-2
No files found.
cmd/kubeadm/app/phases/controlplane/volumes.go
View file @
01e4b960
...
...
@@ -42,14 +42,16 @@ var caCertsPkiVolumePath = "/etc/pki"
// getHostPathVolumesForTheControlPlane gets the required hostPath volumes and mounts for the control plane
func
getHostPathVolumesForTheControlPlane
(
cfg
*
kubeadmapi
.
MasterConfiguration
)
controlPlaneHostPathMounts
{
hostPathDirectoryOrCreate
:=
v1
.
HostPathDirectoryOrCreate
hostPathFileOrCreate
:=
v1
.
HostPathFileOrCreate
mounts
:=
newControlPlaneHostPathMounts
()
// HostPath volumes for the API Server
// Read-only mount for the certificates directory
// TODO: Always mount the K8s Certificates directory to a static path inside of the container
mounts
.
NewHostPathMount
(
kubeadmconstants
.
KubeAPIServer
,
kubeadmconstants
.
KubeCertificatesVolumeName
,
cfg
.
CertificatesDir
,
cfg
.
CertificatesDir
,
true
)
mounts
.
NewHostPathMount
(
kubeadmconstants
.
KubeAPIServer
,
kubeadmconstants
.
KubeCertificatesVolumeName
,
cfg
.
CertificatesDir
,
cfg
.
CertificatesDir
,
true
,
&
hostPathDirectoryOrCreate
)
// Read-only mount for the ca certs (/etc/ssl/certs) directory
mounts
.
NewHostPathMount
(
kubeadmconstants
.
KubeAPIServer
,
caCertsVolumeName
,
caCertsVolumePath
,
caCertsVolumePath
,
true
)
mounts
.
NewHostPathMount
(
kubeadmconstants
.
KubeAPIServer
,
caCertsVolumeName
,
caCertsVolumePath
,
caCertsVolumePath
,
true
,
&
hostPathDirectoryOrCreate
)
// If external etcd is specified, mount the directories needed for accessing the CA/serving certs and the private key
if
len
(
cfg
.
Etcd
.
Endpoints
)
!=
0
{
...
...
@@ -60,23 +62,23 @@ func getHostPathVolumesForTheControlPlane(cfg *kubeadmapi.MasterConfiguration) c
// HostPath volumes for the controller manager
// Read-only mount for the certificates directory
// TODO: Always mount the K8s Certificates directory to a static path inside of the container
mounts
.
NewHostPathMount
(
kubeadmconstants
.
KubeControllerManager
,
kubeadmconstants
.
KubeCertificatesVolumeName
,
cfg
.
CertificatesDir
,
cfg
.
CertificatesDir
,
true
)
mounts
.
NewHostPathMount
(
kubeadmconstants
.
KubeControllerManager
,
kubeadmconstants
.
KubeCertificatesVolumeName
,
cfg
.
CertificatesDir
,
cfg
.
CertificatesDir
,
true
,
&
hostPathDirectoryOrCreate
)
// Read-only mount for the ca certs (/etc/ssl/certs) directory
mounts
.
NewHostPathMount
(
kubeadmconstants
.
KubeControllerManager
,
caCertsVolumeName
,
caCertsVolumePath
,
caCertsVolumePath
,
true
)
mounts
.
NewHostPathMount
(
kubeadmconstants
.
KubeControllerManager
,
caCertsVolumeName
,
caCertsVolumePath
,
caCertsVolumePath
,
true
,
&
hostPathDirectoryOrCreate
)
// Read-only mount for the controller manager kubeconfig file
controllerManagerKubeConfigFile
:=
filepath
.
Join
(
kubeadmconstants
.
KubernetesDir
,
kubeadmconstants
.
ControllerManagerKubeConfigFileName
)
mounts
.
NewHostPathMount
(
kubeadmconstants
.
KubeControllerManager
,
kubeadmconstants
.
KubeConfigVolumeName
,
controllerManagerKubeConfigFile
,
controllerManagerKubeConfigFile
,
true
)
mounts
.
NewHostPathMount
(
kubeadmconstants
.
KubeControllerManager
,
kubeadmconstants
.
KubeConfigVolumeName
,
controllerManagerKubeConfigFile
,
controllerManagerKubeConfigFile
,
true
,
&
hostPathFileOrCreate
)
// HostPath volumes for the scheduler
// Read-only mount for the scheduler kubeconfig file
schedulerKubeConfigFile
:=
filepath
.
Join
(
kubeadmconstants
.
KubernetesDir
,
kubeadmconstants
.
SchedulerKubeConfigFileName
)
mounts
.
NewHostPathMount
(
kubeadmconstants
.
KubeScheduler
,
kubeadmconstants
.
KubeConfigVolumeName
,
schedulerKubeConfigFile
,
schedulerKubeConfigFile
,
true
)
mounts
.
NewHostPathMount
(
kubeadmconstants
.
KubeScheduler
,
kubeadmconstants
.
KubeConfigVolumeName
,
schedulerKubeConfigFile
,
schedulerKubeConfigFile
,
true
,
&
hostPathFileOrCreate
)
// On some systems were we host-mount /etc/ssl/certs, it is also required to mount /etc/pki. This is needed
// due to symlinks pointing from files in /etc/ssl/certs into /etc/pki/
if
isPkiVolumeMountNeeded
()
{
mounts
.
NewHostPathMount
(
kubeadmconstants
.
KubeAPIServer
,
caCertsPkiVolumeName
,
caCertsPkiVolumePath
,
caCertsPkiVolumePath
,
true
)
mounts
.
NewHostPathMount
(
kubeadmconstants
.
KubeControllerManager
,
caCertsPkiVolumeName
,
caCertsPkiVolumePath
,
caCertsPkiVolumePath
,
true
)
mounts
.
NewHostPathMount
(
kubeadmconstants
.
KubeAPIServer
,
caCertsPkiVolumeName
,
caCertsPkiVolumePath
,
caCertsPkiVolumePath
,
true
,
&
hostPathDirectoryOrCreate
)
mounts
.
NewHostPathMount
(
kubeadmconstants
.
KubeControllerManager
,
caCertsPkiVolumeName
,
caCertsPkiVolumePath
,
caCertsPkiVolumePath
,
true
,
&
hostPathDirectoryOrCreate
)
}
return
mounts
...
...
@@ -95,8 +97,8 @@ func newControlPlaneHostPathMounts() controlPlaneHostPathMounts {
}
}
func
(
c
*
controlPlaneHostPathMounts
)
NewHostPathMount
(
component
,
mountName
,
hostPath
,
containerPath
string
,
readOnly
bool
)
{
c
.
volumes
[
component
]
=
append
(
c
.
volumes
[
component
],
staticpodutil
.
NewVolume
(
mountName
,
hostPath
))
func
(
c
*
controlPlaneHostPathMounts
)
NewHostPathMount
(
component
,
mountName
,
hostPath
,
containerPath
string
,
readOnly
bool
,
hostPathType
*
v1
.
HostPathType
)
{
c
.
volumes
[
component
]
=
append
(
c
.
volumes
[
component
],
staticpodutil
.
NewVolume
(
mountName
,
hostPath
,
hostPathType
))
c
.
volumeMounts
[
component
]
=
append
(
c
.
volumeMounts
[
component
],
staticpodutil
.
NewVolumeMount
(
mountName
,
containerPath
,
readOnly
))
}
...
...
@@ -143,9 +145,10 @@ func getEtcdCertVolumes(etcdCfg kubeadmapi.Etcd) ([]v1.Volume, []v1.VolumeMount)
volumes
:=
[]
v1
.
Volume
{}
volumeMounts
:=
[]
v1
.
VolumeMount
{}
pathType
:=
v1
.
HostPathDirectoryOrCreate
for
i
,
certDir
:=
range
certDirs
.
List
()
{
name
:=
fmt
.
Sprintf
(
"etcd-certs-%d"
,
i
)
volumes
=
append
(
volumes
,
staticpodutil
.
NewVolume
(
name
,
certDir
))
volumes
=
append
(
volumes
,
staticpodutil
.
NewVolume
(
name
,
certDir
,
&
pathType
))
volumeMounts
=
append
(
volumeMounts
,
staticpodutil
.
NewVolumeMount
(
name
,
certDir
,
true
))
}
return
volumes
,
volumeMounts
...
...
cmd/kubeadm/app/phases/controlplane/volumes_test.go
View file @
01e4b960
...
...
@@ -29,6 +29,7 @@ import (
)
func
TestGetEtcdCertVolumes
(
t
*
testing
.
T
)
{
hostPathDirectoryOrCreate
:=
v1
.
HostPathDirectoryOrCreate
var
tests
=
[]
struct
{
ca
,
cert
,
key
string
vol
[]
v1
.
Volume
...
...
@@ -67,7 +68,10 @@ func TestGetEtcdCertVolumes(t *testing.T) {
{
Name
:
"etcd-certs-0"
,
VolumeSource
:
v1
.
VolumeSource
{
HostPath
:
&
v1
.
HostPathVolumeSource
{
Path
:
"/var/lib/certs/etcd"
},
HostPath
:
&
v1
.
HostPathVolumeSource
{
Path
:
"/var/lib/certs/etcd"
,
Type
:
&
hostPathDirectoryOrCreate
,
},
},
},
},
...
...
@@ -88,13 +92,19 @@ func TestGetEtcdCertVolumes(t *testing.T) {
{
Name
:
"etcd-certs-0"
,
VolumeSource
:
v1
.
VolumeSource
{
HostPath
:
&
v1
.
HostPathVolumeSource
{
Path
:
"/etc/certs/etcd"
},
HostPath
:
&
v1
.
HostPathVolumeSource
{
Path
:
"/etc/certs/etcd"
,
Type
:
&
hostPathDirectoryOrCreate
,
},
},
},
{
Name
:
"etcd-certs-1"
,
VolumeSource
:
v1
.
VolumeSource
{
HostPath
:
&
v1
.
HostPathVolumeSource
{
Path
:
"/var/lib/certs/etcd"
},
HostPath
:
&
v1
.
HostPathVolumeSource
{
Path
:
"/var/lib/certs/etcd"
,
Type
:
&
hostPathDirectoryOrCreate
,
},
},
},
},
...
...
@@ -120,19 +130,28 @@ func TestGetEtcdCertVolumes(t *testing.T) {
{
Name
:
"etcd-certs-0"
,
VolumeSource
:
v1
.
VolumeSource
{
HostPath
:
&
v1
.
HostPathVolumeSource
{
Path
:
"/etc/certs/etcd"
},
HostPath
:
&
v1
.
HostPathVolumeSource
{
Path
:
"/etc/certs/etcd"
,
Type
:
&
hostPathDirectoryOrCreate
,
},
},
},
{
Name
:
"etcd-certs-1"
,
VolumeSource
:
v1
.
VolumeSource
{
HostPath
:
&
v1
.
HostPathVolumeSource
{
Path
:
"/var/lib/certs/etcd"
},
HostPath
:
&
v1
.
HostPathVolumeSource
{
Path
:
"/var/lib/certs/etcd"
,
Type
:
&
hostPathDirectoryOrCreate
,
},
},
},
{
Name
:
"etcd-certs-2"
,
VolumeSource
:
v1
.
VolumeSource
{
HostPath
:
&
v1
.
HostPathVolumeSource
{
Path
:
"/var/lib/certs/private"
},
HostPath
:
&
v1
.
HostPathVolumeSource
{
Path
:
"/var/lib/certs/private"
,
Type
:
&
hostPathDirectoryOrCreate
,
},
},
},
},
...
...
@@ -163,7 +182,10 @@ func TestGetEtcdCertVolumes(t *testing.T) {
{
Name
:
"etcd-certs-0"
,
VolumeSource
:
v1
.
VolumeSource
{
HostPath
:
&
v1
.
HostPathVolumeSource
{
Path
:
"/etc/certs/etcd"
},
HostPath
:
&
v1
.
HostPathVolumeSource
{
Path
:
"/etc/certs/etcd"
,
Type
:
&
hostPathDirectoryOrCreate
,
},
},
},
},
...
...
@@ -184,7 +206,10 @@ func TestGetEtcdCertVolumes(t *testing.T) {
{
Name
:
"etcd-certs-0"
,
VolumeSource
:
v1
.
VolumeSource
{
HostPath
:
&
v1
.
HostPathVolumeSource
{
Path
:
"/etc/certs/etcd"
},
HostPath
:
&
v1
.
HostPathVolumeSource
{
Path
:
"/etc/certs/etcd"
,
Type
:
&
hostPathDirectoryOrCreate
,
},
},
},
},
...
...
@@ -222,6 +247,8 @@ func TestGetEtcdCertVolumes(t *testing.T) {
}
func
TestGetHostPathVolumesForTheControlPlane
(
t
*
testing
.
T
)
{
hostPathDirectoryOrCreate
:=
v1
.
HostPathDirectoryOrCreate
hostPathFileOrCreate
:=
v1
.
HostPathFileOrCreate
var
tests
=
[]
struct
{
cfg
*
kubeadmapi
.
MasterConfiguration
vol
map
[
string
][]
v1
.
Volume
...
...
@@ -238,13 +265,19 @@ func TestGetHostPathVolumesForTheControlPlane(t *testing.T) {
{
Name
:
"k8s-certs"
,
VolumeSource
:
v1
.
VolumeSource
{
HostPath
:
&
v1
.
HostPathVolumeSource
{
Path
:
testCertsDir
},
HostPath
:
&
v1
.
HostPathVolumeSource
{
Path
:
testCertsDir
,
Type
:
&
hostPathDirectoryOrCreate
,
},
},
},
{
Name
:
"ca-certs"
,
VolumeSource
:
v1
.
VolumeSource
{
HostPath
:
&
v1
.
HostPathVolumeSource
{
Path
:
"/etc/ssl/certs"
},
HostPath
:
&
v1
.
HostPathVolumeSource
{
Path
:
"/etc/ssl/certs"
,
Type
:
&
hostPathDirectoryOrCreate
,
},
},
},
},
...
...
@@ -252,19 +285,28 @@ func TestGetHostPathVolumesForTheControlPlane(t *testing.T) {
{
Name
:
"k8s-certs"
,
VolumeSource
:
v1
.
VolumeSource
{
HostPath
:
&
v1
.
HostPathVolumeSource
{
Path
:
testCertsDir
},
HostPath
:
&
v1
.
HostPathVolumeSource
{
Path
:
testCertsDir
,
Type
:
&
hostPathDirectoryOrCreate
,
},
},
},
{
Name
:
"ca-certs"
,
VolumeSource
:
v1
.
VolumeSource
{
HostPath
:
&
v1
.
HostPathVolumeSource
{
Path
:
"/etc/ssl/certs"
},
HostPath
:
&
v1
.
HostPathVolumeSource
{
Path
:
"/etc/ssl/certs"
,
Type
:
&
hostPathDirectoryOrCreate
,
},
},
},
{
Name
:
"kubeconfig"
,
VolumeSource
:
v1
.
VolumeSource
{
HostPath
:
&
v1
.
HostPathVolumeSource
{
Path
:
"/etc/kubernetes/controller-manager.conf"
},
HostPath
:
&
v1
.
HostPathVolumeSource
{
Path
:
"/etc/kubernetes/controller-manager.conf"
,
Type
:
&
hostPathFileOrCreate
,
},
},
},
},
...
...
@@ -272,7 +314,10 @@ func TestGetHostPathVolumesForTheControlPlane(t *testing.T) {
{
Name
:
"kubeconfig"
,
VolumeSource
:
v1
.
VolumeSource
{
HostPath
:
&
v1
.
HostPathVolumeSource
{
Path
:
"/etc/kubernetes/scheduler.conf"
},
HostPath
:
&
v1
.
HostPathVolumeSource
{
Path
:
"/etc/kubernetes/scheduler.conf"
,
Type
:
&
hostPathFileOrCreate
,
},
},
},
},
...
...
@@ -332,25 +377,37 @@ func TestGetHostPathVolumesForTheControlPlane(t *testing.T) {
{
Name
:
"k8s-certs"
,
VolumeSource
:
v1
.
VolumeSource
{
HostPath
:
&
v1
.
HostPathVolumeSource
{
Path
:
testCertsDir
},
HostPath
:
&
v1
.
HostPathVolumeSource
{
Path
:
testCertsDir
,
Type
:
&
hostPathDirectoryOrCreate
,
},
},
},
{
Name
:
"ca-certs"
,
VolumeSource
:
v1
.
VolumeSource
{
HostPath
:
&
v1
.
HostPathVolumeSource
{
Path
:
"/etc/ssl/certs"
},
HostPath
:
&
v1
.
HostPathVolumeSource
{
Path
:
"/etc/ssl/certs"
,
Type
:
&
hostPathDirectoryOrCreate
,
},
},
},
{
Name
:
"etcd-certs-0"
,
VolumeSource
:
v1
.
VolumeSource
{
HostPath
:
&
v1
.
HostPathVolumeSource
{
Path
:
"/etc/certs/etcd"
},
HostPath
:
&
v1
.
HostPathVolumeSource
{
Path
:
"/etc/certs/etcd"
,
Type
:
&
hostPathDirectoryOrCreate
,
},
},
},
{
Name
:
"etcd-certs-1"
,
VolumeSource
:
v1
.
VolumeSource
{
HostPath
:
&
v1
.
HostPathVolumeSource
{
Path
:
"/var/lib/certs/etcd"
},
HostPath
:
&
v1
.
HostPathVolumeSource
{
Path
:
"/var/lib/certs/etcd"
,
Type
:
&
hostPathDirectoryOrCreate
,
},
},
},
},
...
...
@@ -358,19 +415,28 @@ func TestGetHostPathVolumesForTheControlPlane(t *testing.T) {
{
Name
:
"k8s-certs"
,
VolumeSource
:
v1
.
VolumeSource
{
HostPath
:
&
v1
.
HostPathVolumeSource
{
Path
:
testCertsDir
},
HostPath
:
&
v1
.
HostPathVolumeSource
{
Path
:
testCertsDir
,
Type
:
&
hostPathDirectoryOrCreate
,
},
},
},
{
Name
:
"ca-certs"
,
VolumeSource
:
v1
.
VolumeSource
{
HostPath
:
&
v1
.
HostPathVolumeSource
{
Path
:
"/etc/ssl/certs"
},
HostPath
:
&
v1
.
HostPathVolumeSource
{
Path
:
"/etc/ssl/certs"
,
Type
:
&
hostPathDirectoryOrCreate
,
},
},
},
{
Name
:
"kubeconfig"
,
VolumeSource
:
v1
.
VolumeSource
{
HostPath
:
&
v1
.
HostPathVolumeSource
{
Path
:
"/etc/kubernetes/controller-manager.conf"
},
HostPath
:
&
v1
.
HostPathVolumeSource
{
Path
:
"/etc/kubernetes/controller-manager.conf"
,
Type
:
&
hostPathFileOrCreate
,
},
},
},
},
...
...
@@ -378,7 +444,10 @@ func TestGetHostPathVolumesForTheControlPlane(t *testing.T) {
{
Name
:
"kubeconfig"
,
VolumeSource
:
v1
.
VolumeSource
{
HostPath
:
&
v1
.
HostPathVolumeSource
{
Path
:
"/etc/kubernetes/scheduler.conf"
},
HostPath
:
&
v1
.
HostPathVolumeSource
{
Path
:
"/etc/kubernetes/scheduler.conf"
,
Type
:
&
hostPathFileOrCreate
,
},
},
},
},
...
...
cmd/kubeadm/app/phases/etcd/local.go
View file @
01e4b960
...
...
@@ -49,6 +49,7 @@ func CreateLocalEtcdStaticPodManifestFile(manifestDir string, cfg *kubeadmapi.Ma
// GetEtcdPodSpec returns the etcd static Pod actualized to the context of the current MasterConfiguration
// NB. GetEtcdPodSpec methods holds the information about how kubeadm creates etcd static pod mainfests.
func
GetEtcdPodSpec
(
cfg
*
kubeadmapi
.
MasterConfiguration
)
v1
.
Pod
{
pathType
:=
v1
.
HostPathDirectoryOrCreate
return
staticpodutil
.
ComponentPod
(
v1
.
Container
{
Name
:
kubeadmconstants
.
Etcd
,
Command
:
getEtcdCommand
(
cfg
),
...
...
@@ -56,7 +57,7 @@ func GetEtcdPodSpec(cfg *kubeadmapi.MasterConfiguration) v1.Pod {
// Mount the etcd datadir path read-write so etcd can store data in a more persistent manner
VolumeMounts
:
[]
v1
.
VolumeMount
{
staticpodutil
.
NewVolumeMount
(
etcdVolumeName
,
cfg
.
Etcd
.
DataDir
,
false
)},
LivenessProbe
:
staticpodutil
.
ComponentProbe
(
2379
,
"/health"
,
v1
.
URISchemeHTTP
),
},
[]
v1
.
Volume
{
staticpodutil
.
NewVolume
(
etcdVolumeName
,
cfg
.
Etcd
.
DataDir
)})
},
[]
v1
.
Volume
{
staticpodutil
.
NewVolume
(
etcdVolumeName
,
cfg
.
Etcd
.
DataDir
,
&
pathType
)})
}
// getEtcdCommand builds the right etcd command from the given config object
...
...
cmd/kubeadm/app/phases/selfhosting/podspec_mutation_test.go
View file @
01e4b960
...
...
@@ -186,6 +186,7 @@ func TestSetRightDNSPolicyOnPodSpec(t *testing.T) {
}
func
TestSetSelfHostedVolumesForAPIServer
(
t
*
testing
.
T
)
{
hostPathDirectoryOrCreate
:=
v1
.
HostPathDirectoryOrCreate
var
tests
=
[]
struct
{
podSpec
*
v1
.
PodSpec
expected
v1
.
PodSpec
...
...
@@ -215,6 +216,7 @@ func TestSetSelfHostedVolumesForAPIServer(t *testing.T) {
VolumeSource
:
v1
.
VolumeSource
{
HostPath
:
&
v1
.
HostPathVolumeSource
{
Path
:
"/etc/ssl/certs"
,
Type
:
&
hostPathDirectoryOrCreate
,
},
},
},
...
...
@@ -223,6 +225,7 @@ func TestSetSelfHostedVolumesForAPIServer(t *testing.T) {
VolumeSource
:
v1
.
VolumeSource
{
HostPath
:
&
v1
.
HostPathVolumeSource
{
Path
:
"/etc/kubernetes/pki"
,
Type
:
&
hostPathDirectoryOrCreate
,
},
},
},
...
...
@@ -252,6 +255,7 @@ func TestSetSelfHostedVolumesForAPIServer(t *testing.T) {
VolumeSource
:
v1
.
VolumeSource
{
HostPath
:
&
v1
.
HostPathVolumeSource
{
Path
:
"/etc/ssl/certs"
,
Type
:
&
hostPathDirectoryOrCreate
,
},
},
},
...
...
@@ -276,6 +280,8 @@ func TestSetSelfHostedVolumesForAPIServer(t *testing.T) {
}
func
TestSetSelfHostedVolumesForControllerManager
(
t
*
testing
.
T
)
{
hostPathFileOrCreate
:=
v1
.
HostPathFileOrCreate
hostPathDirectoryOrCreate
:=
v1
.
HostPathDirectoryOrCreate
var
tests
=
[]
struct
{
podSpec
*
v1
.
PodSpec
expected
v1
.
PodSpec
...
...
@@ -310,6 +316,7 @@ func TestSetSelfHostedVolumesForControllerManager(t *testing.T) {
VolumeSource
:
v1
.
VolumeSource
{
HostPath
:
&
v1
.
HostPathVolumeSource
{
Path
:
"/etc/ssl/certs"
,
Type
:
&
hostPathDirectoryOrCreate
,
},
},
},
...
...
@@ -318,6 +325,7 @@ func TestSetSelfHostedVolumesForControllerManager(t *testing.T) {
VolumeSource
:
v1
.
VolumeSource
{
HostPath
:
&
v1
.
HostPathVolumeSource
{
Path
:
"/etc/kubernetes/pki"
,
Type
:
&
hostPathDirectoryOrCreate
,
},
},
},
...
...
@@ -326,6 +334,7 @@ func TestSetSelfHostedVolumesForControllerManager(t *testing.T) {
VolumeSource
:
v1
.
VolumeSource
{
HostPath
:
&
v1
.
HostPathVolumeSource
{
Path
:
"/etc/kubernetes/controller-manager.conf"
,
Type
:
&
hostPathFileOrCreate
,
},
},
},
...
...
@@ -360,6 +369,7 @@ func TestSetSelfHostedVolumesForControllerManager(t *testing.T) {
VolumeSource
:
v1
.
VolumeSource
{
HostPath
:
&
v1
.
HostPathVolumeSource
{
Path
:
"/etc/ssl/certs"
,
Type
:
&
hostPathDirectoryOrCreate
,
},
},
},
...
...
@@ -388,6 +398,7 @@ func TestSetSelfHostedVolumesForControllerManager(t *testing.T) {
}
func
TestSetSelfHostedVolumesForScheduler
(
t
*
testing
.
T
)
{
hostPathFileOrCreate
:=
v1
.
HostPathFileOrCreate
var
tests
=
[]
struct
{
podSpec
*
v1
.
PodSpec
expected
v1
.
PodSpec
...
...
@@ -414,6 +425,7 @@ func TestSetSelfHostedVolumesForScheduler(t *testing.T) {
VolumeSource
:
v1
.
VolumeSource
{
HostPath
:
&
v1
.
HostPathVolumeSource
{
Path
:
"/etc/kubernetes/scheduler.conf"
,
Type
:
&
hostPathFileOrCreate
,
},
},
},
...
...
cmd/kubeadm/app/phases/selfhosting/selfhosting_test.go
View file @
01e4b960
...
...
@@ -249,6 +249,7 @@ spec:
name: ca-certs
- hostPath:
path: /etc/kubernetes/controller-manager.conf
type: FileOrCreate
name: kubeconfig
- hostPath:
path: /etc/pki
...
...
@@ -324,6 +325,7 @@ spec:
name: ca-certs
- hostPath:
path: /etc/kubernetes/controller-manager.conf
type: FileOrCreate
name: kubeconfig
- hostPath:
path: /etc/pki
...
...
@@ -374,6 +376,7 @@ spec:
volumes:
- hostPath:
path: /etc/kubernetes/scheduler.conf
type: FileOrCreate
name: kubeconfig
status: {}
`
...
...
@@ -425,6 +428,7 @@ spec:
volumes:
- hostPath:
path: /etc/kubernetes/scheduler.conf
type: FileOrCreate
name: kubeconfig
updateStrategy: {}
status:
...
...
cmd/kubeadm/app/util/staticpod/utils.go
View file @
01e4b960
...
...
@@ -82,11 +82,14 @@ func ComponentProbe(port int, path string, scheme v1.URIScheme) *v1.Probe {
}
// NewVolume creates a v1.Volume with a hostPath mount to the specified location
func
NewVolume
(
name
,
path
string
)
v1
.
Volume
{
func
NewVolume
(
name
,
path
string
,
pathType
*
v1
.
HostPathType
)
v1
.
Volume
{
return
v1
.
Volume
{
Name
:
name
,
VolumeSource
:
v1
.
VolumeSource
{
HostPath
:
&
v1
.
HostPathVolumeSource
{
Path
:
path
},
HostPath
:
&
v1
.
HostPathVolumeSource
{
Path
:
path
,
Type
:
pathType
,
},
},
}
}
...
...
cmd/kubeadm/app/util/staticpod/utils_test.go
View file @
01e4b960
...
...
@@ -123,10 +123,12 @@ func TestComponentPod(t *testing.T) {
}
func
TestNewVolume
(
t
*
testing
.
T
)
{
hostPathDirectoryOrCreate
:=
v1
.
HostPathDirectoryOrCreate
var
tests
=
[]
struct
{
name
string
path
string
expected
v1
.
Volume
pathType
*
v1
.
HostPathType
}{
{
name
:
"foo"
,
...
...
@@ -134,14 +136,18 @@ func TestNewVolume(t *testing.T) {
expected
:
v1
.
Volume
{
Name
:
"foo"
,
VolumeSource
:
v1
.
VolumeSource
{
HostPath
:
&
v1
.
HostPathVolumeSource
{
Path
:
"/etc/foo"
},
HostPath
:
&
v1
.
HostPathVolumeSource
{
Path
:
"/etc/foo"
,
Type
:
&
hostPathDirectoryOrCreate
,
},
},
},
pathType
:
&
hostPathDirectoryOrCreate
,
},
}
for
_
,
rt
:=
range
tests
{
actual
:=
NewVolume
(
rt
.
name
,
rt
.
path
)
actual
:=
NewVolume
(
rt
.
name
,
rt
.
path
,
rt
.
pathType
)
if
!
reflect
.
DeepEqual
(
actual
,
rt
.
expected
)
{
t
.
Errorf
(
"failed newVolume:
\n\t
expected: %v
\n\t
actual: %v"
,
...
...
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