-
Notifications
You must be signed in to change notification settings - Fork 35
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
Updated summary with pod's parent information #733
Conversation
@@ -36,6 +37,7 @@ message Response{ | |||
repeated CiliumSummData IngressData = 11; | |||
repeated CiliumSummData EgressData = 12; | |||
repeated SysNwSummaryData BindConnection = 13; | |||
string DeployType = 14; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What does DeployType signify over here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't this be ResourceType?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
k8s uses the term resource owner for this.
@@ -36,6 +37,7 @@ message Response{ | |||
repeated CiliumSummData IngressData = 11; | |||
repeated CiliumSummData EgressData = 12; | |||
repeated SysNwSummaryData BindConnection = 13; | |||
string DeployType = 14; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't this be ResourceType?
@@ -20,6 +20,7 @@ message Request{ | |||
string Type = 6; | |||
bool Aggregate = 7; | |||
string DeployName = 8; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we name this as ResourceName?
src/types/constants.go
Outdated
K8sDeploymentType = "Deployment" | ||
K8sStatefulSetsType = "StatefulSet" | ||
K8sReplicaSetsType = "ReplicaSet" | ||
K8sDaemonSetsType = "DaemonSet" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we also need to add for jobs?
87eb5ba
to
67effbc
Compare
@rajaSahil I've updated the code based on your comment. Can you please review again? |
src/cluster/k8sClientHandler.go
Outdated
// == DaemonSets == // | ||
// ================= // | ||
|
||
func GetDaemonSetsFromK8sClient() []types.Deployment { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we create a single function and then pass the k8s objects as argument? like GetObjectSetsFromK8sClient(object), then pass daemonset/deployment etc. as a value to it. It will greatly reduce the code size
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Addressed @Ankurk99
67effbc
to
83c0441
Compare
for _, rs := range replicaSets.Items { | ||
results = append(results, GenerateResourceList(rs.OwnerReferences,rs.Name,rs.Namespace,types.K8sReplicaSetsType,rs.Spec.Selector.MatchLabels)...) | ||
} | ||
case types.K8sJobsType: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we also need to consider cronjobs? Although it creates new jobs periodically.
@@ -119,6 +119,7 @@ recommend: | |||
operation-mode: 1 # 1: cronjob | 2: one-time-job | |||
cron-job-time-interval: "1h0m00s" # format: XhYmZs | |||
recommend-host-policy: true | |||
admission-controller-policy: false |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why this change?
src/libs/dbHandler.go
Outdated
@@ -433,7 +433,7 @@ func upsertSysSummarySQL(db *sql.DB, summary types.SystemSummary, timeCount type | |||
summary.Labels = strings.Join(sortedLabels, ",") | |||
|
|||
queryString := `cluster_name = ? and cluster_id = ? and workspace_id = ? and namespace_name = ? and namespace_id = ? and container_name = ? and container_image = ? | |||
and podname = ? and operation = ? and labels = ? and deployment_name = ? and source = ? and destination = ? | |||
and podname = ? and operation = ? and labels = ? and parent_name = ? and parent_type = ? and source = ? and destination = ? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we name table columns as resource_type and resource_name?
src/libs/sqliteHandler.go
Outdated
" `parent_name` varchar(50) DEFAULT NULL," + | ||
" `parent_type` varchar(50) DEFAULT NULL," + |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
resource_type and resource_name ?
src/libs/sqliteHandler.go
Outdated
db := connectSQLite(cfg, config.GetCfgObservabilityDBName()) | ||
defer db.Close() | ||
|
||
resDeployNames := []string{} | ||
resDeployNames := map[string]string{} | ||
|
||
var results *sql.Rows | ||
var err error | ||
|
||
// Get podnames from system table |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// Get podnames from system table | |
// Get resource type and resource names from system table. |
var locDeployName, locDeployType string | ||
if err := results.Scan( | ||
&locDeployName, | ||
&locDeployType, | ||
); err != nil { | ||
return nil, err | ||
} | ||
resDeployNames = append(resDeployNames, locDeployName) | ||
resDeployNames[locDeployName] = locDeployType |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There can be possibility of having same resource names in different namespace, so when getting all the entries from table, are we handling this case?
src/observability/summarizer.go
Outdated
} | ||
} | ||
if sysSummary.Deployment == "" { | ||
sysSummary.Workload.Type = "Pod" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it correct to consider pod as a workload type?
- Updated summary information to include pod's parent_name and parent_type - Updated functions to retrieve daemonset details - Updated constants with deployment, replicaset, statefulset, daemonset and jobs values - Updated protobuf definitions to include parent_name and parent_type to pod information Signed-off-by: Vishnu Soman <[email protected]>
83c0441
to
e586e08
Compare
Currently putting this on hold as we are handling summary through different CLI tool |
Fixes: #731
Related PRs --> kubearmor/kubearmor-client#299
This PR contains the following changes:
Please refer 299#issuecomment-1561132322 for the updated output