Skip to content

Commit

Permalink
refactor: parametrized more values (#14)
Browse files Browse the repository at this point in the history
* refactor: parametrized more values

* fix: removed hardcoded version from chart
  • Loading branch information
FrancescoL96 authored Feb 5, 2025
1 parent 90780e2 commit 77c241f
Show file tree
Hide file tree
Showing 8 changed files with 115 additions and 30 deletions.
14 changes: 0 additions & 14 deletions azurepricing.yaml

This file was deleted.

13 changes: 13 additions & 0 deletions chart/templates/azurepricing.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
apiVersion: composition.krateo.io/v0-1-0
kind: FocusDataPresentationAzure
metadata:
name: {{ include "example-pricing-vm-azure.fullname" . }}
spec:
annotationKey: krateo-finops-focus-resource
filter: serviceName eq 'Virtual Machines' and armSkuName eq '{{ .Values.vmSize }}' and type eq 'Consumption' and armRegionName eq '{{ .Values.armRegionName }}'
scraperConfig:
tableName: {{ .Values.pricingScraperConfig.tableName }}
pollingIntervalHours: {{ .Values.pricingScraperConfig.pollingIntervalHours }}
scraperDatabaseConfigRef:
name: {{ .Values.pricingScraperConfig.scraperDatabaseConfigRef.name }}
namespace: {{ .Values.pricingScraperConfig.scraperDatabaseConfigRef.namespace }}
2 changes: 0 additions & 2 deletions chart/templates/networkinterface.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ apiVersion: network.azure.com/v1api20201101
kind: NetworkInterface
metadata:
name: {{ include "example-pricing-vm-azure.fullname" . }}
annotations:
focus-resource-name: '["Standard_B2ats_v2"]'
spec:
location: {{ .Values.armRegionName }}
owner:
Expand Down
2 changes: 1 addition & 1 deletion chart/templates/secret.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
apiVersion: v1
kind: Secret
metadata:
name: aso-vmsecret
name: {{ include "example-pricing-vm-azure.fullname" . }}
type: opaque
stringData:
password: {{ .Values.vmPassword }}
12 changes: 6 additions & 6 deletions chart/templates/virtualmachine.yaml
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
apiVersion: compute.azure.com/v1api20220301
kind: VirtualMachine
metadata:
name: aso-sample-vm
name: {{ include "example-pricing-vm-azure.fullname" . }}
annotations:
krateo-finops-focus-resource: '["DZH318Z0K9JH/00KX"]'
krateo-finops-focus-resource: '["{{ .Values.vmSize }}"]'
spec:
hardwareProfile:
vmSize: Standard_B2ats_v2
vmSize: {{ .Values.vmSize }}
location: {{ .Values.armRegionName }}
networkProfile:
networkInterfaces:
Expand All @@ -17,9 +17,9 @@ spec:
osProfile:
adminPassword:
key: password
name: aso-vmsecret
adminUsername: adminUser
computerName: poppy
name: {{ include "example-pricing-vm-azure.fullname" . }}
adminUsername: {{ .Values.vmAdminUsername }}
computerName: {{ .Values.vmComputerName }}
owner:
name: {{ .Values.resourceGroupName }}
storageProfile:
Expand Down
78 changes: 77 additions & 1 deletion chart/values.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,23 +14,99 @@
"title": "global",
"type": "object"
},
"name": {
"default": "aso-sample",
"required": [],
"title": "name",
"type": "string"
},
"pricingScraperConfig": {
"additionalProperties": false,
"properties": {
"pollingIntervalHours": {
"default": 1,
"required": [],
"title": "pollingIntervalHours",
"type": "integer"
},
"scraperDatabaseConfigRef": {
"additionalProperties": false,
"properties": {
"name": {
"default": "finops-database-handler",
"required": [],
"title": "name",
"type": "string"
},
"namespace": {
"default": "krateo-system",
"required": [],
"title": "namespace",
"type": "string"
}
},
"required": [
"name",
"namespace"
],
"title": "scraperDatabaseConfigRef",
"type": "object"
},
"tableName": {
"default": "pricing_table",
"required": [],
"title": "tableName",
"type": "string"
}
},
"required": [
"tableName",
"pollingIntervalHours",
"scraperDatabaseConfigRef"
],
"title": "pricingScraperConfig",
"type": "object"
},
"resourceGroupName": {
"default": "aso-sample-rg",
"required": [],
"title": "resourceGroupName",
"type": "string"
},
"vmAdminUsername": {
"default": "userAdmin",
"required": [],
"title": "vmAdminUsername",
"type": "string"
},
"vmComputerName": {
"default": "poppy",
"required": [],
"title": "vmComputerName",
"type": "string"
},
"vmPassword": {
"default": "Password123%",
"required": [],
"title": "vmPassword",
"type": "string"
},
"vmSize": {
"default": "Standard_B2ats_v2",
"required": [],
"title": "vmSize",
"type": "string"
}
},
"required": [
"name",
"vmSize",
"vmComputerName",
"vmAdminUsername",
"vmPassword",
"armRegionName",
"resourceGroupName"
"resourceGroupName",
"pricingScraperConfig"
],
"type": "object"
}
14 changes: 13 additions & 1 deletion chart/values.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,15 @@
name: aso-sample

vmSize: Standard_B2ats_v2
vmComputerName: poppy
vmAdminUsername: userAdmin
vmPassword: Password123%
armRegionName: westus3
resourceGroupName: aso-sample-rg
resourceGroupName: aso-sample-rg

pricingScraperConfig:
tableName: pricing_table
pollingIntervalHours: 1
scraperDatabaseConfigRef:
name: finops-database-handler
namespace: krateo-system
10 changes: 5 additions & 5 deletions customform.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ spec:
color: ${ .getCompositionDefinition.status.conditions[] | select(.type == "Ready") | if .status == "False" then "orange" elif .status == "True" then "green" else "grey" end }
content: ${ .getPricingInformation | "Pricing information:\n \(to_entries | map(" up to \(.value)$ per \(.key); ") | join("\n "))" }
icon: fa-cubes
tags: example-pricing-vm-azure-system,0.1.0
tags: example-pricing-vm-azure-system,0.1.1
title: example-pricing-vm-azure
status: ${ .getCompositionDefinition.status.conditions[] | select(.type == "Ready") | "Ready:" + .status }
date: ${ .getCompositionDefinition.metadata.creationTimestamp }
Expand Down Expand Up @@ -79,17 +79,17 @@ spec:
actions:
- template:
id: submit
apiVersion: composition.krateo.io/v0-1-0
apiVersion: composition.krateo.io/v0-1-1
verb: POST
resource: finopsexamplepricingvmazures
payloadToOverride:
- name: metadata.name
value: ${ git.toRepo.name }
value: ${ resourceGroupName }
- name: metadata.namespace
value: ${ "example-pricing-vm-azure-system" }
value: ${ "krateo-system" }
app:
template:
schema: ${ .getCRD | .spec.versions[] | select(.name == "v0-1-0") | .schema.openAPIV3Schema.properties.spec.properties }
schema: ${ .getCRD | .spec.versions[] | select(.name == "v0-1-1") | .schema.openAPIV3Schema.properties.spec.properties }
api:
- name: getCRD
path: "/apis/apiextensions.k8s.io/v1/customresourcedefinitions/finopsexamplepricingvmazures.composition.krateo.io"
Expand Down

0 comments on commit 77c241f

Please sign in to comment.