Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
H
holmes
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
QA
holmes
Commits
cde64549
Commit
cde64549
authored
Aug 23, 2021
by
黎博
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
获取pod列表新增Pending状态判断
parent
1eaee48b
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
3 deletions
+8
-3
K8sService.java
src/main/java/cn/qg/holmes/service/k8s/K8sService.java
+8
-3
No files found.
src/main/java/cn/qg/holmes/service/k8s/K8sService.java
View file @
cde64549
...
@@ -141,7 +141,7 @@ public class K8sService {
...
@@ -141,7 +141,7 @@ public class K8sService {
List
<
Pod
>
podList
=
kubernetesClient
.
pods
().
inNamespace
(
namespace
).
list
().
getItems
();
List
<
Pod
>
podList
=
kubernetesClient
.
pods
().
inNamespace
(
namespace
).
list
().
getItems
();
List
<
Map
<
String
,
Object
>>
result
=
new
ArrayList
<>();
List
<
Map
<
String
,
Object
>>
result
=
new
ArrayList
<>();
for
(
Pod
pod
:
podList
)
{
for
(
Pod
pod
:
podList
)
{
if
(
pod
.
getStatus
().
getPhase
().
equals
(
"Running"
))
{
if
(
pod
.
getStatus
().
getPhase
().
equals
(
"Running"
)
||
pod
.
getStatus
().
getPhase
().
equals
(
"Pending"
)
)
{
Map
<
String
,
Object
>
map
=
new
HashMap
<>();
Map
<
String
,
Object
>
map
=
new
HashMap
<>();
// 端口映射
// 端口映射
List
<
Map
<
String
,
Object
>>
portMappingList
=
new
ArrayList
<>();
List
<
Map
<
String
,
Object
>>
portMappingList
=
new
ArrayList
<>();
...
@@ -1971,8 +1971,13 @@ public class K8sService {
...
@@ -1971,8 +1971,13 @@ public class K8sService {
}
}
public
void
podTest
()
{
public
void
podTest
()
{
Pod
pod
=
kubernetesClient
.
pods
().
inNamespace
(
"k8s"
).
withName
(
"notify-56fc55776b-5qshb"
).
get
();
List
<
Pod
>
podList
=
kubernetesClient
.
pods
().
inNamespace
(
"k8s"
).
list
().
getItems
();
System
.
out
.
println
(
JSON
.
toJSONString
(
pod
.
getStatus
().
getContainerStatuses
().
get
(
0
)));
for
(
Pod
pod:
podList
)
{
System
.
out
.
println
(
pod
.
getMetadata
().
getName
());
System
.
out
.
println
(
pod
.
getMetadata
());
System
.
out
.
println
(
JSON
.
toJSON
(
pod
.
getSpec
()));
System
.
out
.
println
(
JSON
.
toJSON
(
pod
.
getStatus
()));
}
}
}
public
static
void
main
(
String
[]
args
)
{
public
static
void
main
(
String
[]
args
)
{
...
...
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