http-db-service

command
v0.0.0-...-5552a58 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 20, 2024 License: Apache-2.0 Imports: 10 Imported by: 0

README

HTTP DB Service

Overview

This example demonstrates Kyma capabilities, such as HTTP endpoints that expose and bind a service to a database. The service in this example exposes HTTP endpoints used to create and read basic order JSON entities, as described in the service's API descriptor. The service can run with either an in-memory database or an MSSQL instance. By default, the in-memory database is enabled. The service in this example uses Go.

Prerequisites

  • A Docker installation.
  • Kyma as the target deployment environment.
  • An MSSQL database for the service's database functionality. You can also use Azure MSSQL that you can provision using the Kyma Open Service Broker API.
  • Golang and dep installed.

Installation

Use these commands to build and run the service with Docker:

./build.sh
docker run -it --rm -p 8017:8017 http-db-service:latest

To run the service with an MSSQL database, use the DbType=mssql environment variable in the application. To configure the connection to the database, set the environment variables for the values defined in the config/db.go file.

The deployment folder contains .yaml descriptors used for the deployment of the service to Kyma.

Run the following commands to deploy the published service to Kyma:

  1. Export your Namespace as variable by replacing the {namespace} placeholder in the following command and running it:

    export K8S_NAMESPACE="{namespace}"
    
  2. Deploy the service:

    kubectl create namespace $K8S_NAMESPACE
    kubectl apply -f deployment/deployment.yaml -n $K8S_NAMESPACE
    
MSSQL Database tests

To run the unit tests on a real MSSQL database, run the following command on the root of the example:

docker run -ti -e 'ACCEPT_EULA=Y' -e 'SA_PASSWORD=Password!123' -p 1433:1433 -d microsoft/mssql-server-linux:2017-latest

The command starts a MSSQL database in a container.

username=sa password='Password!123' database=main tablename='test_orders' host=localhost port=1433 dbtype=mssql go test ./... -v

The command runs the specific unit tests for MSSQL databases with the environment information to connect to the previously started MSSQL database.

Cleanup

Run the following command to completely remove the example and all its resources from the cluster:

kubectl delete all -l example=http-db-service -n $K8S_NAMESPACE

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis
internal
repository
Code generated by mockery v1.0.0.
Code generated by mockery v1.0.0.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL