Develop a Service¶
Choreo allows you to create and deploy applications in your preferred programming language.
In this guide, you will:
- Build a simple greeting service using a sample service implementation. The sample implementation will have a single resource named
greet
that accepts a single query parameter as input. - Deploy the service in Choreo using a
Go
buildpack. The service will run on port 9090. - Test the service.
Prerequisites¶
-
If you're signing in to the Choreo Console for the first time, create an organization:
- Go to https://console.choreo.dev/ and sign in using your preferred method.
- Enter a unique organization name. For example,
Stark Industries
. - Read and accept the privacy policy and terms of use.
- Click Create.
This creates the organization and opens the Project Home page of the default project created for you.
-
Fork the Choreo samples repository, which contains the sample greetings service implementation in
Go
.
Learn the repository file structure¶
It is important to understand the purpose of the key files in the sample service. The following table provides a brief overview of each file in the greeter service:
Note
The specified file paths are relative to <sample-repository-dir>/greeting-service-go
.
Filepath | Description |
---|---|
main.go |
The Go-based greeter service code. |
.choreo/component.yaml |
Choreo-specific configuration that provides information about how Choreo exposes the service. |
openapi.yaml |
The OpenAPI contract of the greeter service. This is required to publish the service as a managed API. This openapi.yaml file is referenced by the .choreo/component.yaml file. |
Configure the service port with endpoints¶
In Choreo, you can expose your services via endpoints. To run the greeter service on port 9090 and securely expose it through Choreo, you must provide the port and other required information in the component.yaml
file. For detailed information on each attribute of an endpoint, see Configure Endpoints.
In the greeter sample, the component.yaml
file is located in the greeting-service-go/.choreo/
directory.
Step 1: Create a service component¶
To create a containerized service component, follow these steps:
- Go to https://console.choreo.dev/ and sign in. This opens the project home page.
- If you already have one or more components in your project, click + Create. Otherwise, proceed to the next step.
- Click the Service card.
-
Enter the following details:
Info
The Component Name field must be unique and cannot be changed after creation.
Field Value Component Display Name Greetings Component Name greetings Description Send greetings -
Go to the GitHub tab.
-
Click Authorize with GitHub to connect Choreo to your GitHub account. If you haven't connected your GitHub repository to Choreo, enter your credentials and select the repository you forked earlier to install the Choreo GitHub App.
Alternatively, paste the Choreo samples repository URL in the Provide Repository URL field. However, enabling Auto Deploy requires authorizing the repository with the Choreo GitHub App.
Note
The Choreo GitHub App requires: - Read and write access to code and pull requests. - Read access to issues and metadata.
You can revoke access at any time. Write access is only used for sending pull requests; Choreo will not push changes directly to your repository.
-
Under Connect Your Repository, enter the following details:
Field Value Organization Your GitHub account GitHub Repository choreo-samples Branch main -
Select Go as the buildpack.
-
Enter the following details:
Field Value Go Project Directory /greeting-service-go
Language Version 1.x -
Click Create. This creates the component and lists it under Component Listing on the project home page.
You have successfully created the service. The next step is to build and deploy it.
Step 2: Build and deploy¶
Now that you have connected the source repository and configured the endpoint details, it's time to build and deploy the greeter service.
Step 2.1: Build¶
- On the project home page, click on the
Greetings
component you created. This takes you to the component overview page. - In the left navigation menu, click Build.
-
On the Build page, click Build Latest.
Note
The build process may take some time. You can track progress in the Build Details pane. Once complete, the build status changes to Success.
Step 2.2: Deploy¶
- In the left navigation menu, click Deploy.
- On the Set Up card, click Configure & Deploy.
- In the Environment Configurations pane, click Next to skip the configuration.
- In the File Mount pane, click Next to skip the configuration.
-
Review the Endpoint Details and click Deploy.
Note
Deploying the service component may take some time. Once deployed, the Development environment card indicates the Deployment Status as Active.
Once you have successfully deployed the service, you can test, manage, and observe it like any other component type in Choreo.