Skip to content

Commit

Permalink
Merge pull request #549 from vshn/appcat/270/collabora-billing
Browse files Browse the repository at this point in the history
PR for appcat on collabora-billing
  • Loading branch information
zugao authored Dec 3, 2024
2 parents 311ccc8 + c1ba29a commit cff1ad6
Show file tree
Hide file tree
Showing 52 changed files with 829 additions and 96 deletions.
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.114.0
tag: v4.116.0
functionAppcat:
registry: ${appcat:images:appcat:registry}
repository: ${appcat:images:appcat:repository}
Expand Down
43 changes: 42 additions & 1 deletion component/billing.jsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ local paramsBilling = params.billing;

local formatImage = function(ref) '%(registry)s/%(repository)s:%(tag)s' % ref;

local addOns = [ 'nextcloud-office' ];

// escape any non-valid characters and replace them with -
local escape = function(str)
std.join('',
Expand Down Expand Up @@ -149,10 +151,47 @@ local backfillCJ = function(name, query, sla, type)
},
},
failedJobsHistoryLimit: 3,
successfulJobsHistoryLimit: 0,
successfulJobsHistoryLimit: 1,
},
};

local getManagedQuery = function(queryName)
'sum_over_time(appcat:metering{label_appuio_io_billing_name="appcat-' + queryName + '",label_appcat_vshn_io_sla="%s", tenant_name!="APPUiO"}[59m:1m])/60';

local getCloudQuery = function(queryName)
'sum_over_time(appcat:metering{label_appuio_io_billing_name="appcat-' + queryName + '",label_appcat_vshn_io_sla="%s", tenant_name="APPUiO"}[59m:1m])/60 * 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 getPermutations = function(cloudQuery, managedQuery)
[
{
query: cloudQuery % 'besteffort',
sla: 'besteffort',
type: 'cloud',
},
{
query: cloudQuery % 'guaranteed',
sla: 'guaranteed',
type: 'cloud',
},
{
query: managedQuery % 'besteffort',
sla: 'besteffort',
type: 'managed',
},
{
query: managedQuery % 'guaranteed',
sla: 'guaranteed',
type: 'managed',
},
];

local generateAddOnsCloudAndManaged = function(name)
local queryName = if name == 'postgres' then name + 'ql' else name;
local managedQuery = getManagedQuery(queryName);
local cloudQuery = getCloudQuery(queryName);
local permutations = getPermutations(cloudQuery, managedQuery);
std.flatMap(function(r) [ backfillCJ(name, r.query, r.sla, r.type) ], permutations);

local generateCloudAndManaged = function(name)

// For postgresql we have a missmatch between the label and the name in our definition.
Expand Down Expand Up @@ -188,11 +227,13 @@ local generateCloudAndManaged = function(name)

local vshnServices = common.FilterServiceByBoolean('billing');
local billingCronjobs = std.flattenArrays(std.flatMap(function(r) [ generateCloudAndManaged(r.name) ], vshnServices));
local billingAddOnsCronjobs = std.flattenArrays(std.flatMap(function(addOn) [ generateAddOnsCloudAndManaged(addOn) ], addOns));

if paramsBilling.vshn.enableCronjobs then
{
[if std.length(std.filter(function(name) paramsBilling.network_policies.target_namespaces[name] == true, std.objectFields(paramsBilling.network_policies.target_namespaces))) > 0 then 'billing/01_netpol']: netPol.Policies,
'billing/10_odoo_secret': odooSecret,
'billing/11_backfill': billingCronjobs,
'billing/12_backfill_addons': billingAddOnsCronjobs,
[if paramsBilling.monitoring.enabled then 'billing/50_alerts']: alerts.Alerts,
} else {}
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@ metadata:
argocd.argoproj.io/sync-wave: '-40'
name: function-appcat
spec:
package: ghcr.io/vshn/appcat:v4.114.0-func
package: ghcr.io/vshn/appcat:v4.116.0-func
runtimeConfigRef:
name: function-appcat
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ spec:
emailAlertingSmtpHost: smtp.eu.mailgun.org:465
emailAlertingSmtpUsername: appcat@appuio.cloud
ignoreNamespaceForBilling: vshn-test
imageTag: v4.114.0
imageTag: v4.116.0
ingress_annotations: |
nginx.ingress.kubernetes.io/backend-protocol: HTTPS
cert-manager.io/cluster-issuer: letsencrypt-staging
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ spec:
emailAlertingSmtpHost: smtp.eu.mailgun.org:465
emailAlertingSmtpUsername: appcat@appuio.cloud
ignoreNamespaceForBilling: vshn-test
imageTag: v4.114.0
imageTag: v4.116.0
isOpenshift: 'false'
maintenanceSA: helm-based-service-maintenance
mode: standalone
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ spec:
emailAlertingSmtpHost: smtp.eu.mailgun.org:465
emailAlertingSmtpUsername: appcat@appuio.cloud
ignoreNamespaceForBilling: vshn-test
imageTag: v4.114.0
imageTag: v4.116.0
ingress_annotations: |
cert-manager.io/cluster-issuer: letsencrypt-staging
nginx.ingress.kubernetes.io/enable-cors: "true"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ spec:
emailAlertingSmtpUsername: appcat@appuio.cloud
externalDatabaseConnectionsEnabled: 'true'
ignoreNamespaceForBilling: vshn-test
imageTag: v4.114.0
imageTag: v4.116.0
initContainers: '{"clusterReconciliationCycle": {"limits": {"cpu": "300m",
"memory": "200Mi"}, "requests": {"cpu": "100m", "memory": "100Mi"}}, "pgbouncerAuthFile":
{"limits": {"cpu": "300m", "memory": "500Mi"}, "requests": {"cpu": "100m",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -597,7 +597,7 @@ spec:
emailAlertingSmtpHost: smtp.eu.mailgun.org:465
emailAlertingSmtpUsername: appcat@appuio.cloud
ignoreNamespaceForBilling: vshn-test
imageTag: v4.114.0
imageTag: v4.116.0
isOpenshift: 'false'
maintenanceSA: helm-based-service-maintenance
ownerGroup: vshn.appcat.vshn.io
Expand Down
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.114.0
image: ghcr.io/vshn/appcat:v4.116.0
livenessProbe:
failureThreshold: 3
httpGet:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ spec:
env:
- name: PLANS_NAMESPACE
value: syn-appcat
image: ghcr.io/vshn/appcat:v4.114.0
image: ghcr.io/vshn/appcat:v4.116.0
livenessProbe:
httpGet:
path: /healthz
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ spec:
envFrom:
- secretRef:
name: appcat-sla-reports-creds
image: ghcr.io/vshn/appcat:v4.114.0
image: ghcr.io/vshn/appcat:v4.116.0
name: sla-reporter
resources:
limits:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ spec:
value: 'true'
- name: APPCAT_SLI_VSHNMARIADB
value: 'true'
image: ghcr.io/vshn/appcat:v4.114.0
image: ghcr.io/vshn/appcat:v4.116.0
livenessProbe:
httpGet:
path: /healthz
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@ metadata:
argocd.argoproj.io/sync-wave: '-40'
name: function-appcat
spec:
package: ghcr.io/vshn/appcat:v4.114.0-func
package: ghcr.io/vshn/appcat:v4.116.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.114.0
image: ghcr.io/vshn/appcat:v4.116.0
livenessProbe:
failureThreshold: 3
httpGet:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ spec:
value: 'false'
- name: APPCAT_SLI_VSHNMARIADB
value: 'false'
image: ghcr.io/vshn/appcat:v4.114.0
image: ghcr.io/vshn/appcat:v4.116.0
livenessProbe:
httpGet:
path: /healthz
Expand Down
2 changes: 1 addition & 1 deletion tests/golden/dev/appcat/appcat/10_function_appcat.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@ metadata:
argocd.argoproj.io/sync-wave: '-40'
name: function-appcat
spec:
package: ghcr.io/vshn/appcat:v4.114.0-func
package: ghcr.io/vshn/appcat:v4.116.0-func
runtimeConfigRef:
name: function-appcat
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ spec:
emailAlertingSmtpHost: smtp.eu.mailgun.org:465
emailAlertingSmtpUsername: appcat@appuio.cloud
ignoreNamespaceForBilling: vshn-test
imageTag: v4.114.0
imageTag: v4.116.0
ingress_annotations: |
nginx.ingress.kubernetes.io/backend-protocol: HTTPS
cert-manager.io/cluster-issuer: letsencrypt-staging
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ spec:
emailAlertingSmtpHost: smtp.eu.mailgun.org:465
emailAlertingSmtpUsername: appcat@appuio.cloud
ignoreNamespaceForBilling: vshn-test
imageTag: v4.114.0
imageTag: v4.116.0
isOpenshift: 'false'
maintenanceSA: helm-based-service-maintenance
mode: standalone
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ spec:
emailAlertingSmtpHost: smtp.eu.mailgun.org:465
emailAlertingSmtpUsername: appcat@appuio.cloud
ignoreNamespaceForBilling: vshn-test
imageTag: v4.114.0
imageTag: v4.116.0
ingress_annotations: |
cert-manager.io/cluster-issuer: letsencrypt-staging
isOpenshift: 'false'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ spec:
emailAlertingSmtpUsername: appcat@appuio.cloud
externalDatabaseConnectionsEnabled: 'true'
ignoreNamespaceForBilling: vshn-test
imageTag: v4.114.0
imageTag: v4.116.0
initContainers: '{"clusterReconciliationCycle": {"limits": {"cpu": "300m",
"memory": "200Mi"}, "requests": {"cpu": "100m", "memory": "100Mi"}}, "pgbouncerAuthFile":
{"limits": {"cpu": "300m", "memory": "500Mi"}, "requests": {"cpu": "100m",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -597,7 +597,7 @@ spec:
emailAlertingSmtpHost: smtp.eu.mailgun.org:465
emailAlertingSmtpUsername: appcat@appuio.cloud
ignoreNamespaceForBilling: vshn-test
imageTag: v4.114.0
imageTag: v4.116.0
isOpenshift: 'false'
maintenanceSA: helm-based-service-maintenance
ownerGroup: vshn.appcat.vshn.io
Expand Down
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.114.0
image: ghcr.io/vshn/appcat:v4.116.0
livenessProbe:
failureThreshold: 3
httpGet:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ spec:
env:
- name: PLANS_NAMESPACE
value: syn-appcat
image: ghcr.io/vshn/appcat:v4.114.0
image: ghcr.io/vshn/appcat:v4.116.0
livenessProbe:
httpGet:
path: /healthz
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ spec:
envFrom:
- secretRef:
name: appcat-sla-reports-creds
image: ghcr.io/vshn/appcat:v4.114.0
image: ghcr.io/vshn/appcat:v4.116.0
name: sla-reporter
resources:
limits:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ spec:
value: 'true'
- name: APPCAT_SLI_VSHNMARIADB
value: 'true'
image: ghcr.io/vshn/appcat:v4.114.0
image: ghcr.io/vshn/appcat:v4.116.0
livenessProbe:
httpGet:
path: /healthz
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ spec:
name: vcluster-kubeconfig
- name: PLANS_NAMESPACE
value: syn-appcat
image: ghcr.io/vshn/appcat:v4.114.0
image: ghcr.io/vshn/appcat:v4.116.0
livenessProbe:
httpGet:
path: /healthz
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@ metadata:
argocd.argoproj.io/sync-wave: '-40'
name: function-appcat
spec:
package: ghcr.io/vshn/appcat:v4.114.0-func
package: ghcr.io/vshn/appcat:v4.116.0-func
runtimeConfigRef:
name: function-appcat
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ spec:
emailAlertingSmtpHost: smtp.eu.mailgun.org:465
emailAlertingSmtpUsername: appcat@appuio.cloud
ignoreNamespaceForBilling: vshn-test
imageTag: v4.114.0
imageTag: v4.116.0
ingress_annotations: |
nginx.ingress.kubernetes.io/backend-protocol: HTTPS
cert-manager.io/cluster-issuer: letsencrypt-staging
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ spec:
emailAlertingSmtpHost: smtp.eu.mailgun.org:465
emailAlertingSmtpUsername: appcat@appuio.cloud
ignoreNamespaceForBilling: vshn-test
imageTag: v4.114.0
imageTag: v4.116.0
isOpenshift: 'true'
maintenanceSA: helm-based-service-maintenance
mode: standalone
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ spec:
emailAlertingSmtpHost: smtp.eu.mailgun.org:465
emailAlertingSmtpUsername: appcat@appuio.cloud
ignoreNamespaceForBilling: vshn-test
imageTag: v4.114.0
imageTag: v4.116.0
isOpenshift: 'true'
maintenanceSA: helm-based-service-maintenance
minioChartRepository: https://charts.min.io
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ spec:
emailAlertingSmtpHost: smtp.eu.mailgun.org:465
emailAlertingSmtpUsername: appcat@appuio.cloud
ignoreNamespaceForBilling: vshn-test
imageTag: v4.114.0
imageTag: v4.116.0
ingress_annotations: |
cert-manager.io/cluster-issuer: letsencrypt-staging
isOpenshift: 'true'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ spec:
emailAlertingSmtpUsername: appcat@appuio.cloud
externalDatabaseConnectionsEnabled: 'true'
ignoreNamespaceForBilling: vshn-test
imageTag: v4.114.0
imageTag: v4.116.0
initContainers: '{"clusterReconciliationCycle": {"limits": {"cpu": "300m",
"memory": "200Mi"}, "requests": {"cpu": "100m", "memory": "100Mi"}}, "pgbouncerAuthFile":
{"limits": {"cpu": "300m", "memory": "500Mi"}, "requests": {"cpu": "100m",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -597,7 +597,7 @@ spec:
emailAlertingSmtpHost: smtp.eu.mailgun.org:465
emailAlertingSmtpUsername: appcat@appuio.cloud
ignoreNamespaceForBilling: vshn-test
imageTag: v4.114.0
imageTag: v4.116.0
isOpenshift: 'true'
maintenanceSA: helm-based-service-maintenance
ownerGroup: vshn.appcat.vshn.io
Expand Down
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.114.0
image: ghcr.io/vshn/appcat:v4.116.0
livenessProbe:
failureThreshold: 3
httpGet:
Expand Down
Loading

0 comments on commit cff1ad6

Please sign in to comment.