Run a CAP Application on Kyma
You can follow all the steps outlined here without having to install anything else if you use this mentioned VS Dev Container.
This walkthrough only provides my additional quidance for this awesome tutorial from SAP.
Run the CAP application locally in a Dev Container
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 .
2
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)
2
3
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)
2
3
Run Your CAP Service
Check for the created container
Attach Shell
Check for your files: commad ls
Run the container using the side bar of VS Code
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
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
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.
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
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
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
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
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
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
2
3
4
Issue: It don't see this expected output
Forwarding from 127.0.0.1:5000 -> 5000
Forwarding from [::1]:5000 -> 5000
2