-
Notifications
You must be signed in to change notification settings - Fork 58
Create guide explaining how to connect OpenCost with AWS and Argo CD K8 resource #1397
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
Closed
Closed
Changes from 2 commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
c5ba8b2
Implement guide for opencost and argocd
lordsarcastic 36d2339
Fixed failing builds
lordsarcastic 53a0452
Updated integrations index
lordsarcastic cb8c2ba
Made comment fixes on PR
lordsarcastic fb5de63
Merge remote-tracking branch 'origin/main' into port-7910
lordsarcastic bcbf8d9
Merge remote-tracking branch 'origin/main' into port-7910
lordsarcastic ba23408
Fix comments on opencost prs
lordsarcastic c034975
Add missing image
lordsarcastic c1c09c9
Merge remote-tracking branch 'origin/main' into port-7910
lordsarcastic 4d7b12e
Merge branch 'main' into port-7910
PeyGis e8dfac5
Merge remote-tracking branch 'origin/main' into port-7910
lordsarcastic 9ae2a74
Merge remote-tracking branch 'origin/main' into port-7910
lordsarcastic File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
4 changes: 4 additions & 0 deletions
4
docs/build-your-software-catalog/sync-data-to-catalog/argocd/guides/_category_.json
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"label": "Guides", | ||
"position": 1 | ||
} | ||
247 changes: 247 additions & 0 deletions
247
...to-catalog/argocd/guides/connect-opencost-resource-with-argocd-k8s-resources.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,247 @@ | ||
--- | ||
sidebar_position: 1 | ||
title: Connect Opencost cloudcost with ArgoCD/K8 resource | ||
--- | ||
|
||
import PortTooltip from "/src/components/tooltip/tooltip.jsx" | ||
|
||
# Connect Opencost `cloudcost` with AWS Resource | ||
lordsarcastic marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
This guide aims to cover how to connect an Opencost Resource Allocations resource with an ArgoCD K8 resource to draw cost analysis. | ||
lordsarcastic marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
lordsarcastic marked this conversation as resolved.
Show resolved
Hide resolved
|
||
:::tip Prerequisites | ||
lordsarcastic marked this conversation as resolved.
Show resolved
Hide resolved
|
||
- This guide assumes you have a Port account and that you have finished the [onboarding process](/quickstart). | ||
- Ensure you have [Port's Opencost integration installed and configured in your environment](https://docs.getport.io/build-your-software-catalog/sync-data-to-catalog/cloud-cost/opencost). | ||
- Ensure you have [Port's Opencost integration installed and configured in your environment](https://docs.getport.io/build-your-software-catalog/sync-data-to-catalog/cloud-cost/opencost). | ||
lordsarcastic marked this conversation as resolved.
Show resolved
Hide resolved
|
||
::: | ||
|
||
## Create the ArgoCD K8 relation | ||
|
||
With Opencost and ArgoCD installed, you should see: | ||
- Two (2) new blueprints created by the Opencost integration, "Opencost Resource Allocations" and `Opencost Cloudcost` | ||
lordsarcastic marked this conversation as resolved.
Show resolved
Hide resolved
|
||
- Six (6) new blueprints created by the ArgoCD integration, `ArgoCD Cluster`, `ArgoCD Project`, `Running Service`, `ArgoCD Deployment History`, `Kubernetes Resource` and `ArgoCD Namespace`. | ||
|
||
If the blueprints aren't created: | ||
lordsarcastic marked this conversation as resolved.
Show resolved
Hide resolved
|
||
- Navigate to your Port organization's data model page on the builder. | ||
lordsarcastic marked this conversation as resolved.
Show resolved
Hide resolved
|
||
- Click the + Blueprint button at the top right corner. | ||
lordsarcastic marked this conversation as resolved.
Show resolved
Hide resolved
|
||
- Click the Edit JSON button. | ||
lordsarcastic marked this conversation as resolved.
Show resolved
Hide resolved
|
||
- Copy-paste the blueprint JSON: | ||
|
||
:::info Important Blueprints | ||
The `Opencost Resource Allocations` and `Kubernetes Resource` are the only blueprints of interest here. | ||
|
||
::: | ||
|
||
|
||
<details> | ||
<summary><b>Opencost Resource Allocations (Click to expand)</b></summary> | ||
|
||
```json showLineNumbers | ||
{ | ||
"identifier": "openCostResourceAllocation", | ||
"description": "This blueprint represents an OpenCost resource allocation in our software catalog", | ||
"title": "OpenCost Resource Allocation", | ||
"icon": "Cluster", | ||
"schema": { | ||
"properties": { | ||
"cluster": { | ||
"type": "string", | ||
"title": "Cluster" | ||
}, | ||
"namespace": { | ||
"type": "string", | ||
"title": "Namespace" | ||
}, | ||
"startDate": { | ||
"title": "Start Date", | ||
"type": "string", | ||
"format": "date-time" | ||
}, | ||
"endDate": { | ||
"title": "End Date", | ||
"type": "string", | ||
"format": "date-time" | ||
}, | ||
"cpuCoreHours": { | ||
"title": "CPU Core Hours", | ||
"type": "number" | ||
}, | ||
"cpuCost": { | ||
"title": "CPU Cost", | ||
"type": "number" | ||
}, | ||
"cpuEfficiency": { | ||
"title": "CPU Efficiency", | ||
"type": "number" | ||
}, | ||
"gpuHours": { | ||
"title": "GPU Hours", | ||
"type": "number" | ||
}, | ||
"gpuCost": { | ||
"title": "GPU Cost", | ||
"type": "number" | ||
}, | ||
"networkCost": { | ||
"title": "Network Cost", | ||
"type": "number" | ||
}, | ||
"loadBalancerCost": { | ||
"title": "Load Balancer Cost", | ||
"type": "number" | ||
}, | ||
"pvCost": { | ||
"title": "PV Cost", | ||
"type": "number" | ||
}, | ||
"ramBytes": { | ||
"title": "RAM Bytes", | ||
"type": "number" | ||
}, | ||
"ramCost": { | ||
"title": "RAM Cost", | ||
"type": "number" | ||
}, | ||
"ramEfficiency": { | ||
"title": "RAM Efficiency", | ||
"type": "number" | ||
}, | ||
"sharedCost": { | ||
"title": "Shared Cost", | ||
"type": "number" | ||
}, | ||
"externalCost": { | ||
"title": "External Cost", | ||
"type": "number" | ||
}, | ||
"totalCost": { | ||
"title": "Total Cost", | ||
"type": "number" | ||
}, | ||
"totalEfficiency": { | ||
"title": "Total Efficiency", | ||
"type": "number" | ||
} | ||
}, | ||
"required": [] | ||
}, | ||
"mirrorProperties": {}, | ||
"calculationProperties": {}, | ||
"relations": {} | ||
} | ||
``` | ||
|
||
</details> | ||
|
||
|
||
<details> | ||
<summary><b>Kubernetes Resource (Click to expand)</b></summary> | ||
|
||
```json showLineNumbers | ||
{ | ||
"identifier": "argocdKubernetesResource", | ||
"description": "This blueprint represents an ArgoCD kubernetes resource", | ||
"title": "Kubernetes Resource", | ||
"icon": "Argo", | ||
"schema": { | ||
"properties": { | ||
"kind": { | ||
"title": "Kind", | ||
"type": "string" | ||
}, | ||
"version": { | ||
"title": "Version", | ||
"type": "string" | ||
}, | ||
"namespace": { | ||
"title": "Namespace", | ||
"type": "string" | ||
}, | ||
"labels": { | ||
"type": "object", | ||
"title": "Labels" | ||
}, | ||
"annotations": { | ||
"type": "object", | ||
"title": "Annotations" | ||
} | ||
}, | ||
"required": [] | ||
}, | ||
"mirrorProperties": { | ||
"healthStatus": { | ||
"title": "Health Status", | ||
"path": "application.healthStatus" | ||
}, | ||
"syncStatus": { | ||
"title": "Sync Status", | ||
"path": "application.syncStatus" | ||
} | ||
}, | ||
"calculationProperties": {}, | ||
"aggregationProperties": {}, | ||
"relations": {} | ||
} | ||
``` | ||
|
||
</details> | ||
|
||
|
||
Now that Port is synced with our ArgoCD and Opencost resources, let's map the Opencost Resource Allocations to the ArgoCD K8 resource. | ||
|
||
First, we will need to create a [relation](/build-your-software-catalog/customize-integrations/configure-data-model/relate-blueprints/relate-blueprints.md) between our `argocdKubernetesResource` and the corresponding `openCostResourceAllocation`. | ||
|
||
1. Head back to the [Builder](https://app.getport.io/settings/data-model), choose the `Pull Request` <PortTooltip id="blueprint">blueprint</PortTooltip>, and click on `New relation`: | ||
lordsarcastic marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
<img src='/img/build-your-software-catalog/sync-data-to-catalog/argocd/newRelationMapping.png' width='60%' border='1px' /> | ||
|
||
<br/><br/> | ||
|
||
2. Fill out the form like this, then click `Create`: | ||
|
||
<img src='/img/build-your-software-catalog/sync-data-to-catalog/argocd/createRelation.png' width='60%' border='1px' /> | ||
|
||
<br/><br/> | ||
|
||
|
||
Now that the <PortTooltip id="blueprint">blueprints</PortTooltip> are related, we need to assign the relevant ArgoCD K8 resource to each of our Opencost Resource Allocation. This can be done by adding some mapping logic. Go to your [data sources page](https://app.getport.io/settings/data-sources), and click on your ArgoCD integration | ||
lordsarcastic marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
Under the `resources` key, locate the Kubernetes block and replace it with the following YAML block to map ArgoCD Kubernetes Resource to the respective Opencost Allocation Resource. Then click `Save & Resync`: | ||
|
||
<details> | ||
<summary><b>Relation mapping (click to expand)</b></summary> | ||
|
||
```yaml showLineNumbers | ||
- kind: managed-resource | ||
selector: | ||
query: "true" | ||
port: | ||
entity: | ||
mappings: | ||
identifier: .__application.metadata.uid + "-" + .kind + "-" + .name | ||
title: .__application.metadata.name + "-" + .kind + "-" + .name | ||
blueprint: '"argocdKubernetesResource"' | ||
properties: | ||
kind: .kind | ||
namespace: .namespace | ||
version: .resourceVersion | ||
annotations: .liveState | fromjson | .metadata.annotations | ||
labels: .liveState | fromjson | .metadata.labels | ||
relations: | ||
application: .__application.metadata.uid | ||
image: 'if .kind == "Deployment" then .liveState | fromjson | .spec.template.spec.containers[0].image else null end' | ||
openCostResourceAllocation: .name | ||
``` | ||
|
||
</details> | ||
|
||
:::tip Mapping explanation | ||
The configuration mapping above maps `openCostResourceAllocation` using the `name` property of the Kubernetes resource since Opencost Resource Allocation have their identifiers as the name of the Kubernetes resource | ||
|
||
::: | ||
|
||
More relevant guides and examples: | ||
- [Port's Opencost integration](https://docs.getport.io/build-your-software-catalog/sync-data-to-catalog/cloud-cost/opencost) | ||
- [Port's ArgoCD integration](https://docs.getport.io/build-your-software-catalog/sync-data-to-catalog/argocd/) | ||
|
||
|
4 changes: 4 additions & 0 deletions
4
docs/build-your-software-catalog/sync-data-to-catalog/cloud-cost/opencost/_category_.json
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"label": "Jira", | ||
"position": 2 | ||
} |
4 changes: 4 additions & 0 deletions
4
...ild-your-software-catalog/sync-data-to-catalog/cloud-cost/opencost/guides/_category_.json
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"label": "Guides", | ||
"position": 1 | ||
} | ||
lordsarcastic marked this conversation as resolved.
Show resolved
Hide resolved
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.