This sample demonstrates how to build and deploy an ASP.NET-based microservice as an extension and expose the API in SAP BTP, Kyma runtime.
You can find the application code in the sample-extension-dotnet directory.
This sample demonstrates how to:
- Create a development Namespace in the Kyma runtime.
- Create and deploy an ASP.NET application in the Kyma runtime.
- Expose the ASP.NET application using APIRules.
- Call the APIs.
- SAP BTP, Kyma runtime instance
- Docker
- make
- kubectl configured to use the
KUBECONFIG
file downloaded from the Kyma runtime
-
Create a new
dev
Namespace:kubectl create namespace dev
-
Build and push the image to the Docker repository:
DOCKER_ACCOUNT={your-docker-account} make push-image
-
Update the image name in the Kubernetes Deployment. Refer to the standard Kubernetes Deployment and Service definitions.
This section details out deploying the extension using standard Kubernetes resources.
To deploy as Helm chart, please refer to Helm Chart Deployment
-
Deploy the application:
kubectl -n dev apply -f ./k8s/deployment.yaml
-
Verify that the Pods are up and running:
kubectl -n dev get po -l app=sample-extension-dotnet
The expected result shows that the Pod for the sample-extension-dotnet
Deployment is running:
kubectl -n dev get po -l app=sample-extension-dotnet
NAME READY STATUS RESTARTS AGE
sample-extension-dotnet-774fbc5c7b-x44pd 2/2 Running 0 15s
-
Create an APIRule. In the APIRule, specify the Kubernetes Service that is exposed:
apiVersion: gateway.kyma-project.io/v1alpha1 kind: APIRule metadata: name: sample-extension-dotnet spec: gateway: kyma-gateway.kyma-system.svc.cluster.local rules: - accessStrategies: - config: {} handler: noop methods: - GET - POST - PUT - DELETE path: /.* service: host: sample-extension-dotnet name: sample-extension-dotnet port: 80
This sample snippet exposes the
sample-extension-dotnet
Service. The Service is specified in the spec.service.name field. Thesample-extension-dotnet
subdomain is specified in the spec.service.host field. -
Apply the APIRule:
kubectl -n dev apply -f ./k8s/api-rule.yaml
A Helm Chart definition is also available for developers to try out.
-
To install the helm chart in
dev
namespace, run the following command. Change to use your image.helm install kymaapp ../helm-charts/sample-extension-dotnet --set image.repository=gabbi/sample-extension-dotnet:0.0.1 -n dev
-
To verify, the installed chart, run
helm -n dev ls
NAME NAMESPACE REVISION UPDATED STATUS CHART APP VERSION dev-gateway dev 1 2020-09-14 17:34:58.607853163 +0000 UTC deployed gateway-0.0.1 kymaapp dev 1 2020-09-15 15:18:34.502591 +0200 CEST deployed sample-extension-dotnet-0.1.0 1.16.0
-
Access the APIs through this URL:
https://sample-extension-dotnet.{cluster domain}
-
Make an HTTP call using curl:
curl https://sample-extension-dotnet.{cluster domain} Hello from dotnet app running on Kyma Runtime