Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
openmole
skuber-openmole
Commits
2850ce69
Commit
2850ce69
authored
Jun 12, 2019
by
mengxue
Browse files
change createTime in ListObjects
parent
f5774f3b
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/main/scala/skuberopenmole/ListObjects.scala
View file @
2850ce69
...
...
@@ -25,8 +25,9 @@ import scala.concurrent.duration._
object
ListObjects
extends
App
{
case
class
PodInfo
(
status
:
String
,
restarts
:
Int
,
start
Time
:
Timestamp
create
Time
:
Timestamp
)
private
def
listPods
(
pods
:
List
[
Pod
])
=
{
...
...
@@ -37,23 +38,19 @@ object ListObjects extends App{
pods
.
map
{
pod
:
Pod
=>
val
name
=
pod
.
name
val
ns
=
pod
.
namespace
val
phaseOpt
=
for
{
stat
<-
pod
.
status
status
<-
stat
.
phase
}
yield
status
val
status
=
phaseOpt
.
getOrElse
(
"Not set"
)
val
podInfo
=
(
for
{
status
<-
pod
.
status
.
toList
restarts
<-
status
.
containerStatuses
startTime
<-
status
.
startTime
stat
<-
pod
.
status
.
toList
status
<-
stat
.
phase
restarts
<-
stat
.
containerStatuses
.
headOption
createTime
<-
pod
.
metadata
.
creationTimestamp
}
yield
{
//st = status.containerStatuses.map {_.restartCount}
PodInfo
(
restarts
.
restartCount
,
start
Time
)
PodInfo
(
status
.
toString
,
restarts
.
restartCount
,
create
Time
)
}).
headOption
val
start
TimeString
=
new
SimpleDateFormat
(
"yyyy-MM-dd'T'HH:mm:ssX"
).
parse
(
podInfo
.
map
{
_
.
start
Time
}.
getOrElse
(
"None"
).
toString
())
val
create
TimeString
=
new
SimpleDateFormat
(
"yyyy-MM-dd'T'HH:mm:ssX"
).
parse
(
podInfo
.
map
{
_
.
create
Time
}.
getOrElse
(
"None"
).
toString
())
System
.
out
.
println
(
f
"${name}%-50s${ns}%-20s${
status
}%-20s${podInfo.map{_.restarts}.getOrElse("
None
")}%-20s${
start
TimeString}"
)
System
.
out
.
println
(
f
"${name}%-50s${ns}%-20s${
podInfo.map{_.status}.getOrElse("
None
")
}%-20s${podInfo.map{_.restarts}.getOrElse("
None
")}%-20s${
create
TimeString}"
)
}
}
...
...
@@ -64,7 +61,6 @@ object ListObjects extends App{
val
k8s
=
k8sInit
System
.
out
.
println
(
"\n======================================== kubectl get pods ========================================"
)
System
.
out
.
println
(
"\nGetting list of pods in namespace of current context ==>"
)
...
...
@@ -78,7 +74,6 @@ object ListObjects extends App{
}
Await
.
ready
(
printCurrNsPods
,
30
seconds
)
System
.
out
.
println
(
"\n============================= kubectl get pods --namespace=kube-system ============================"
)
System
.
out
.
println
(
"\nGetting lists of pods in 'kube-system' namespace ==>"
)
...
...
@@ -92,7 +87,6 @@ object ListObjects extends App{
}
Await
.
ready
(
printKSysPods
,
30
seconds
)
System
.
out
.
println
(
"\n================================= kubectl get pods --all-namespaces ================================"
)
System
.
out
.
println
(
"\nGetting lists of pods in all namespaces in the cluster ==>"
)
...
...
Write
Preview
Supports
Markdown
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