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
bf306d65
Commit
bf306d65
authored
Aug 20, 2015
by
Wojciech Tyczynski
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #12622 from JanetKuo/kubectl-describe-rc-pod-volume
Describe volumes in rc and pod
parents
44fa48e5
bff0cab7
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
127 additions
and
0 deletions
+127
-0
describe.go
pkg/kubectl/describe.go
+127
-0
No files found.
pkg/kubectl/describe.go
View file @
bf306d65
...
@@ -432,6 +432,7 @@ func describePod(pod *api.Pod, rcs []api.ReplicationController, events *api.Even
...
@@ -432,6 +432,7 @@ func describePod(pod *api.Pod, rcs []api.ReplicationController, events *api.Even
c
.
Status
)
c
.
Status
)
}
}
}
}
describeVolumes
(
pod
.
Spec
.
Volumes
,
out
)
if
events
!=
nil
{
if
events
!=
nil
{
DescribeEvents
(
events
,
out
)
DescribeEvents
(
events
,
out
)
}
}
...
@@ -439,6 +440,129 @@ func describePod(pod *api.Pod, rcs []api.ReplicationController, events *api.Even
...
@@ -439,6 +440,129 @@ func describePod(pod *api.Pod, rcs []api.ReplicationController, events *api.Even
})
})
}
}
func
describeVolumes
(
volumes
[]
api
.
Volume
,
out
io
.
Writer
)
{
if
volumes
==
nil
||
len
(
volumes
)
==
0
{
fmt
.
Fprint
(
out
,
"No volumes.
\n
"
)
return
}
fmt
.
Fprint
(
out
,
"Volumes:
\n
"
)
for
_
,
volume
:=
range
volumes
{
fmt
.
Fprintf
(
out
,
" %v:
\n
"
,
volume
.
Name
)
switch
{
case
volume
.
VolumeSource
.
HostPath
!=
nil
:
printHostPathVolumeSource
(
volume
.
VolumeSource
.
HostPath
,
out
)
case
volume
.
VolumeSource
.
EmptyDir
!=
nil
:
printEmptyDirVolumeSource
(
volume
.
VolumeSource
.
EmptyDir
,
out
)
case
volume
.
VolumeSource
.
GCEPersistentDisk
!=
nil
:
printGCEPersistentDiskVolumeSource
(
volume
.
VolumeSource
.
GCEPersistentDisk
,
out
)
case
volume
.
VolumeSource
.
AWSElasticBlockStore
!=
nil
:
printAWSElasticBlockStoreVolumeSource
(
volume
.
VolumeSource
.
AWSElasticBlockStore
,
out
)
case
volume
.
VolumeSource
.
GitRepo
!=
nil
:
printGitRepoVolumeSource
(
volume
.
VolumeSource
.
GitRepo
,
out
)
case
volume
.
VolumeSource
.
Secret
!=
nil
:
printSecretVolumeSource
(
volume
.
VolumeSource
.
Secret
,
out
)
case
volume
.
VolumeSource
.
NFS
!=
nil
:
printNFSVolumeSource
(
volume
.
VolumeSource
.
NFS
,
out
)
case
volume
.
VolumeSource
.
ISCSI
!=
nil
:
printISCSIVolumeSource
(
volume
.
VolumeSource
.
ISCSI
,
out
)
case
volume
.
VolumeSource
.
Glusterfs
!=
nil
:
printGlusterfsVolumeSource
(
volume
.
VolumeSource
.
Glusterfs
,
out
)
case
volume
.
VolumeSource
.
PersistentVolumeClaim
!=
nil
:
printPersistentVolumeClaimVolumeSource
(
volume
.
VolumeSource
.
PersistentVolumeClaim
,
out
)
case
volume
.
VolumeSource
.
RBD
!=
nil
:
printRBDVolumeSource
(
volume
.
VolumeSource
.
RBD
,
out
)
default
:
fmt
.
Fprintf
(
out
,
" <Volume Type Not Found>
\n
"
)
}
}
}
func
printHostPathVolumeSource
(
hostPath
*
api
.
HostPathVolumeSource
,
out
io
.
Writer
)
{
fmt
.
Fprintf
(
out
,
" Type:
\t
HostPath (bare host directory volume)
\n
"
+
" Path:
\t
%v
\n
"
,
hostPath
.
Path
)
}
func
printEmptyDirVolumeSource
(
emptyDir
*
api
.
EmptyDirVolumeSource
,
out
io
.
Writer
)
{
fmt
.
Fprintf
(
out
,
" Type:
\t
EmptyDir (a temporary directory that shares a pod's lifetime)
\n
"
+
" Medium:
\t
%v
\n
"
,
emptyDir
.
Medium
)
}
func
printGCEPersistentDiskVolumeSource
(
gce
*
api
.
GCEPersistentDiskVolumeSource
,
out
io
.
Writer
)
{
fmt
.
Fprintf
(
out
,
" Type:
\t
GCEPersistentDisk (a Persistent Disk resource in Google Compute Engine)
\n
"
+
" PDName:
\t
%v
\n
"
+
" FSType:
\t
%v
\n
"
+
" Partition:
\t
%v
\n
"
+
" ReadOnly:
\t
%v
\n
"
,
gce
.
PDName
,
gce
.
FSType
,
gce
.
Partition
,
gce
.
ReadOnly
)
}
func
printAWSElasticBlockStoreVolumeSource
(
aws
*
api
.
AWSElasticBlockStoreVolumeSource
,
out
io
.
Writer
)
{
fmt
.
Fprintf
(
out
,
" Type:
\t
AWSElasticBlockStore (a Persistent Disk resource in AWS)
\n
"
+
" VolumeID:
\t
%v
\n
"
+
" FSType:
\t
%v
\n
"
+
" Partition:
\t
%v
\n
"
+
" ReadOnly:
\t
%v
\n
"
,
aws
.
VolumeID
,
aws
.
FSType
,
aws
.
Partition
,
aws
.
ReadOnly
)
}
func
printGitRepoVolumeSource
(
git
*
api
.
GitRepoVolumeSource
,
out
io
.
Writer
)
{
fmt
.
Fprintf
(
out
,
" Type:
\t
GitRepo (a volume that is pulled from git when the pod is created)
\n
"
+
" Repository:
\t
%v
\n
"
+
" Revision:
\t
%v
\n
"
,
git
.
Repository
,
git
.
Revision
)
}
func
printSecretVolumeSource
(
secret
*
api
.
SecretVolumeSource
,
out
io
.
Writer
)
{
fmt
.
Fprintf
(
out
,
" Type:
\t
Secret (a secret that should populate this volume)
\n
"
+
" SecretName:
\t
%v
\n
"
,
secret
.
SecretName
)
}
func
printNFSVolumeSource
(
nfs
*
api
.
NFSVolumeSource
,
out
io
.
Writer
)
{
fmt
.
Fprintf
(
out
,
" Type:
\t
NFS (an NFS mount that lasts the lifetime of a pod)
\n
"
+
" Server:
\t
%v
\n
"
+
" Path:
\t
%v
\n
"
+
" ReadOnly:
\t
%v
\n
"
,
nfs
.
Server
,
nfs
.
Path
,
nfs
.
ReadOnly
)
}
func
printISCSIVolumeSource
(
iscsi
*
api
.
ISCSIVolumeSource
,
out
io
.
Writer
)
{
fmt
.
Fprintf
(
out
,
" Type:
\t
ISCSI (an ISCSI Disk resource that is attached to a kubelet's host machine and then exposed to the pod)
\n
"
+
" TargetPortal:
\t
%v
\n
"
+
" IQN:
\t
%v
\n
"
+
" Lun:
\t
%v
\n
"
+
" FSType:
\t
%v
\n
"
+
" ReadOnly:
\t
%v
\n
"
,
iscsi
.
TargetPortal
,
iscsi
.
IQN
,
iscsi
.
Lun
,
iscsi
.
FSType
,
iscsi
.
ReadOnly
)
}
func
printGlusterfsVolumeSource
(
glusterfs
*
api
.
GlusterfsVolumeSource
,
out
io
.
Writer
)
{
fmt
.
Fprintf
(
out
,
" Type:
\t
Glusterfs (a Glusterfs mount on the host that shares a pod's lifetime)
\n
"
+
" EndpointsName:
\t
%v
\n
"
+
" Path:
\t
%v
\n
"
+
" ReadOnly:
\t
%v
\n
"
,
glusterfs
.
EndpointsName
,
glusterfs
.
Path
,
glusterfs
.
ReadOnly
)
}
func
printPersistentVolumeClaimVolumeSource
(
claim
*
api
.
PersistentVolumeClaimVolumeSource
,
out
io
.
Writer
)
{
fmt
.
Fprintf
(
out
,
" Type:
\t
PersistentVolumeClaim (a reference to a PersistentVolumeClaim in the same namespace)
\n
"
+
" ClaimName:
\t
%v
\n
"
+
" ReadOnly:
\t
%v
\n
"
,
claim
.
ClaimName
,
claim
.
ReadOnly
)
}
func
printRBDVolumeSource
(
rbd
*
api
.
RBDVolumeSource
,
out
io
.
Writer
)
{
fmt
.
Fprintf
(
out
,
" Type:
\t
RBD (a Rados Block Device mount on the host that shares a pod's lifetime)
\n
"
+
" CephMonitors:
\t
%v
\n
"
+
" RBDImage:
\t
%v
\n
"
+
" FSType:
\t
%v
\n
"
+
" RBDPool:
\t
%v
\n
"
+
" RadosUser:
\t
%v
\n
"
+
" Keyring:
\t
%v
\n
"
+
" SecretRef:
\t
%v
\n
"
+
" ReadOnly:
\t
%v
\n
"
,
rbd
.
CephMonitors
,
rbd
.
RBDImage
,
rbd
.
FSType
,
rbd
.
RBDPool
,
rbd
.
RadosUser
,
rbd
.
Keyring
,
rbd
.
SecretRef
,
rbd
.
ReadOnly
)
}
type
PersistentVolumeDescriber
struct
{
type
PersistentVolumeDescriber
struct
{
client
.
Interface
client
.
Interface
}
}
...
@@ -631,6 +755,9 @@ func describeReplicationController(controller *api.ReplicationController, events
...
@@ -631,6 +755,9 @@ func describeReplicationController(controller *api.ReplicationController, events
fmt
.
Fprintf
(
out
,
"Labels:
\t
%s
\n
"
,
formatLabels
(
controller
.
Labels
))
fmt
.
Fprintf
(
out
,
"Labels:
\t
%s
\n
"
,
formatLabels
(
controller
.
Labels
))
fmt
.
Fprintf
(
out
,
"Replicas:
\t
%d current / %d desired
\n
"
,
controller
.
Status
.
Replicas
,
controller
.
Spec
.
Replicas
)
fmt
.
Fprintf
(
out
,
"Replicas:
\t
%d current / %d desired
\n
"
,
controller
.
Status
.
Replicas
,
controller
.
Spec
.
Replicas
)
fmt
.
Fprintf
(
out
,
"Pods Status:
\t
%d Running / %d Waiting / %d Succeeded / %d Failed
\n
"
,
running
,
waiting
,
succeeded
,
failed
)
fmt
.
Fprintf
(
out
,
"Pods Status:
\t
%d Running / %d Waiting / %d Succeeded / %d Failed
\n
"
,
running
,
waiting
,
succeeded
,
failed
)
if
controller
.
Spec
.
Template
!=
nil
{
describeVolumes
(
controller
.
Spec
.
Template
.
Spec
.
Volumes
,
out
)
}
if
events
!=
nil
{
if
events
!=
nil
{
DescribeEvents
(
events
,
out
)
DescribeEvents
(
events
,
out
)
}
}
...
...
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