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
2bec8ad8
Commit
2bec8ad8
authored
Nov 01, 2021
by
黎博
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' into pipline
parents
5662bc7c
6e68f512
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
3 deletions
+11
-3
K8sService.java
src/main/java/cn/qg/holmes/service/k8s/K8sService.java
+11
-3
No files found.
src/main/java/cn/qg/holmes/service/k8s/K8sService.java
View file @
2bec8ad8
...
...
@@ -2102,7 +2102,14 @@ public class K8sService {
labelMap
.
put
(
"type"
,
serviceType
);
labelMap
.
put
(
"qcloud-app"
,
serviceName
);
labelSelector
.
setMatchLabels
(
labelMap
);
return
kubernetesClient
.
pods
().
inNamespace
(
namespace
).
withLabelSelector
(
labelSelector
).
list
().
getItems
().
get
(
0
);
List
<
Pod
>
podList
=
kubernetesClient
.
pods
().
inNamespace
(
namespace
).
withLabelSelector
(
labelSelector
).
list
().
getItems
();
for
(
Pod
pod:
podList
)
{
// pod可能有多个,返回Running状态的pod
if
(
pod
.
getStatus
().
getPhase
().
equals
(
"Running"
))
{
return
pod
;
}
}
return
null
;
}
/**
...
...
@@ -2116,7 +2123,7 @@ public class K8sService {
Service
service
=
getServiceDetail
(
namespace
,
serviceName
);
Pod
pod
=
getPodDetail
(
namespace
,
serviceType
,
serviceName
);
Map
<
String
,
Object
>
map
=
new
HashMap
<>();
if
(
pod
.
getStatus
().
getPhase
().
equals
(
"Running"
))
{
if
(
pod
!=
null
&&
pod
.
getStatus
().
getPhase
().
equals
(
"Running"
))
{
// 端口映射
List
<
Map
<
String
,
Object
>>
portMappingList
=
new
ArrayList
<>();
ObjectMeta
podMetadata
=
pod
.
getMetadata
();
...
...
@@ -2378,7 +2385,8 @@ public class K8sService {
public
static
void
main
(
String
[]
args
)
{
K8sService
k8sService
=
new
K8sService
();
// k8sService.createNewNamespace("test6", "dev", "黎博");
k8sService
.
podTest
();
// k8sService.podTest();
System
.
out
.
println
(
k8sService
.
getPodAndServiceInfo
(
"vcc2"
,
"java"
,
"vcc-quota-service"
));
// k8sService.getPodList("k8s");
// System.out.println(JSON.toJSONString(k8sService.getPodListNew("fe")));
// if (!k8sService.queryIfServiceExistByName("fe", "lxq-ui")) {
...
...
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