头图

Before reading this article, Jerry assumes that you have read this Run Microsoft SQL Server in Docker.

Local project address: C:\Code\referenceCode\SAP Kyma tutorial example

Reference link: https://developers.sap.com/tutorials/cp-kyma-mssql-deployment.html#42706edb-619b-43f4-9b3e-3179f149e565

secret.yaml

The user name and password of the database are defined.

pvc.yaml

A PersistentVolume is defined to store data in the database.

deployment.yaml

defines the Deployment definition for the MSSQL database as well as a Service used for communication. This definition references both the secret.yaml and pvc.yaml by name.

Use this article how to use kubectl SAP Kyma operation by the command line mentioned method, configured and connected kubectl of SAP Kyma.

Use the command line to create a namespace named dev:

kubectl create namespace dev

Deploy secret.yaml and pvc.yaml:

kubectl -n dev apply -f ./k8s/pvc.yaml

Note that if you encounter the following error messages:

error: you must be logged in to the server ( the server has asked for the client to provide credentials):

The solution is to download a copy of kubeconfig from the Kyma console:

Successfully deployed PersistentVolumeClaim: persistentvolumeclaim/mssql-data created

Successfully deploy secret:

Finally, use the following command to deploy the deployment resource represented by the yaml file in the local k8s folder to SAP Kyma:

After the deployment is successful, use the command line to view the automatically generated pod name:

My pod name: mssql-74787d5b48-lr877

Kubernetes provides a port-forward functionality that allows you to connect to resources running in the Kyma runtime locally. This can be useful for development and debugging tasks.

Use the following command line to get the port number monitored by the pod:

kubectl get pod mssql-74787d5b48-lr877 -n dev --template="{{(index (index .spec.containers 0).ports 0).containerPort}}"

Get the port number: 1433

Use the following command to set up port forwarding for the pod, that is, the port forward function:

kubectl port-forward mssql-74787d5b48-lr877 -n dev 1433:1433

You see the following output:

Forwarding from 127.0.0.1:1433 -> 1433
Forwarding from [::1]:1433 -> 1433

Next, we can use localhost:1433 to access the database running in SAP Kyma locally.

sqlcmd -S localhost:1433 -U SA -P Yukon900

Use the following command to find the container name in the pod: mssql

kubectl describe pod mssql-74787d5b48-lr877 -n dev

Use the command

kubectl exec -it mssql-74787d5b48-lr877 -n dev -c mssql -- bash

Need to set environment variables in advance: set KUBECONFIG=C:\app\kubeconfig.yml


More original articles by Jerry, all in: "Wang Zixi":


注销
1k 声望1.6k 粉丝

invalid