diff --git a/docs/products/runtime/connect-services-to-apps.md b/docs/products/runtime/connect-services-to-apps.md index dcfa15234..08a935648 100644 --- a/docs/products/runtime/connect-services-to-apps.md +++ b/docs/products/runtime/connect-services-to-apps.md @@ -5,6 +5,8 @@ sidebar_label: Connect services import ConsoleLabel from "@site/src/components/ConsoleIcons"; import AppIntegrationLimitation from "@site/static/includes/runtime-app-integration-limitation.md"; +import Tabs from '@theme/Tabs'; +import TabItem from '@theme/TabItem'; Connect your deployed application to [Aiven services](/docs/products/services). You can connect an existing Aiven for Apache Kafka®, Aiven for PostgreSQL®, @@ -17,12 +19,84 @@ by using [Compose files](/docs/products/runtime/manifest-files/compose-files). ## Connect an Aiven service + + + 1. In your project, click . 1. Open your application. 1. In the **Connected services** section, click **Connect service**. 1. Select the service to connect. 1. Click **Connect**. + + + +Use the `avn service integration-create` command. For example, to integrate +a PostgreSQL service with your application, run: + +```bash +avn service integration-create \ + --project PROJECT_NAME \ + --integration-type application_service_credential \ + --source-service SERVICE_NAME \ + --dest-service APPLICATION_NAME \ + --user-config-json '{ + "service_type": "pg", + "exposed_values": { + "connection_string": { + "environment_variable_key": "DATABASE_URL" + } + } + }' +``` +Where: +- `PROJECT_NAME` is the name of your Aiven project. +- `source-service` is the name of the data service to connect. +- `dest-service` is the name of your application. +- `service_type` is the type of data service. For example, `pg` for PostgreSQL. +- `environment_variable_key` is the environment variable your application reads for the + connection URI. For other services, view the list of + [default variables](/docs/products/runtime/secrets-and-variables#default-environment-variables). + + + + + +Use the +`POST /v1/project/{project}/integration` endpoint. For example, to integrate +an existing PostgreSQL service with an application: + +```bash +curl -sS -X POST "https://api.aiven.io/v1/project/PROJECT_NAME/integration" \ + -H "Authorization: Bearer $AIVEN_TOKEN" \ + -H "Content-Type: application/json" \ + -d '{ + "integration_type": "application_service_credential", + "source_service": "prod-pg", + "dest_service": "web-app", + "user_config": { + "service_type": "pg", + "exposed_values": { + "connection_string": { + "environment_variable_key": "DATABASE_URL" + } + } + } + }' +``` + +Where: +- `PROJECT_NAME` is the name of your Aiven project. +- `source_service` is the name of the data service to integrate with your application. +- `dest_service` is the name of your application. +- `service_type` is the type of data service, for example `pg` for PostgreSQL. +- `environment_variable_key` is the environment variable your application reads for the + connection URI. For other services, view the list of + [default variables](/docs/products/runtime/secrets-and-variables#default-environment-variables). + + + + ## Connect a Karapace schema registry To connect services that are integrated with your application @@ -40,6 +114,9 @@ to a Karapace schema registry: ### Connect a schema registry during application creation + + + 1. In your project, click . 1. Click **Deploy application**. 1. Select or connect your **GitHub account**. @@ -55,22 +132,277 @@ to a Karapace schema registry: and add the connection details as environment variables. 1. To deploy the application, click **Deploy**. + + + +When you create the application, [connect the Kafka service](#connect-an-aiven-service) +and include the schema registry details in `application.environment_variables`. + +For example: + +```bash +avn service create example-application \ + --project example-project \ + --service-type application \ + --plan startup-50-1024 \ + --cloud aws-eu-west-1 \ + --user-config-json '{ + "application": { + "source": { + "repository_url": "REPOSITORY_URL", + "branch": "main", + "build_path": "./", + "containerfile_path": "Dockerfile" + }, + "environment_variables": [ + { + "key": "SCHEMA_REGISTRY_URL", + "value": "SCHEMA_REGISTRY_URI", + "kind": "variable" + }, + { + "key": "SCHEMA_REGISTRY_USER", + "value": "SCHEMA_REGISTRY_USER", + "kind": "variable" + }, + { + "key": "SCHEMA_REGISTRY_PASSWORD", + "value": "SCHEMA_REGISTRY_PASSWORD", + "kind": "secret" + } + ] + } + }' +``` + +Where: `SCHEMA_REGISTRY_URI`, `SCHEMA_REGISTRY_USER`, and `SCHEMA_REGISTRY_PASSWORD` +are the service URI, user, and password from the Kafka service Schema Registry +connection information. + + + + +When you create the application, [connect the Kafka service](#connect-an-aiven-service) +and include the schema registry details in `user_config.application.environment_variables`. + +For example: + +```bash +curl -sS -X POST "https://api.aiven.io/v1/project/example-project/service" \ + -H "Authorization: Bearer $AIVEN_TOKEN" \ + -H "Content-Type: application/json" \ + -d '{ + "service_name": "web-app", + "service_type": "application", + "plan": "startup-50-1024", + "cloud": "aws-eu-west-1", + "user_config": { + "application": { + "source": { + "repository_url": "REPOSITORY_URL", + "branch": "main", + "build_path": "./", + "containerfile_path": "Dockerfile" + }, + "environment_variables": [ + { + "key": "SCHEMA_REGISTRY_URL", + "value": "SCHEMA_REGISTRY_URI", + "kind": "variable" + }, + { + "key": "SCHEMA_REGISTRY_USER", + "value": "SCHEMA_REGISTRY_USER", + "kind": "variable" + }, + { + "key": "SCHEMA_REGISTRY_PASSWORD", + "value": "SCHEMA_REGISTRY_PASSWORD", + "kind": "secret" + } + ] + } + }, + "service_integrations": [ + { + "integration_type": "application_service_credential", + "source_service": "KAFKA_SERVICE_NAME", + "user_config": { + "service_type": "kafka", + "exposed_values": { + "bootstrap_servers": { "environment_variable_key": "KAFKA_BOOTSTRAP_SERVER" }, + "security_protocol": { "environment_variable_key": "KAFKA_SECURITY_PROTOCOL" }, + "access_key": { "environment_variable_key": "KAFKA_ACCESS_KEY" }, + "access_cert": { "environment_variable_key": "KAFKA_ACCESS_CERT" }, + "ca_cert": { "environment_variable_key": "KAFKA_CA_CERT" } + } + } + } + ] + }' +``` + +Where: + +- `KAFKA_SERVICE_NAME` is the connected Kafka service with Karapace enabled. +- `SCHEMA_REGISTRY_URI`, `SCHEMA_REGISTRY_USER`, and `SCHEMA_REGISTRY_PASSWORD` + are the service URI, user, and password from the Kafka service + Schema Registry connection information. + + + + ### Connect a schema registry to an existing application + + + 1. In your project, click . 1. Open your application. 1. In the **Environment variables** section, click **Edit**. 1. On the **Variables** tab, add the connection details as environment variables. 1. Click **Save**. + + + +Use the `avn service update` command. + +:::warning +This replaces the application's environment variables. +To keep the existing variables, include them in the `environment_variables` list. +To view a list of the existing environment variables, run +`avn service get APPLICATION_NAME`. +::: + +For example: + +```bash +avn service update example-application \ + --project example-project \ + -c 'application.environment_variables=[ + { + "key": "SCHEMA_REGISTRY_URL", + "value": "SCHEMA_REGISTRY_URI", + "kind": "variable" + }, + { + "key": "SCHEMA_REGISTRY_USER", + "value": "SCHEMA_REGISTRY_USER", + "kind": "variable" + }, + { + "key": "SCHEMA_REGISTRY_PASSWORD", + "value": "SCHEMA_REGISTRY_PASSWORD", + "kind": "secret" + } + ]' +``` + +Where: `SCHEMA_REGISTRY_URI`, `SCHEMA_REGISTRY_USER`, and `SCHEMA_REGISTRY_PASSWORD` +are the service URI, user, and password from the Kafka service Schema Registry +connection information. + + + + +Use the `PUT /v1/project/{project}/service/{service}` endpoint. + +:::warning +This replaces the application's environment variables. +To keep the existing variables, include them in the `environment_variables` list. +To view a list of the existing environment variables, call +`GET /v1/project/{project}/service/{service}`. +::: + +For example: + +```bash +curl -sS -X PUT "https://api.aiven.io/v1/project/PROJECT_NAME/service/example-application" \ + -H "Authorization: Bearer $AIVEN_TOKEN" \ + -H "Content-Type: application/json" \ + -d '{ + "user_config": { + "application": { + "environment_variables": [ + { + "key": "SCHEMA_REGISTRY_URL", + "value": "SCHEMA_REGISTRY_URI", + "kind": "variable" + }, + { + "key": "SCHEMA_REGISTRY_USER", + "value": "SCHEMA_REGISTRY_USER", + "kind": "variable" + }, + { + "key": "SCHEMA_REGISTRY_PASSWORD", + "value": "SCHEMA_REGISTRY_PASSWORD", + "kind": "secret" + } + ] + } + } + }' +``` + +Where: `SCHEMA_REGISTRY_URI`, `SCHEMA_REGISTRY_USER`, and `SCHEMA_REGISTRY_PASSWORD` +are the service URI, user, and password from the Kafka service Schema Registry +connection information. + + + + ## Disconnect an Aiven service + + + 1. In your project, click . 1. Open your application. 1. In the **Connected services** section, find the service to disconnect. 1. Click > **Disconnect service**. 1. Click **Disconnect** to confirm. + + + +1. Get the integration ID for the connected service using + the `service integration-list` command: + + ```bash + avn service integration-list APPLICATION_NAME --project PROJECT_NAME + ``` + +1. To remove the integration, run: + + ```bash + avn service integration-remove APPLICATION_NAME SERVICE_INTEGRATION_ID --project PROJECT_NAME + ``` + + + + +1. List integrations for the application and copy the `service_integration_id` + for the `application_service_credential` integration to remove: + + ```bash + curl -sS -X GET \ + "https://api.aiven.io/v1/project/PROJECT_NAME/service/APPLICATION_NAME/integration" \ + -H "Authorization: Bearer $AIVEN_TOKEN" + ``` + +1. Delete the integration: + + ```bash + curl -sS -X DELETE \ + "https://api.aiven.io/v1/project/PROJECT_NAME/integration/SERVICE_INTEGRATION_ID" \ + -H "Authorization: Bearer $AIVEN_TOKEN" + ``` + + + + ## Apply database schema changes Aiven Runtime does not automatically support pre-deploy commands or one-off task execution. diff --git a/docs/products/runtime/deploy-apps.md b/docs/products/runtime/deploy-apps.md index 3dd900760..55b389e18 100644 --- a/docs/products/runtime/deploy-apps.md +++ b/docs/products/runtime/deploy-apps.md @@ -6,6 +6,8 @@ import {ConsoleIcon} from "@site/src/components/ConsoleIcons"; import ConsoleLabel from "@site/src/components/ConsoleIcons"; import RequirementsPanel from "@site/src/components/RequirementsPanel"; import GitHubAccountVisibilityNote from "@site/static/includes/runtime-github-account-visibility-note.md"; +import Tabs from '@theme/Tabs'; +import TabItem from '@theme/TabItem'; Build and deploy applications using Aiven Runtime from source code in a GitHub repository. @@ -32,8 +34,43 @@ Build and deploy applications using Aiven Runtime from source code in a GitHub r +You cannot use Compose files to deploy applications through the Aiven API or Aiven MCP. +Use +[Containerfiles or Dockerfiles](/docs/products/runtime/manifest-files/containerfiles) instead. + +## Prerequisites + + + + +- A GitHub account + + + + +- The [Aiven CLI installed](/docs/tools/cli) +- [An Aiven token](/docs/platform/concepts/authentication-tokens) +- A [connected GitHub account](/docs/products/runtime/connect-github-account) + + + + +- [An Aiven token](/docs/platform/concepts/authentication-tokens) +- A [connected GitHub account](/docs/products/runtime/connect-github-account) + + + + ## Deploy an application + + + +:::important +When you connect a GitHub account to your Aiven organization, all users in that +organization can select that account in Aiven Runtime. +::: + 1. In your project, click . 1. Click **Deploy application**. 1. Select or connect your **GitHub account**. @@ -46,6 +83,179 @@ Build and deploy applications using Aiven Runtime from source code in a GitHub r . 1. To deploy the application and create the services, click **Deploy**. + + + +1. To choose a project, run: + + ```bash + avn project switch PROJECT_NAME + ``` + + Where `PROJECT_NAME` is the name of your Aiven project. + +1. Optional: Create data services for the app to use with the `avn service create` command. + The following example creates a PostgreSQL service: + + ```bash + avn service create example-postgres \ + --project PROJECT_NAME \ + -t pg \ + --cloud aws-eu-west-1 \ + --plan startup-4 + ``` + +1. Get your `VCS_INTEGRATION_ID` from the Aiven API. This is Aiven's ID + for the GitHub Aiven App installation linked to your organization when + you [connected your GitHub account](/docs/products/runtime/connect-github-account). + To get your ID, run: + + ```bash + curl -sS \ + "https://api.aiven.io/v1/organization/ORGANIZATION_ID/application/vcs-integrations" \ + -H "Authorization: Bearer $AIVEN_TOKEN" + ``` + + Where `ORGANIZATION_ID` is the + [Aiven organization ID](/docs/platform/reference/get-resource-IDs) the GitHub account + is connected to. + +1. Get the ID of the connected repository from the Aiven API. + To get the `REMOTE_REPOSITORY_ID`, run the following command using the + `VCS_INTEGRATION_ID`: + + ```bash + curl -sS \ + "https://api.aiven.io/v1/organization/ORGANIZATION_ID/application/vcs-integrations/VCS_INTEGRATION_ID/repositories" \ + -H "Authorization: Bearer $AIVEN_TOKEN" + ``` + +1. To create the application, run the following: + + ```bash + avn service create example-app \ + --project PROJECT_NAME \ + -t application \ + --cloud aws-eu-west-1 \ + --plan startup-50-1024 \ + -c application.source.vcs_integration_id=VCS_INTEGRATION_ID \ + -c application.source.remote_repository_id=REMOTE_REPOSITORY_ID \ + -c application.source.repository_url=REPOSITORY_URL \ + -c application.source.branch=BRANCH_NAME \ + -c application.source.build_path=. \ + -c application.source.containerfile_path=Dockerfile \ + -c 'application.ports=[{"name":"http","port":8080,"protocol":"HTTP"}]' \ + ``` + + Where: + - `VCS_INTEGRATION_ID` is the GitHub Aiven app ID. + - `REMOTE_REPOSITORY_ID` is the ID of the connected repository. + - `REPOSITORY_URL` is the URL of the connected repository. + - `BRANCH_NAME` is the branch to deploy. + + + To use a project VPC, add `--project-vpc-id VPC_ID`. + +1. Optional: Integrate your data services with the app. + For example, to integrate the PostgreSQL service with the app, run: + + ```bash + avn service integration-create \ + --project PROJECT_NAME \ + -t application_service_credential \ + -s example-postgres \ + -d example-app \ + --user-config-json '{"service_type":"pg","exposed_values":{"connection_string":{"environment_variable_key":"DATABASE_URL"}}}' + ``` + +:::tip +To check the status of your services or applications, run +`avn service wait SERVICE_NAME --project PROJECT_NAME`. +::: + + + + +1. Optional: Create data services to integrate with your application using the + `POST /v1/project/{project}/service` endpoint. For example, the following + creates Aiven for PostgreSQL® service: + + ```bash + curl -sS -X POST "https://api.aiven.io/v1/project/example-project/service" \ + -H "Authorization: Bearer $AIVEN_TOKEN" \ + -H "Content-Type: application/json" \ + -d '{ + "service_name": "example-postgres-service", + "service_type": "pg", + "plan": "startup-4", + "cloud": "aws-eu-west-1" + }' + ``` + +1. To create the application, use the `POST/v1/project/{project}/service` endpoint. The + following example deploys an application, sets environment variables, and integrates + the app with an existing PostgreSQL service: + + ```bash + curl -sS -X POST \ + "https://api.aiven.io/v1/project/PROJECT_NAME/service" \ + -H "Authorization: Bearer $AIVEN_TOKEN" \ + -H "Content-Type: application/json" \ + -d '{ + "service_name": "example-app", + "service_type": "application", + "cloud": "aws-eu-west-1", + "plan": "startup-50-1024", + "user_config": { + "application": { + "source": { + "repository_url": "REPOSITORY_URL", + "branch": "BRANCH_NAME", + "build_path": "./", + "containerfile_path": "Dockerfile" + }, + "ports": [ + { "name": "http", "port": 8080, "protocol": "HTTP" } + ], + "environment_variables": [ + { "key": "LOG_LEVEL", "value": "INFO", "kind": "variable" }, + { "key": "API_KEY", "value": "secret", "kind": "secret" } + ] + } + }, + "service_integrations": [ + { + "integration_type": "application_service_credential", + "source_service": "example-postgres-service", + "user_config": { + "service_type": "pg", + "exposed_values": { + "connection_string": { + "environment_variable_key": "DATABASE_URL" + } + } + } + } + ] + }' + ``` + + Where: + - `PROJECT_NAME` is the name of your Aiven project. + - `REPOSITORY_URL` is the URL of the connected repository. + - `BRANCH_NAME` is the branch to deploy. + - `containerfile_path`: Use the repository-relative path for your + Dockerfile or Containerfile. For example, `./Dockerfile` or `./api/Dockerfile.prod`. + - `build_path` is the build context and defaults to `./.`. + If you set `build_path` and omit `containerfile_path`, Aiven searches that directory + for a Dockerfile/Containerfile. + - `source_service` is the name of the service to integrate with the application. + + To use a project VPC, add `"project_vpc_id": "VPC_ID"`. + + + + ## Redeploy an application When you redeploy an application, Aiven deploys the latest commit from diff --git a/external/terraform-provider b/external/terraform-provider index 6031bbfca..c8d7f0f7f 160000 --- a/external/terraform-provider +++ b/external/terraform-provider @@ -1 +1 @@ -Subproject commit 6031bbfcafd3fb866a6772458c793dba302af29d +Subproject commit c8d7f0f7f1e63eec772ecef9057481f6f324ba6e