Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Task] VX-281: Report the pods which belong to deployment in getController #284

Merged
merged 1 commit into from
Aug 28, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 10 additions & 7 deletions API.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,11 @@
- [List Pods](#list-pods)
- [Get Pod](#get-pod)
- [Delete Pod](#delete-pod)
- [Deployment](#deploy)
- [Create Deployment](#create-deploy)
- [List Deployments](#list-deploys)
- [Get Deployment](#get-deploy)
- [Delete Deployment](#delete-deploy)
- [Deployment](#deployment)
- [Create Deployment](#create-deployment)
- [List Deployments](#list-deployments)
- [Get Deployment](#get-deployment)
- [Delete Deployment](#delete-deployment)
- [Resouce Monitoring](#resouce-monitoring)
- [List Nodes](#list-nodes)
- [Get Node](#get-node)
Expand Down Expand Up @@ -1433,12 +1433,15 @@ Response Data:
{
"controllerName": "prometheus",
"type": "deployment",
"namespace": "monitoring",
"namespace": "vortex",
"strategy": "",
"createAt": 1531211728,
"createAt": 1535031877,
"desiredPod": 1,
"currentPod": 1,
"availablePod": 1,
"pods": [
"prometheus-85bc764c94-kj4wg"
],
"labels": {
"name": "prometheus-deployment"
}
Expand Down
1 change: 1 addition & 0 deletions src/entity/metrics_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,6 @@ type ControllerMetrics struct {
DesiredPod int `json:"desiredPod"`
CurrentPod int `json:"currentPod"`
AvailablePod int `json:"availablePod"`
Pods []string `json:"pods"`
Labels map[string]string `json:"labels"`
}
16 changes: 16 additions & 0 deletions src/prometheuscontroller/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -596,6 +596,22 @@ func GetController(sp *serviceprovider.Container, id string) (entity.ControllerM
}
}

// pods
expression = Expression{}
expression.Metrics = []string{"kube_pod_info"}
expression.QueryLabels = map[string]string{"created_by_kind": "ReplicaSet", "created_by_name": id + ".*"}

str = basicExpr(expression.Metrics)
str = queryExpr(str, expression.QueryLabels)
results, err = query(sp, str)
if err != nil {
return controller, err
}

for _, result := range results {
controller.Pods = append(controller.Pods, string(result.Metric["pod"]))
}

return controller, nil
}

Expand Down