关于docker:把运行在-Docker-容器内的-Microsoft-SQL-服务器部署到-SAP-Kyma-中

8次阅读

共计 1576 个字符,预计需要花费 4 分钟才能阅读完成。

在浏览这篇文章之前,Jerry 假如您曾经读过了这篇在 Docker 里运行 Microsoft SQL 服务器。

本地我的项目地址:C:\Code\referenceCode\SAP Kyma 教程例子

参考链接:https://developers.sap.com/tu…

secret.yaml

定义了数据库的用户名和明码。

pvc.yaml

定义了一个 PersistentVolume,用于存储数据库的数据。

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.

应用这篇文章如何应用 kubectl 通过命令行的形式操作 SAP Kyma 提到的办法,配置好 kubectl 和 SAP Kyma 的连贯。

应用命令行创立名为 dev 的 namespace:

kubectl create namespace dev

部署 secret.yaml 和 pvc.yaml:

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

留神,如果遇到下列谬误音讯:

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

解决办法就是从 Kyma 控制台从新下载一份 kubeconfig:

胜利部署 PersistentVolumeClaim:persistentvolumeclaim/mssql-data created

胜利部署 secret:

最初应用如下命令,将本地 k8s 文件夹里的 yaml 文件代表的 deployment 资源,部署到 SAP Kyma 上:

部署胜利后,应用命令行查看主动生成的 pod 的名称:

我的 pod 名称: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.

应用如下命令行拿到该 pod 监听的端口号:

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

失去端口号:1433

应用如下命令为 pod 设置端口转发,即 port forward 性能:

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

看到如下输入:

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

接下来,咱们就能够在本地,应用 localhost:1433 拜访运行在 SAP Kyma 里的数据库了。

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

应用如下命令找到 pod 里的 container 名称:mssql

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

应用命令

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

须要提前设置环境变量:set KUBECONFIG=C:\app\kubeconfig.yml


更多 Jerry 的原创文章,尽在:” 汪子熙 ”:

正文完
 0