Skip to content

Commit

Permalink
testing new kubebuilder approach
Browse files Browse the repository at this point in the history
  • Loading branch information
wejdross committed Jan 28, 2025
1 parent 9d91102 commit 1806357
Show file tree
Hide file tree
Showing 2 changed files with 138 additions and 1 deletion.
136 changes: 136 additions & 0 deletions component/vshn_codey.jsonnet
Original file line number Diff line number Diff line change
@@ -0,0 +1,136 @@
local com = import 'lib/commodore.libjsonnet';
local kap = import 'lib/kapitan.libjsonnet';
local kube = import 'lib/kube.libjsonnet';

local comp = import 'lib/appcat-compositions.libsonnet';
local crossplane = import 'lib/appcat-crossplane.libsonnet';

local common = import 'common.libsonnet';
local vars = import 'config/vars.jsonnet';
local prom = import 'prometheus.libsonnet';
local slos = import 'slos.libsonnet';
local opsgenieRules = import 'vshn_alerting.jsonnet';
local xrds = import 'xrds.libsonnet';

local inv = kap.inventory();
local params = inv.parameters.appcat;
local codeyParams = params.services.vshn.codey;
local appuioManaged = inv.parameters.appcat.appuioManaged;

local defaultUser = 'default';
local defaultPort = '6379';

local caCertificateSecretName = 'tls-ca-certificate';
local serverCertificateSecretName = 'tls-server-certificate';
local clientCertificateSecretName = 'tls-client-certificate';

local serviceNameLabelKey = 'appcat.vshn.io/servicename';
local serviceNamespaceLabelKey = 'appcat.vshn.io/claim-namespace';
local serviceCLaimNameLabelKey = 'appcat.vshn.io/claim-name';

local connectionSecretKeys = [
'CODEY_USERNAME',
'CODEY_PASSWORD',
'CODEY_URL',
];

local isOpenshift = std.startsWith(inv.parameters.facts.distribution, 'openshift') || inv.parameters.facts.distribution == 'oke';

local securityContext = if isOpenshift then false else true;

local codeyPlans = common.FilterDisabledParams(codeyParams.plans);

local xrd = xrds.XRDFromCRD(
'xvshncodey.vshn.appcat.vshn.io',
xrds.LoadCRD('vshn.appcat.vshn.io_vshncodey.yaml', params.images.appcat.tag),
defaultComposition='vshncodey.vshn.appcat.vshn.io',
connectionSecretKeys=connectionSecretKeys,
) + xrds.WithPlanDefaults(codeyPlans, codeyParams.defaultPlan);

local composition =
local selfSignedIssuer = comp.KubeObject('cert-manager.io/v1', 'Issuer') +
{
spec+: {
forProvider+: {
manifest+: {
metadata: {
name: '',
namespace: '',
},
spec: {
selfSigned: {
crlDistributionPoints: [],
},
},
},
},
},
};


kube._Object('apiextensions.crossplane.io/v1', 'Composition', 'vshncodey.vshn.appcat.vshn.io') +
common.SyncOptions +
common.vshnMetaVshnDBaas('codey', 'standalone', 'true', codeyPlans) +
{
spec: {
compositeTypeRef: comp.CompositeRef(xrd),
writeConnectionSecretsToNamespace: codeyParams.secretNamespace,
mode: 'Pipeline',
pipeline:
[
{
step: 'patch-and-transform',
functionRef: {
name: 'function-patch-and-transform',
},
input: {
apiVersion: 'pt.fn.crossplane.io/v1beta1',
kind: 'Resources',
resources: [ selfSignedIssuer ],
},
},
{
step: 'codey-func',
functionRef: {
name: 'function-appcat',
},
input: kube.ConfigMap('xfn-config') + {
metadata: {
labels: {
name: 'xfn-config',
},
name: 'xfn-config',
},
data: {
serviceName: 'codey',
controlNamespace: params.services.controlNamespace,
quotasEnabled: std.toString(params.services.vshn.quotasEnabled),
ownerKind: xrd.spec.names.kind,
ownerGroup: xrd.spec.group,
ownerVersion: xrd.spec.versions[0].name,
sliNamespace: params.slos.namespace,
crossplaneNamespace: params.crossplane.namespace,
ignoreNamespaceForBilling: params.billing.ignoreNamespace,
},
},
},
],
},
};

local plansCM = kube.ConfigMap('vshncodeyplans') + {
metadata+: {
namespace: params.namespace,
},
data: {
plans: std.toString(codeyPlans),
},
};

if params.services.vshn.enabled && codeyParams.enabled && vars.isSingleOrControlPlaneCluster then {
'26_xrd_vshn_codey': xrd,
// '20_rbac_vshn_codey': xrds.CompositeClusterRoles(xrd),
// '20_role_vshn_codeyrestore': [ restoreRole, restoreServiceAccount, restoreClusterRoleBinding ],
'20_plans_vshn_codey': plansCM,
// '21_composition_vshn_codey': composition,
} else {}
3 changes: 2 additions & 1 deletion tests/golden/dev/appcat/appcat/20_xrd_vshn_forgejo.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5593,7 +5593,6 @@ spec:
type: boolean
type: object
service:
default: {}
description: Service contains Forgejo DBaaS specific properties
properties:
adminEmail:
Expand Down Expand Up @@ -5624,6 +5623,8 @@ spec:
Version contains supported version of Forgejo.
Multiple versions are supported. Defaults to 10.0.0 if not set.
type: string
required:
- fqdn
type: object
size:
default: {}
Expand Down

0 comments on commit 1806357

Please sign in to comment.