把运行在 Docker 容器内的 Microsoft SQL 服务器部署到 SAP Kyma 中
在閱讀這篇文章之前,Jerry 假設您已經(jīng)讀過了這篇在 Docker 里運行 Microsoft SQL 服務器。
本地項目地址:C:\Code\referenceCode\SAP Kyma教程例子
參考鏈接:https://developers.sap.com/tutorials/cp-kyma-mssql-deployment.html#42706edb-619b-43f4-9b3e-3179f149e565
secret.yaml
定義了數(shù)據(jù)庫的用戶名和密碼。
pvc.yaml
定義了一個 PersistentVolume,用于存儲數(shù)據(jù)庫的數(shù)據(jù)。
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 的連接。
使用命令行創(chuàng)建名為 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 監(jiān)聽的端口號:
kubectl get pod mssql-74787d5b48-lr877 -n dev --template="{{(index (index .spec.containers 0).ports 0).containerPort}}"
得到端口號:1433
使用如下命令為 pod 設置端口轉發(fā),即 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 里的數(shù)據(jù)庫了。
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
需要提前設置環(huán)境變量:set KUBECONFIG=C:\app\kubeconfig.yml
更多Jerry的原創(chuàng)文章,盡在:“汪子熙”:
總結
以上是生活随笔為你收集整理的把运行在 Docker 容器内的 Microsoft SQL 服务器部署到 SAP Kyma 中的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 印度捷行航空申请破产 原因想不到:普惠发
- 下一篇: 安装 Microsoft Command