diff --git a/README.md b/README.md index fd41385..ac3c931 100644 --- a/README.md +++ b/README.md @@ -191,16 +191,3 @@ source .container-use/container-use.sh cu-spec # Show available specs cu-new my-config apps # Create new config with guidance ``` - -### Available Tasks - -```bash -task: Available tasks for this project: -* branch: Create branch from main -* check: Run pre-commit hooks -* commit: Commit + push code into branch -* do: Select a task to run -* pr: Create pull request into main -* run-pre-commit-hook: Run the pre-commit hook script to replace .example.com with .example.com -* xplane-push: Push crossplane package -``` diff --git a/Taskfile.yaml b/Taskfile.yaml index 9970fbd..b320910 100644 --- a/Taskfile.yaml +++ b/Taskfile.yaml @@ -14,19 +14,14 @@ vars: includes: git: taskfile: https://raw.githubusercontent.com/stuttgart-things/tasks/refs/heads/main/git/git.yaml - #crossplane: - # taskfile: https://raw.githubusercontent.com/stuttgart-things/tasks/refs/heads/main/configuration/crossplane.yaml + crossplane: + taskfile: https://raw.githubusercontent.com/stuttgart-things/tasks/refs/heads/main/configuration/crossplane.yaml k2n: taskfile: https://raw.githubusercontent.com/stuttgart-things/tasks/refs/heads/main/configuration/k2n.yaml + dagger: + taskfile: https://raw.githubusercontent.com/stuttgart-things/tasks/refs/heads/main/dagger/modules.yaml tasks: - apply-configuration-packages: - desc: Apply crossplane configuration packages - cmds: - - | - set -e - - push-configuration-package: desc: Push crossplane configuration package cmds: diff --git a/configurations/apps/postgres-db/README.md b/configurations/apps/postgres-db/README.md index 6a87eb3..854f998 100644 --- a/configurations/apps/postgres-db/README.md +++ b/configurations/apps/postgres-db/README.md @@ -2,34 +2,24 @@ ## REQUIREMENTS -
DEPLOY POSTGRESDB w/ HELM +
CONNECT TO POSTGRESDB ```bash -cat < values.yaml ---- -global: - postgresql: - auth: - postgresPassword: volki123 - username: volki - password: volki123 - database: volki -EOF +# GET SERVICE +kubectk get svc -m postgres -helm repo add bitnami https://charts.bitnami.com/bitnami -helm repo update +# GET USER +kubectl get pod -n postgres -l app.kubernetes.io/name=postgres -o yaml | grep -A5 POSTGRESES -helm upgrade --install postgresql bitnami/postgresql \ ---version 16.7.13 \ --n xplane \ ---create-namespace \ ---values values.yaml -``` +# RUN SQL CLIENT +kubectl run -n postgres -it psql-client --rm --image=postgres --restart=Never -- bash -```bash -kubectl run -n xplane -it psql-client --rm --image=postgres --restart=Never -- bash - -psql -h postgresql.xplane.svc.cluster.local -U postgres -p 5432 +# CONNECT TO DB +psql \ + -h my-postgres-d499897318cc \ + -U appuser \ + -d appdb \ + -p 5432 \l # list databases ``` @@ -46,42 +36,23 @@ kind: Provider metadata: name: provider-sql spec: - package: xpkg.upbound.io/crossplane-contrib/provider-sql:v0.12.0 + package: xpkg.upbound.io/crossplane-contrib/provider-sql:v0.13.0 EOF ``` ```bash kubectl apply -f - <=v1.14.1-0" + version: ">=2.13.0" dependsOn: - - provider: xpkg.upbound.io/crossplane-contrib/provider-kubernetes - version: ">=v0.16.0" - provider: xpkg.upbound.io/crossplane-contrib/provider-helm version: ">=v0.19.0" diff --git a/configurations/apps/postgres-server/examples/claim.yaml b/configurations/apps/postgres-server/examples/claim.yaml index a9eacfb..1b9d935 100644 --- a/configurations/apps/postgres-server/examples/claim.yaml +++ b/configurations/apps/postgres-server/examples/claim.yaml @@ -2,8 +2,21 @@ apiVersion: resources.stuttgart-things.com/v1alpha1 kind: PostgresServer metadata: - name: postgres + name: my-postgres spec: - deploymentNamespace: test2 - clusterName: in-cluster - version: 16.7.18 + targetCluster: + name: in-cluster + scope: Cluster + postgres: + profile: medium + namespace: postgres + auth: + username: appuser + database: appdb + existingSecret: postgres-app-credentials # pragma: allowlist secret + persistence: + size: 20Gi + metrics: + enabled: true + serviceMonitor: + enabled: false diff --git a/configurations/apps/postgres-server/examples/configuration.yaml b/configurations/apps/postgres-server/examples/configuration.yaml deleted file mode 100644 index 62a7415..0000000 --- a/configurations/apps/postgres-server/examples/configuration.yaml +++ /dev/null @@ -1,7 +0,0 @@ ---- -apiVersion: pkg.crossplane.io/v1 -kind: Configuration -metadata: - name: postgres-server -spec: - package: ghcr.io/stuttgart-things/crossplane/postgres-server:v16.7.18 diff --git a/configurations/apps/postgres-server/examples/functions.yaml b/configurations/apps/postgres-server/examples/functions.yaml index e55b71d..b21e28d 100644 --- a/configurations/apps/postgres-server/examples/functions.yaml +++ b/configurations/apps/postgres-server/examples/functions.yaml @@ -1,7 +1,13 @@ ---- apiVersion: pkg.crossplane.io/v1beta1 kind: Function metadata: name: function-go-templating spec: - package: xpkg.upbound.io/crossplane-contrib/function-go-templating:v0.9.2 + package: xpkg.crossplane.io/crossplane-contrib/function-go-templating:v0.11.3 +--- +apiVersion: pkg.crossplane.io/v1beta1 +kind: Function +metadata: + name: function-auto-ready +spec: + package: xpkg.crossplane.io/crossplane-contrib/function-auto-ready:v0.6.0 diff --git a/configurations/terraform/harbor-project/README.md b/configurations/terraform/harbor-project/README.md new file mode 100644 index 0000000..34f31b4 --- /dev/null +++ b/configurations/terraform/harbor-project/README.md @@ -0,0 +1,158 @@ +# Harbor Project + +Crossplane composition for managing Harbor projects using OpenTofu/Terraform. + +## Prerequisites + +- Crossplane installed +- `function-go-templating` and `function-auto-ready` functions installed + +### Install OpenTofu Provider + +```bash +kubectl apply -f - < + meta.crossplane.io/source: github.com/stuttgart-things/crossplane-harbor-project + meta.crossplane.io/license: Apache-2.0 + meta.crossplane.io/description: | + Harbor project management abstraction for Crossplane using OpenTofu provider. + Automatically provisions Harbor projects with vulnerability scanning and storage quotas. + meta.crossplane.io/readme: | + # HarborProject Configuration + + A Crossplane configuration for managing Harbor projects using the OpenTofu provider with the Harbor Terraform provider. + + ## Features + + - **Automated Project Creation**: Provisions Harbor projects with a single claim + - **Security First**: Enables vulnerability scanning by default + - **Storage Management**: Configurable storage quotas per project + - **Insecure Registry Support**: Optional flag for self-signed certificates + - **Provider Flexibility**: Works with any Harbor instance (cloud or on-premises) + + ## Usage + + ### Simple Example + ```yaml + apiVersion: resources.stuttgart-things.com/v1alpha1 + kind: HarborProject + metadata: + name: demo-project + spec: + providerConfigRef: default + harborURL: https://harbor.example.com + projectName: my-application + storageQuota: 107374182400 # 100GB in bytes + ``` + + ### Self-Signed Certificate Example + ```yaml + apiVersion: resources.stuttgart-things.com/v1alpha1 + kind: HarborProject + metadata: + name: dev-project + spec: + providerConfigRef: default + harborURL: https://harbor.internal.dev + projectName: development-team + harborInsecure: true + storageQuota: -1 # Unlimited + ``` + + ## Requirements + + - Crossplane >= v1.14.1 + - Provider OpenTofu (upbound) + - Function Go Templating + - Function Auto Ready + - Harbor instance with admin credentials + + ## Prerequisites + + You need to create a ClusterProviderConfig for OpenTofu with Harbor credentials: + + ```yaml + apiVersion: opentofu.m.upbound.io/v1beta1 + kind: ClusterProviderConfig + metadata: + name: default + spec: + credentials: + source: Secret + secretRef: + namespace: crossplane-system + name: harbor-credentials + key: credentials + ``` + +spec: + crossplane: + version: ">=v1.14.1-0" + + dependsOn: + - provider: xpkg.upbound.io/upbound/provider-opentofu + version: ">=v0.3.0" + # Required for Pipeline compositions + - function: xpkg.crossplane.io/crossplane-contrib/function-go-templating + version: ">=v0.11.3" + - function: xpkg.crossplane.io/crossplane-contrib/function-auto-ready + version: ">=v0.6.0" diff --git a/configurations/terraform/harbor-project/examples/claim.yaml b/configurations/terraform/harbor-project/examples/claim.yaml new file mode 100644 index 0000000..e68cb6a --- /dev/null +++ b/configurations/terraform/harbor-project/examples/claim.yaml @@ -0,0 +1,14 @@ +--- +apiVersion: resources.stuttgart-things.com/v1alpha1 +kind: HarborProject +metadata: + name: demo-project-2 + namespace: default +spec: + harborURL: https://harbor.idp.kubermatic.sva.dev + projectName: demo-project-21 + storageQuota: -1 + providerConfigRef: default + credentialsSecretRef: + name: harbor-credentials + namespace: default diff --git a/configurations/terraform/harbor-project/examples/cluster-provider-config.yaml b/configurations/terraform/harbor-project/examples/cluster-provider-config.yaml new file mode 100644 index 0000000..9c33b2d --- /dev/null +++ b/configurations/terraform/harbor-project/examples/cluster-provider-config.yaml @@ -0,0 +1,14 @@ +--- +apiVersion: opentofu.m.upbound.io/v1beta1 +kind: ClusterProviderConfig +metadata: + name: default +spec: + configuration: | + terraform { + backend "kubernetes" { + secret_suffix = "providerconfig-default" + namespace = "crossplane-system" + in_cluster_config = true + } + } diff --git a/configurations/terraform/harbor-project/examples/deployment-runtime-config.yaml b/configurations/terraform/harbor-project/examples/deployment-runtime-config.yaml new file mode 100644 index 0000000..0ee5c3c --- /dev/null +++ b/configurations/terraform/harbor-project/examples/deployment-runtime-config.yaml @@ -0,0 +1,17 @@ +--- +apiVersion: pkg.crossplane.io/v1beta1 +kind: DeploymentRuntimeConfig +metadata: + name: opentofu +spec: + deploymentTemplate: + spec: + selector: {} + template: + spec: + containers: + - name: package-runtime + args: + - -d + - --poll=5m + - --max-reconcile-rate=10 diff --git a/configurations/terraform/harbor-project/examples/functions.yaml b/configurations/terraform/harbor-project/examples/functions.yaml new file mode 100644 index 0000000..9f82445 --- /dev/null +++ b/configurations/terraform/harbor-project/examples/functions.yaml @@ -0,0 +1,14 @@ +--- +apiVersion: pkg.crossplane.io/v1beta1 +kind: Function +metadata: + name: function-go-templating +spec: + package: xpkg.crossplane.io/crossplane-contrib/function-go-templating:v0.11.3 +--- +apiVersion: pkg.crossplane.io/v1beta1 +kind: Function +metadata: + name: function-auto-ready +spec: + package: xpkg.crossplane.io/crossplane-contrib/function-auto-ready:v0.6.0 diff --git a/configurations/terraform/harbor-project/examples/provider.yaml b/configurations/terraform/harbor-project/examples/provider.yaml new file mode 100644 index 0000000..29d9dd6 --- /dev/null +++ b/configurations/terraform/harbor-project/examples/provider.yaml @@ -0,0 +1,9 @@ +--- +apiVersion: pkg.crossplane.io/v1 +kind: Provider +metadata: + name: provider-opentofu +spec: + package: xpkg.upbound.io/upbound/provider-opentofu:v1.0.3 + runtimeConfigRef: + name: opentofu diff --git a/configurations/terraform/harbor-project/examples/secret.yaml b/configurations/terraform/harbor-project/examples/secret.yaml new file mode 100644 index 0000000..3ef6a73 --- /dev/null +++ b/configurations/terraform/harbor-project/examples/secret.yaml @@ -0,0 +1,11 @@ +--- +apiVersion: v1 +kind: Secret +metadata: + name: harbor-credentials + namespace: default +type: Opaque +stringData: + credentials.tfvars: | + harbor_username = "" + harbor_password = "" diff --git a/dagger.json b/dagger.json index 024cb0f..464ad4f 100644 --- a/dagger.json +++ b/dagger.json @@ -5,6 +5,11 @@ "source": "go" }, "dependencies": [ + { + "name": "go", + "source": "github.com/stuttgart-things/dagger/go@v0.71.0", + "pin": "7c8aed11ba08645e6cba3513a3aae5f2945aadd1" + }, { "name": "kubernetes", "source": "github.com/stuttgart-things/dagger/kubernetes@v0.70.0", diff --git a/dev/storage-integration/README.md b/dev/storage-integration/README.md deleted file mode 100644 index d79ebbc..0000000 --- a/dev/storage-integration/README.md +++ /dev/null @@ -1,12 +0,0 @@ -# MyClaim - -This Crossplane Configuration provisions a `StorageIntegration` Composite Resource Definition (XRD) along with a Composition and an example Claim. - -## DEV - -```bash -crossplane render examples/claim.yaml \ -apis/composition.yaml \ -examples/functions.yaml \ ---include-function-results -``` diff --git a/dev/storage-integration/apis/composition.yaml b/dev/storage-integration/apis/composition.yaml deleted file mode 100644 index b6258e7..0000000 --- a/dev/storage-integration/apis/composition.yaml +++ /dev/null @@ -1,41 +0,0 @@ ---- -apiVersion: v1beta1 -kind: Composition -metadata: - labels: - crossplane.io/xrd: storageintegrations.resources.stuttgart-things.com - name: storage-integration -spec: - compositeTypeRef: - apiVersion: resources.stuttgart-things.com/v1alpha1 - kind: StorageIntegration - #pipeline: - # - step: - # functionRef: - # name: function-go-templating - # input: - # apiVersion: gotemplating.fn.crossplane.io/v1beta1 - # kind: GoTemplate - # source: Inline - # inline: - # template: | - # apiVersion: - # kind: - # metadata: - # annotations: - # gotemplating.fn.crossplane.io/composition-resource-name: $CLAIMNAME - # gotemplating.fn.crossplane.io/ready: "True" - # - step: - # functionRef: - # name: function-patch-and-transform - # input: - # apiVersion: pt.fn.crossplane.io/v1beta1 - # environment: null - # kind: Resources - # patchSets: [] - # resources: - # - name: - # base: - # apiVersion: - # kind: - # patches: {} diff --git a/dev/storage-integration/apis/definition.yaml b/dev/storage-integration/apis/definition.yaml deleted file mode 100644 index 566498b..0000000 --- a/dev/storage-integration/apis/definition.yaml +++ /dev/null @@ -1,21 +0,0 @@ ---- -apiVersion: apiextensions.crossplane.io/v2 -kind: CompositeResourceDefinition -metadata: - name: storageintegrations.resources.stuttgart-things.com -spec: - group: resources.stuttgart-things.com - defaultCompositeDeletePolicy: Foreground - scope: Namespaced - names: - kind: StorageIntegration - plural: storageintegrations - singular: storageintegration - versions: - - name: v1alpha1 - served: true - referenceable: true - schema: - openAPIV3Schema: - type: object - # add spec fields here diff --git a/dev/storage-integration/crossplane.yaml b/dev/storage-integration/crossplane.yaml deleted file mode 100644 index ae6adea..0000000 --- a/dev/storage-integration/crossplane.yaml +++ /dev/null @@ -1,19 +0,0 @@ ---- -apiVersion: meta.pkg.crossplane.io/v1 -kind: Configuration -metadata: - name: StorageIntegration - annotations: - meta.crossplane.io/maintainer: patrick.hermann@sva.de - meta.crossplane.io/source: https://github.com/stuttgart-things/crossplane - meta.crossplane.io/license: Apache-2.0 - meta.crossplane.io/description: | - manages lifecycle of StorageIntegration w/ crossplane - meta.crossplane.io/readme: | - manages lifecycle of StorageIntegration w/ crossplane -spec: - crossplane: - version: ">=2.13.0" - dependsOn: - - provider: xpkg.upbound.io/crossplane-contrib/provider-helm - version: ">=v0.19.0" diff --git a/dev/storage-integration/examples/claim.yaml b/dev/storage-integration/examples/claim.yaml deleted file mode 100644 index 4f320ed..0000000 --- a/dev/storage-integration/examples/claim.yaml +++ /dev/null @@ -1,8 +0,0 @@ ---- -apiVersion: resources.stuttgart-things.com/v1 -kind: StorageIntegration -metadata: - name: StorageIntegrationClaim - namespace: default -spec: - # add spec fields here diff --git a/dev/storage-integration/examples/functions.yaml b/dev/storage-integration/examples/functions.yaml deleted file mode 100644 index bbbe796..0000000 --- a/dev/storage-integration/examples/functions.yaml +++ /dev/null @@ -1,15 +0,0 @@ ---- -apiVersion: pt.fn.crossplane.io/v1beta1 -kind: Function -metadata: - name: function-patch-and-transform -spec: - package: xpkg.upbound.io/function-patch-and-transform:v0.1.0 ---- -apiVersion: gotemplating.fn.crossplane.io/v1beta1 -kind: Function -metadata: - name: function-go-templating -spec: - package: xpkg.upbound.io/function-go-templating:v0.1.0 ---- diff --git a/dev/what-ever/README.md b/dev/what-ever/README.md deleted file mode 100644 index f4125ce..0000000 --- a/dev/what-ever/README.md +++ /dev/null @@ -1,5 +0,0 @@ -# MyClaim - -// ## PROVIDER-CONFIG - -// ### CREATE KUBECONFIG AS A SECRET FROM LOCAL FILE diff --git a/dev/what-ever/apis/composition.yaml b/dev/what-ever/apis/composition.yaml deleted file mode 100644 index 722c3ae..0000000 --- a/dev/what-ever/apis/composition.yaml +++ /dev/null @@ -1,41 +0,0 @@ ---- -apiVersion: v1beta1 -kind: Composition -metadata: - labels: - crossplane.io/xrd: whatevers.resources.stuttgart-things.com - name: what-ever -spec: - compositeTypeRef: - apiVersion: resources.stuttgart-things.com/v1alpha1 - kind: WhatEver - #pipeline: - # - step: - # functionRef: - # name: function-go-templating - # input: - # apiVersion: gotemplating.fn.crossplane.io/v1beta1 - # kind: GoTemplate - # source: Inline - # inline: - # template: | - # apiVersion: - # kind: - # metadata: - # annotations: - # gotemplating.fn.crossplane.io/composition-resource-name: $CLAIMNAME - # gotemplating.fn.crossplane.io/ready: "True" - # - step: - # functionRef: - # name: function-patch-and-transform - # input: - # apiVersion: pt.fn.crossplane.io/v1beta1 - # environment: null - # kind: Resources - # patchSets: [] - # resources: - # - name: - # base: - # apiVersion: - # kind: - # patches: {} diff --git a/dev/what-ever/apis/definition.yaml b/dev/what-ever/apis/definition.yaml deleted file mode 100644 index 94ce71b..0000000 --- a/dev/what-ever/apis/definition.yaml +++ /dev/null @@ -1,20 +0,0 @@ ---- -apiVersion: apiextensions.crossplane.io/v2 -kind: CompositeResourceDefinition -metadata: - name: whatevers.resources.stuttgart-things.com -spec: - group: resources.stuttgart-things.com - defaultCompositeDeletePolicy: Foreground - scope: Namespaced - names: - kind: WhatEver - plural: whatevers - singular: whatever - versions: - - name: v1alpha1 - served: true - referenceable: true - schema: - openAPIV3Schema: - type: object diff --git a/dev/what-ever/crossplane.yaml b/dev/what-ever/crossplane.yaml deleted file mode 100644 index 2f29c7a..0000000 --- a/dev/what-ever/crossplane.yaml +++ /dev/null @@ -1,19 +0,0 @@ ---- -apiVersion: meta.pkg.crossplane.io/v1 -kind: Configuration -metadata: - name: WhatEver - annotations: - meta.crossplane.io/maintainer: patrick.hermann@sva.de - meta.crossplane.io/source: https://github.com/stuttgart-things/crossplane - meta.crossplane.io/license: Apache-2.0 - meta.crossplane.io/description: | - deploys MyClaim w/ crossplane - meta.crossplane.io/readme: | - deploys MyClaim w/ crossplane -spec: - crossplane: - version: ">=2.13.0" - dependsOn: - - provider: xpkg.upbound.io/crossplane-contrib/provider-helm - version: ">=v0.19.0" diff --git a/dev/what-ever/examples/claim.yaml b/dev/what-ever/examples/claim.yaml deleted file mode 100644 index d9e851d..0000000 --- a/dev/what-ever/examples/claim.yaml +++ /dev/null @@ -1,7 +0,0 @@ ---- -apiVersion: resources.stuttgart-things.com/v1 -kind: MyClaim -metadata: - name: WhatEverClaim - namespace: default -spec: diff --git a/dev/what-ever/examples/functions.yaml b/dev/what-ever/examples/functions.yaml deleted file mode 100644 index bbbe796..0000000 --- a/dev/what-ever/examples/functions.yaml +++ /dev/null @@ -1,15 +0,0 @@ ---- -apiVersion: pt.fn.crossplane.io/v1beta1 -kind: Function -metadata: - name: function-patch-and-transform -spec: - package: xpkg.upbound.io/function-patch-and-transform:v0.1.0 ---- -apiVersion: gotemplating.fn.crossplane.io/v1beta1 -kind: Function -metadata: - name: function-go-templating -spec: - package: xpkg.upbound.io/function-go-templating:v0.1.0 ----