writing-skills
writing-skills
Use when creating new skills, editing existing skills, or verifying skills work before deployment
sap-kyma-runtimeSAP BTP Kyma Runtime skill for Kubernetes-based extension development. Use when deploying microservices to Kyma, creating serverless Functions, configuring API Rules, setting up BTP service bindings, or building event-driven extensions. If the user mentions Kyma, Kubernetes on BTP, Kyma Function, API Rule, or Istio service mesh, use this skill.
Independent GitHub snapshot · Automated classification · Original documentation governs
sap-s4hana-extensibility — S/4HANA events and APIs consumed by Kyma extensionssap-devops-cicd — CI/CD pipelines for Kyma deploymentssap-security-authorization — XSUAA/IAS integration for Kyma workloadssap-cap-advanced — Deploying CAP applications on Kymasap-event-mesh — Event-driven Kyma Functions consuming SAP eventsChoose your extension pattern:
| Scenario | Approach | Key Artifact |
|---|---|---|
| Lightweight webhook / event handler | Kyma Function (serverless) | Function CR |
| Full microservice | Kubernetes Deployment | Deployment + Service + APIRule |
| Scheduled job | Kubernetes CronJob | CronJob CR |
| Event-driven extension | Function + Event subscription | Subscription CR |
| Helm-based app | Helm chart | Chart.yaml + templates |
Minimal Kyma Function:
apiVersion: serverless.kyma-project.io/v1alpha2
kind: Function
metadata:
name: order-handler
namespace: default
spec:
runtime: nodejs20
source:
inline:
source: |
module.exports = {
main: async function (event, context) {
const order = event.data;
console.log('Order received:', order.OrderID);
return { statusCode: 200, body: { status: 'processed' } };
}
};
dependencies: |
{ "name": "order-handler", "version": "1.0.0", "dependencies": {} }
| CR | Purpose | Module |
|---|---|---|
Function | Serverless function | Serverless |
APIRule | Expose service externally (Istio Gateway) | API Gateway |
Subscription | Subscribe to SAP/custom events | Eventing |
ServiceInstance | Provision BTP service | BTP Operator |
ServiceBinding | Bind BTP service to workload | BTP Operator |
default — Quick prototyping onlyproduction / staging — Separate by environmentistio-injection=enabled for mesh# service-instance.yaml — provision XSUAA
apiVersion: services.cloud.sap.com/v1
kind: ServiceInstance
metadata:
name: xsuaa-instance
spec:
serviceOfferingName: xsuaa
servicePlanName: application
parameters:
xsappname: order-service
tenant-mode: dedicated
scopes:
- name: $XSAPPNAME.OrderRead
description: Read orders
role-templates:
- name: OrderViewer
scope-references:
- $XSAPPNAME.OrderRead
---
# service-binding.yaml
apiVersion: services.cloud.sap.com/v1
kind: ServiceBinding
metadata:
name: xsuaa-binding
spec:
serviceInstanceName: xsuaa-instance
secretName: xsuaa-credentials
# deployment.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
name: order-service
spec:
replicas: 2
selector:
matchLabels:
app: order-service
template:
metadata:
labels:
app: order-service
spec:
containers:
- name: order-service
image: myregistry.io/order-service:1.0.0
ports:
- containerPort: 8080
envFrom:
- secretRef:
name: xsuaa-credentials
resources:
requests:
memory: "128Mi"
cpu: "100m"
limits:
memory: "256Mi"
cpu: "500m"
livenessProbe:
httpGet:
path: /health
port: 8080
initialDelaySeconds: 10
---
apiVersion: v1
kind: Service
metadata:
name: order-service
spec:
selector:
app: order-service
ports:
- port: 80
targetPort: 8080
apiVersion: gateway.kyma-project.io/v1beta1
kind: APIRule
metadata:
name: order-api
spec:
host: order-api
service:
name: order-service
port: 80
gateway: kyma-system/kyma-gateway
rules:
- path: /orders.*
methods: ["GET", "POST"]
accessStrategies:
- handler: jwt
config:
jwks_urls:
- https://<subaccount>.authentication.<region>.hana.ondemand.com/token_keys
trusted_issuers:
- https://<subaccount>.authentication.<region>.hana.ondemand.com
- path: /health
methods: ["GET"]
accessStrategies:
- handler: noop
apiVersion: eventing.kyma-project.io/v1alpha2
kind: Subscription
metadata:
name: order-created-sub
spec:
sink: http://order-handler.default.svc.cluster.local
source: sap.s4.beh/ER9
types:
- sap.s4.beh.businesspartner.v1.BusinessPartner.Created.v1
typeMatching: standard
apiVersion: services.cloud.sap.com/v1
kind: ServiceInstance
metadata:
name: dest-instance
spec:
serviceOfferingName: destination
servicePlanName: lite
---
apiVersion: services.cloud.sap.com/v1
kind: ServiceBinding
metadata:
name: dest-binding
spec:
serviceInstanceName: dest-instance
secretName: dest-credentials
// Node.js — call S/4HANA via Destination Service
const { getDestination, executeHttpRequest } = require('@sap-cloud-sdk/connectivity');
async function getBusinessPartners() {
const dest = await getDestination({ destinationName: 'S4HANA_SYSTEM' });
const response = await executeHttpRequest(dest, {
method: 'GET',
url: '/sap/opu/odata/sap/API_BUSINESS_PARTNER/A_BusinessPartner?$top=10'
});
return response.data;
}
my-extension/
├── Chart.yaml
├── values.yaml
└── templates/
├── deployment.yaml
├── service.yaml
├── apirule.yaml
└── service-binding.yaml
# Deploy with Helm
helm upgrade --install my-extension ./my-extension \
--namespace production \
--set image.tag=1.2.0 \
--set replicas=3
| Error | Message | Root Cause | Fix |
|---|---|---|---|
Function CrashLoopBackOff | Runtime error in function code | Syntax error or missing dependency | Check logs: kubectl logs -n default -l serverless.kyma-project.io/function-name=<name> |
APIRule ERROR | VirtualService creation failed | Duplicate host or invalid gateway | Ensure unique host; verify gateway exists: kubectl get gateways -n kyma-system |
ServiceBinding failed | Could not find service instance | Instance not ready or wrong name | Check kubectl get serviceinstances; wait for Ready status |
Subscription NATS error | No events received | Wrong event type string or source | Match exact type from SAP Event Catalog; check eventing module is enabled |
ImagePullBackOff | unauthorized: authentication required | Registry credentials missing | Create imagePullSecret and reference in Deployment spec |
OOMKilled | Container killed by OOM | Memory limit too low | Increase resources.limits.memory; profile actual usage first |
100m CPU / 128Mi memory, scale based on metricsHorizontalPodAutoscaler on CPU/memory or custom metricsminReplicas: 1 for latency-sensitive FunctionsPodDisruptionBudget for critical services during node upgradesKyma CR before useNetworkPolicy for production isolation