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

Linode lke #818 #904

Merged
merged 26 commits into from
Sep 15, 2023
Merged
Show file tree
Hide file tree
Changes from 17 commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
129ceb7
Create lke_pools.go
professorabhay Jul 23, 2023
83da841
Update linode.go
professorabhay Jul 23, 2023
bf38dd5
Update lke_pools.go
professorabhay Jul 23, 2023
d04397d
Update lke_pools.go
professorabhay Jul 23, 2023
bcba7b0
Update lke_pools.go
professorabhay Jul 23, 2023
96acc28
Update lke_pools.go
professorabhay Jul 23, 2023
6b7b435
Update lke_pools.go
professorabhay Jul 23, 2023
285ab79
Delete providers/linode/linode-lke directory
professorabhay Jul 23, 2023
5f0b29a
Create lke_pool.go
professorabhay Jul 23, 2023
55675e0
Update linode.go
professorabhay Jul 23, 2023
fce9946
Update lke_pool.go strings added
professorabhay Jul 23, 2023
cb984e2
Update lke_pool.go
professorabhay Jul 23, 2023
0469f94
Update lke_pool.go
professorabhay Jul 23, 2023
4833038
Update lke_pool.go
professorabhay Jul 23, 2023
a8fbe8a
Update lke_pool.go
professorabhay Jul 23, 2023
2bca019
Merge pull request #13 from professorabhay/linode-lke
professorabhay Jul 24, 2023
83d8e17
Merge branch 'develop' into LINODE_LKE
professorabhay Jul 25, 2023
0fa0e83
Merge branch 'tailwarden:develop' into LINODE_LKE
professorabhay Jul 27, 2023
dd75aca
Update lke_pool.go
professorabhay Jul 27, 2023
24948b1
Update lke_pool.go
professorabhay Jul 27, 2023
5944939
Update lke_pool.go
professorabhay Jul 27, 2023
4bb79fa
Update lke_pool.go
professorabhay Jul 27, 2023
77f0669
Update lke_pool.go
professorabhay Jul 27, 2023
3a3d4e7
Merge branch 'develop' into LINODE_LKE
ShubhamPalriwala Aug 26, 2023
fbf1438
Update lke_pool.go
professorabhay Aug 26, 2023
f9b57f1
Merge branch 'develop' into LINODE_LKE
mlabouardy Sep 15, 2023
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
2 changes: 2 additions & 0 deletions providers/linode/linode.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import (
"github.com/tailwarden/komiser/providers/linode/sql"
"github.com/tailwarden/komiser/providers/linode/postgres"
"github.com/tailwarden/komiser/providers/linode/storage"
"github.com/tailwarden/komiser/providers/linode/lkepool"
"github.com/uptrace/bun"
)

Expand All @@ -27,6 +28,7 @@ func listOfSupportedServices() []providers.FetchDataFunction {
networking.Firewalls,
sql.Instances,
postgres.Instances,
lkepool.LKENodePools,
}
}

Expand Down
75 changes: 75 additions & 0 deletions providers/linode/lkepool/lke_pool.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
package lkepool

import (
"context"
"fmt"
"strings"
"time"

"github.com/linode/linodego"
log "github.com/sirupsen/logrus"

"github.com/tailwarden/komiser/models"
"github.com/tailwarden/komiser/providers"
)

type LinodeLKENodePool struct {
NodePool *linodego.LKECluster `json:"node_pool"`
}

func LKENodePools(ctx context.Context, client providers.ProviderClient) ([]models.Resource, error) {
resources := make([]models.Resource, 0)


lkeClusters, err := client.LinodeClient.ListLKEClusters(ctx, &linodego.ListOptions{})
if err != nil {
return resources, err
}

for _, lkeCluster := range lkeClusters {
nodePools, err := client.LinodeClient.ListLKENodePools(ctx, lkeCluster.ID, &linodego.ListOptions{})
if err != nil {
return resources, err
}
for _, nodePool := range nodePools {
tags := make([]models.Tag, 0)
for _, tag := range nodePool.Tags {
if strings.Contains(tag, ":") {
parts := strings.Split(tag, ":")
tags = append(tags, models.Tag{
Key: parts[0],
Value: parts[1],
})
} else {
tags = append(tags, models.Tag{
Key: tag,
Value: tag,
})
}
}

resources = append(resources, models.Resource{
Provider: "Linode",
Account: client.Name,
Service: "Linode Kubernetes Engine",
// Region: nodePool.Region,
professorabhay marked this conversation as resolved.
Show resolved Hide resolved
ResourceId: fmt.Sprintf("%d", nodePool.ID),
Cost: 0,
// Name: nodePool.Label,
FetchedAt: time.Now(),
CreatedAt: time.Time{}, // Update this with the actual created time.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we fix this please if possible?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried but not find the way to do so. Because every time I try to fetch then its give error of not defined in linodego library

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Then can we have some other identifier if possible as a name? or if you could fetch the name in some other way and parse it? because ideally we should not not have a name. Let me know if you need my hand on this!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, I'll let you know

Tags: tags,
Link: fmt.Sprintf("https://cloud.linode.com/kubernetes/clusters/%d", nodePool.ID),
// Add any additional fields or data you want to collect here.
professorabhay marked this conversation as resolved.
Show resolved Hide resolved
})
}
}

log.WithFields(log.Fields{
"provider": "Linode",
"account": client.Name,
"service": "Linode Kubernetes Engine",
"resources": len(resources),
}).Info("Fetched LKE node pools")
return resources, nil
}