Run a CAP Application on Kyma

Run the CAP application locally in a Dev Container

Dev Container for CAP on Kyma

Start the CAP app in a separate folder with the command "code ."

node ➜ /workspaces/vsc-sap-hana-mta-dev-env-node14x/cap-kyma-app (main ✗)
$ code .  
1
2

CAP folder

Build the docker image locally

node ➜ /workspaces/vsc-sap-hana-mta-dev-env-node14x/cap-kyma-app (main ✗)
$ docker build -t cpapp . 
    --> Image: cpapp:latest (030cbbeca7fb)   
1
2
3

Check for the image via VS Code

Run the Docker Container

You can run the docker container and look inside its contents

node ➜ /workspaces/vsc-sap-hana-mta-dev-env-node14x/cap-kyma-app (main ✗)
$ docker run -p 4004:4004 -t cpapp 
    --> Image: cpapp:latest (030cbbeca7fb)   
1
2
3

Run Your CAP Service

Check for the created container

Attach Shell

attach-shell-cap-kyma-app

Check for your files: commad ls

ls-attach-shell-cap-kyma-app

Run the container using the side bar of VS Code

run-container-locally-cap-kyma-app

open-in-browser-shell

browser-shell-cap-kyma

Deploy to Kyma

Log In to Kyma (Kubernetes Cluster)

Get your Kubeconfig as described (CF Login required)

Update your kubeconfig.yml (keep in mind, secrets on Kyma are changing all 8 hours (I guess))

node ➜ /workspaces/vsc-sap-hana-mta-dev-env-node14x/cap-kyma-app (main ✗)
$ env | grep KUBECONFIG
KUBECONFIG=/usr/local/share/kube-devcontainer/kubeconfig.yml   
1
2
3

Maybe you want to establish a CLI connection

cf login -a https://api.cf.eu10.hana.ondemand.com -u email -p psw --skip-ssl-validation
1

Check for your pods, if you have any

node ➜ /workspaces/vsc-sap-hana-mta-dev-env-node14x/cap-kyma-app (main ✗)
$ kubectl get pods
No resources found in default namespace.
1
2
3

Check for your namespaces

node ➜ /workspaces/vsc-sap-hana-mta-dev-env-node14x/cap-kyma-app (main ✗)
$ kubectl get namespaces
NAME               STATUS   AGE
compass-system     Active   8d
default            Active   8d
1
2
3
4
5

Prepare the Docker Registry as described

Add the stable Helm Chart repository to the helm CLI

node ➜ /workspaces/vsc-sap-hana-mta-dev-env-node14x/cap-kyma-app (main ✗)
$ helm repo add stable https://charts.helm.sh/stable
1
2

Install the Helm Chart for a docker registry

node ➜ /workspaces/vsc-sap-hana-mta-dev-env-node14x/cap-kyma-app (main ✗)
$ helm install docker-registry stable/docker-registry
1
2

You need to make the docker registry available on the public internet. The details to this step are explained later. Run the following commands

node ➜ /workspaces/vsc-sap-hana-mta-dev-env-node14x/cap-kyma-app (main ✗) 
$ kubectl apply -f - <<EOF
apiVersion: gateway.kyma-project.io/v1alpha1
kind: APIRule
metadata:
  labels:
    app: docker-registry
  name: docker-registry
spec:
  service:
    host: docker-registry
    name: docker-registry
    port: 5000
  gateway: kyma-gateway.kyma-system.svc.cluster.local
  rules:
    - path: /.*
      methods: ["GET", "HEAD" ]
      accessStrategies:
        - handler: noop
      mutators: []
EOF
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21

Push the docker image (my journey comes to the end)

node ➜ /workspaces/vsc-sap-hana-mta-dev-env-node14x/cap-kyma-app (main ✗)
$ kubectl port-forward deployment/docker-registry 5000:5000 &
[1] 6219

node ➜ /workspaces/vsc-sap-hana-mta-dev-env-node14x/cap-kyma-app (main ✗) 
my output:
Forwarding from 127.0.0.1:5000 -> 5000
1
2
3
4
5
6
7

Issue: connection refused

node ➜ /workspaces/vsc-sap-hana-mta-dev-env-node14x/cap-kyma-app (main ✗)
$ docker push 0.0.0.0:5000/cpapp
The push refers to repository [0.0.0.0:5000/cpapp]
Get http://0.0.0.0:5000/v2/: dial tcp 0.0.0.0:5000: connect: connection refused
1
2
3
4

Issue: It don't see this expected output

Forwarding from 127.0.0.1:5000 -> 5000
Forwarding from [::1]:5000 -> 5000
1
2

Issue Push Image failed

Any help to solve the problem would be great

Issue Push Image failed