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

PR for appcat on change-billing #512

Merged
merged 3 commits into from
Oct 25, 2024
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
2 changes: 1 addition & 1 deletion class/defaults.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ parameters:
appcat:
registry: ghcr.io
repository: vshn/appcat
tag: v4.98.1
tag: v4.99.0
functionAppcat:
registry: ${appcat:images:appcat:registry}
repository: ${appcat:images:appcat:repository}
Expand Down
4 changes: 2 additions & 2 deletions component/billing.jsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -157,8 +157,8 @@ local generateCloudAndManaged = function(name)
// For postgresql we have a missmatch between the label and the name in our definition.
local queryName = if name == 'postgres' then name + 'ql' else name;

local managedQuery = 'appcat:metering{label_appuio_io_billing_name="appcat-' + queryName + '",label_appcat_vshn_io_sla="%s", tenant_name!="APPUiO"}';
local cloudQuery = 'appcat:metering{label_appuio_io_billing_name="appcat-' + queryName + '",label_appcat_vshn_io_sla="%s", tenant_name="APPUiO"} * on(label_appuio_io_organization) group_left(sales_order) label_replace(appuio_control_organization_info{namespace="appuio-control-api-production"}, "label_appuio_io_organization", "$1", "organization", "(.*)")';
local managedQuery = 'sum_over_time(appcat:metering{label_appuio_io_billing_name="appcat-' + queryName + '",label_appcat_vshn_io_sla="%s", tenant_name!="APPUiO"}[59:1])/60';
local cloudQuery = 'sum_over_time(appcat:metering{label_appuio_io_billing_name="appcat-' + queryName + '",label_appcat_vshn_io_sla="%s", tenant_name="APPUiO"} * on(label_appuio_io_organization) group_left(sales_order) label_replace(appuio_control_organization_info{namespace="appuio-control-api-production"}, "label_appuio_io_organization", "$1", "organization", "(.*)")[59:1])/60';

local permutations = [
{
Expand Down
24 changes: 0 additions & 24 deletions component/main.jsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -113,10 +113,6 @@ local promQueryTemplate = importstr 'promql/appcat.promql';
local promQueryWithLabel = std.strReplace(promQueryTemplate, '{{ORGLABEL}}', tenant.label);
local promQuery = std.strReplace(promQueryWithLabel, '{{TENANT_REPLACE}}', tenant.replace);

local meteringQueryCloud = importstr 'promql/metering_cloud.promql';
local meteringQueryManagedRaw = importstr 'promql/metering_managed.promql';
local meteringQueryManaged = std.strReplace(meteringQueryManagedRaw, '{{salesOrderID}}', params.billing.salesOrder);

local legacyBillingRule = std.prune(kube._Object('monitoring.coreos.com/v1', 'PrometheusRule', 'appcat-billing') {
metadata+: {
namespace: params.namespace,
Expand All @@ -136,25 +132,6 @@ local legacyBillingRule = std.prune(kube._Object('monitoring.coreos.com/v1', 'Pr
},
});

local meteringRule = std.prune(kube._Object('monitoring.coreos.com/v1', 'PrometheusRule', 'appcat-metering') {
metadata+: {
namespace: params.namespace,
},
spec: {
groups: [
{
name: 'appcat-metering-rules',
rules: [
{
expr: if params.appuioManaged then meteringQueryManaged else meteringQueryCloud,
record: 'appcat:metering',
},
],
},
],
},
});

local mockOrgInfo = kube._Object('monitoring.coreos.com/v1', 'PrometheusRule', 'mock-org-info') {
metadata+: {
namespace: params.namespace,
Expand Down Expand Up @@ -286,7 +263,6 @@ local haPrometheusRule = {
'10_appcat_legacy_billing_recording_rule': legacyBillingRule,
'10_appcat_backup_monitoring': backupPrometheusRule,
'10_appcat_ha_monitoring': haPrometheusRule,
[if params.billing.vshn.meteringRules then '10_appcat_metering_recording_rule']: meteringRule,
[if params.services.vshn.enabled && params.services.emailAlerting.enabled then '10_mailgun_secret']: emailSecret,
[if params.billing.enableMockOrgInfo then '10_mock_org_info']: mockOrgInfo,
}
20 changes: 0 additions & 20 deletions component/promql/metering_cloud.promql

This file was deleted.

25 changes: 0 additions & 25 deletions component/promql/metering_managed.promql

This file was deleted.

2 changes: 2 additions & 0 deletions component/vshn_appcat_services.jsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ local opsgenieRules = import 'vshn_alerting.jsonnet';

local inv = kap.inventory();
local params = inv.parameters.appcat;
local appuioManaged = inv.parameters.appcat.appuioManaged;

local serviceNameLabelKey = 'appcat.vshn.io/servicename';
local serviceNamespaceLabelKey = 'appcat.vshn.io/claim-namespace';
Expand Down Expand Up @@ -110,6 +111,7 @@ local vshn_appcat_service(name, serviceParams) =
ownerKind: xrd.spec.names.kind,
ownerGroup: xrd.spec.group,
ownerVersion: xrd.spec.versions[0].name,
salesOrder: if appuioManaged then std.toString(params.billing.salesOrder) else '',
} + common.EmailAlerting(params.services.emailAlerting)
+ restoreSA
+ additonalInputs
Expand Down
2 changes: 2 additions & 0 deletions component/vshn_postgres.jsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ local inv = kap.inventory();
local params = inv.parameters.appcat;
local pgParams = params.services.vshn.postgres;
local opsgenieRules = import 'vshn_alerting.jsonnet';
local appuioManaged = inv.parameters.appcat.appuioManaged;

local defaultDB = 'postgres';
local defaultUser = 'postgres';
Expand Down Expand Up @@ -220,6 +221,7 @@ local composition =
bucketEndpoint: pgParams.bucket_endpoint,
isOpenshift: std.toString(isOpenshift),
sliNamespace: params.slos.namespace,
salesOrder: if appuioManaged then std.toString(params.billing.salesOrder) else '',
} + std.get(pgParams, 'additionalInputs', default={}, inc_hidden=true)
+ common.EmailAlerting(params.services.emailAlerting)
+ if pgParams.proxyFunction then {
Expand Down
2 changes: 2 additions & 0 deletions component/vshn_redis.jsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ local inv = kap.inventory();
local params = inv.parameters.appcat;
local redisParams = params.services.vshn.redis;
local opsgenieRules = import 'vshn_alerting.jsonnet';
local appuioManaged = inv.parameters.appcat.appuioManaged;

local defaultUser = 'default';
local defaultPort = '6379';
Expand Down Expand Up @@ -487,6 +488,7 @@ local composition =
ownerVersion: xrd.spec.versions[0].name,
isOpenshift: std.toString(isOpenshift),
sliNamespace: params.slos.namespace,
salesOrder: if appuioManaged then std.toString(params.billing.salesOrder) else '',
} + common.EmailAlerting(params.services.emailAlerting)
+ if redisParams.proxyFunction then {
proxyEndpoint: redisParams.grpcEndpoint,
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ kind: Function
metadata:
name: function-appcat
spec:
package: ghcr.io/vshn/appcat:v4.98.1-func
package: ghcr.io/vshn/appcat:v4.99.0-func
runtimeConfigRef:
name: function-appcat
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ spec:
- --secure-port=9443
- --tls-cert-file=/apiserver.local.config/certificates/tls.crt
- --tls-private-key-file=/apiserver.local.config/certificates/tls.key
image: ghcr.io/vshn/appcat:v4.98.1
image: ghcr.io/vshn/appcat:v4.99.0
livenessProbe:
failureThreshold: 3
httpGet:
Expand Down

This file was deleted.

2 changes: 1 addition & 1 deletion tests/golden/billing/appcat/appcat/10_function_appcat.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ kind: Function
metadata:
name: function-appcat
spec:
package: ghcr.io/vshn/appcat:v4.98.1-func
package: ghcr.io/vshn/appcat:v4.99.0-func
runtimeConfigRef:
name: function-appcat
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ spec:
- --secure-port=9443
- --tls-cert-file=/apiserver.local.config/certificates/tls.crt
- --tls-private-key-file=/apiserver.local.config/certificates/tls.key
image: ghcr.io/vshn/appcat:v4.98.1
image: ghcr.io/vshn/appcat:v4.99.0
livenessProbe:
failureThreshold: 3
httpGet:
Expand Down
Loading