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
f8999a0e
Commit
f8999a0e
authored
Oct 19, 2016
by
Kubernetes Submit Queue
Committed by
GitHub
Oct 19, 2016
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #35141 from rootfs/rbd-secret2
Automatic merge from submit-queue remove pv annotation from rbd volume @kubernetes/sig-storage @jsafrane @childsb @eparis
parents
192e18e2
10b29de5
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
18 additions
and
39 deletions
+18
-39
rbd.go
pkg/volume/rbd/rbd.go
+18
-39
No files found.
pkg/volume/rbd/rbd.go
View file @
f8999a0e
...
@@ -49,11 +49,8 @@ var _ volume.DeletableVolumePlugin = &rbdPlugin{}
...
@@ -49,11 +49,8 @@ var _ volume.DeletableVolumePlugin = &rbdPlugin{}
var
_
volume
.
ProvisionableVolumePlugin
=
&
rbdPlugin
{}
var
_
volume
.
ProvisionableVolumePlugin
=
&
rbdPlugin
{}
const
(
const
(
rbdPluginName
=
"kubernetes.io/rbd"
rbdPluginName
=
"kubernetes.io/rbd"
annCephAdminID
=
"rbd.kubernetes.io/admin"
secretKeyName
=
"key"
// key name used in secret
annCephAdminSecretName
=
"rbd.kubernetes.io/adminsecretname"
annCephAdminSecretNameSpace
=
"rbd.kubernetes.io/adminsecretnamespace"
secretKeyName
=
"key"
// key name used in secret
)
)
func
(
plugin
*
rbdPlugin
)
Init
(
host
volume
.
VolumeHost
)
error
{
func
(
plugin
*
rbdPlugin
)
Init
(
host
volume
.
VolumeHost
)
error
{
...
@@ -183,9 +180,23 @@ func (plugin *rbdPlugin) NewDeleter(spec *volume.Spec) (volume.Deleter, error) {
...
@@ -183,9 +180,23 @@ func (plugin *rbdPlugin) NewDeleter(spec *volume.Spec) (volume.Deleter, error) {
if
spec
.
PersistentVolume
!=
nil
&&
spec
.
PersistentVolume
.
Spec
.
RBD
==
nil
{
if
spec
.
PersistentVolume
!=
nil
&&
spec
.
PersistentVolume
.
Spec
.
RBD
==
nil
{
return
nil
,
fmt
.
Errorf
(
"spec.PersistentVolumeSource.Spec.RBD is nil"
)
return
nil
,
fmt
.
Errorf
(
"spec.PersistentVolumeSource.Spec.RBD is nil"
)
}
}
admin
,
adminSecretName
,
adminSecretNamespace
,
err
:=
annotationsToParam
(
spec
.
PersistentVolume
)
class
,
err
:=
volutil
.
GetClassForVolume
(
plugin
.
host
.
GetKubeClient
(),
spec
.
PersistentVolume
)
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
fmt
.
Errorf
(
"cannot find Ceph credentials to delete rbd PV: %v"
,
err
)
return
nil
,
err
}
adminSecretName
:=
""
adminSecretNamespace
:=
"default"
admin
:=
""
for
k
,
v
:=
range
class
.
Parameters
{
switch
dstrings
.
ToLower
(
k
)
{
case
"adminid"
:
admin
=
v
case
"adminsecretname"
:
adminSecretName
=
v
case
"adminsecretnamespace"
:
adminSecretNamespace
=
v
}
}
}
secret
,
err
:=
parseSecret
(
adminSecretNamespace
,
adminSecretName
,
plugin
.
host
.
GetKubeClient
())
secret
,
err
:=
parseSecret
(
adminSecretNamespace
,
adminSecretName
,
plugin
.
host
.
GetKubeClient
())
...
@@ -313,8 +324,6 @@ func (r *rbdVolumeProvisioner) Provision() (*api.PersistentVolume, error) {
...
@@ -313,8 +324,6 @@ func (r *rbdVolumeProvisioner) Provision() (*api.PersistentVolume, error) {
pv
.
Spec
.
Capacity
=
api
.
ResourceList
{
pv
.
Spec
.
Capacity
=
api
.
ResourceList
{
api
.
ResourceName
(
api
.
ResourceStorage
)
:
resource
.
MustParse
(
fmt
.
Sprintf
(
"%dMi"
,
sizeMB
)),
api
.
ResourceName
(
api
.
ResourceStorage
)
:
resource
.
MustParse
(
fmt
.
Sprintf
(
"%dMi"
,
sizeMB
)),
}
}
// place parameters in pv selector
paramToAnnotations
(
r
.
adminId
,
adminSecretNamespace
,
adminSecretName
,
pv
)
return
pv
,
nil
return
pv
,
nil
}
}
...
@@ -331,36 +340,6 @@ func (r *rbdVolumeDeleter) Delete() error {
...
@@ -331,36 +340,6 @@ func (r *rbdVolumeDeleter) Delete() error {
return
r
.
manager
.
DeleteImage
(
r
)
return
r
.
manager
.
DeleteImage
(
r
)
}
}
func
paramToAnnotations
(
admin
,
adminSecretNamespace
,
adminSecretName
string
,
pv
*
api
.
PersistentVolume
)
{
if
pv
.
Annotations
==
nil
{
pv
.
Annotations
=
make
(
map
[
string
]
string
)
}
pv
.
Annotations
[
annCephAdminID
]
=
admin
pv
.
Annotations
[
annCephAdminSecretName
]
=
adminSecretName
pv
.
Annotations
[
annCephAdminSecretNameSpace
]
=
adminSecretNamespace
}
func
annotationsToParam
(
pv
*
api
.
PersistentVolume
)
(
string
,
string
,
string
,
error
)
{
if
pv
.
Annotations
==
nil
{
return
""
,
""
,
""
,
fmt
.
Errorf
(
"PV has no annotation, cannot get Ceph admin credentials"
)
}
var
admin
,
adminSecretName
,
adminSecretNamespace
string
found
:=
false
admin
,
found
=
pv
.
Annotations
[
annCephAdminID
]
if
!
found
{
return
""
,
""
,
""
,
fmt
.
Errorf
(
"Cannot get Ceph admin id from PV annotations"
)
}
adminSecretName
,
found
=
pv
.
Annotations
[
annCephAdminSecretName
]
if
!
found
{
return
""
,
""
,
""
,
fmt
.
Errorf
(
"Cannot get Ceph admin secret from PV annotations"
)
}
adminSecretNamespace
,
found
=
pv
.
Annotations
[
annCephAdminSecretNameSpace
]
if
!
found
{
return
""
,
""
,
""
,
fmt
.
Errorf
(
"Cannot get Ceph admin secret namespace from PV annotations"
)
}
return
admin
,
adminSecretName
,
adminSecretNamespace
,
nil
}
type
rbd
struct
{
type
rbd
struct
{
volName
string
volName
string
podUID
types
.
UID
podUID
types
.
UID
...
...
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