在 Openshift 期间安装 pyodbc Build/Deployment
Installing pyodbc during Openshift Build/Deployment
在我的 Openshift 部署中安装 pyodbc 时出现错误。有许多线程解释了解决方案,包括这个:
错误:
Building wheel for pyodbc (setup.py): started
Building wheel for pyodbc (setup.py): finished with status 'error'
error: subprocess-exited-with-error
× python setup.py bdist_wheel did not run successfully.
│ exit code: 1
╰─> [10 lines of output]
running bdist_wheel
running build
running build_ext
building 'pyodbc' extension
In file included from src/buffer.cpp:12:0:
src/pyodbc.h:56:17: fatal error: sql.h: No such file or directory
#include <sql.h>
^
compilation terminated.
error: command '/usr/bin/gcc' failed with exit code 1
[end of output]
note: This error originates from a subprocess, and is likely not a problem with pip.
ERROR: Failed building wheel for pyodbc
我的问题是:如何在我的部署中启动 apt 安装(或 sudo)?
我正在使用 OpenShift GUI。
我正在使用 requirements.txt 强制安装所有依赖项的 PIP:
pandas
numpy
dash
dash_core_components
dash_html_components
plotly.express
dash
plotly
sqlalchemy
matplotlib
pyodbc
powershift-image
构建的 YAML 内容:
kind: BuildConfig
apiVersion: build.openshift.io/v1
metadata:
annotations:
app.openshift.io/vcs-ref: master
app.openshift.io/vcs-uri: >-
ssh://git@sourcecode.xxdeletedxx_reports.git
openshift.io/generated-by: OpenShiftWebConsole
selfLink: >-
/apis/build.openshift.io/v1/namespaces/ci-testline-analysis-adp/buildconfigs/adp-testline-reports-git
resourceVersion: '319828205'
name: adp-testline-reports-git
uid: 6d2f69e9-8d8d-4c72-bdc0-5838be4649d9
creationTimestamp: '2022-02-08T18:30:16Z'
managedFields:
- manager: Mozilla
operation: Update
apiVersion: build.openshift.io/v1
time: '2022-02-08T20:25:20Z'
fieldsType: FieldsV1
fieldsV1:
'f:metadata':
'f:annotations':
.: {}
'f:app.openshift.io/vcs-ref': {}
'f:app.openshift.io/vcs-uri': {}
'f:openshift.io/generated-by': {}
'f:labels':
.: {}
'f:app': {}
'f:app.kubernetes.io/component': {}
'f:app.kubernetes.io/instance': {}
'f:app.kubernetes.io/name': {}
'f:app.kubernetes.io/part-of': {}
'f:app.openshift.io/runtime': {}
'f:app.openshift.io/runtime-version': {}
'f:spec':
'f:output':
'f:to':
.: {}
'f:kind': {}
'f:name': {}
'f:runPolicy': {}
'f:source':
'f:contextDir': {}
'f:git':
.: {}
'f:ref': {}
'f:uri': {}
'f:sourceSecret':
.: {}
'f:name': {}
'f:type': {}
'f:strategy':
'f:sourceStrategy':
.: {}
'f:env': {}
'f:from':
.: {}
'f:kind': {}
'f:name': {}
'f:namespace': {}
'f:type': {}
- manager: openshift-apiserver
operation: Update
apiVersion: build.openshift.io/v1
time: '2022-02-10T14:04:32Z'
fieldsType: FieldsV1
fieldsV1:
'f:spec':
'f:triggers': {}
'f:status':
'f:lastVersion': {}
namespace: ci-testline-analysis-adp
labels:
app: adp-testline-reports-git
app.kubernetes.io/component: adp-testline-reports-git
app.kubernetes.io/instance: adp-testline-reports-git
app.kubernetes.io/name: python
app.kubernetes.io/part-of: TestLine-Report
app.openshift.io/runtime: python
app.openshift.io/runtime-version: 3.8-ubi7
spec:
nodeSelector: null
output:
to:
kind: ImageStreamTag
name: 'adp-testline-reports-git:latest'
resources: {}
successfulBuildsHistoryLimit: 5
failedBuildsHistoryLimit: 5
strategy:
type: Source
sourceStrategy:
from:
kind: ImageStreamTag
namespace: openshift
name: 'python:3.8-ubi7'
env:
- name: APP_FILE
value: main.py
postCommit: {}
source:
type: Git
git:
uri: >-
ssh://git@sourcecode.xxdeletedxx_reports.git
ref: master
contextDir: /
sourceSecret:
name: openshift-key-socialcoding
triggers:
- type: Generic
generic:
secretReference:
name: adp-testline-reports-git-generic-webhook-secret
- type: ImageChange
imageChange:
lastTriggeredImageID: >-
image-registry.openshift-image-registry.svc:5000/openshift/python@sha256:c5d24000000000000000000000
- type: ConfigChange
runPolicy: Serial
status:
lastVersion: 15
为了解决我的问题,我必须创建自定义 Docker 文件并将应用程序作为 Docker 映像部署到 OpenShift 中。具体来说,我在 GUI 中使用了 add --> from Dockerfile 而不是 add--> Import from Git (Python builder image)。
从 Git 导入方法不允许足够的灵活性来安装所有需要的包。 (pyodbc 等)
在我的 Openshift 部署中安装 pyodbc 时出现错误。有许多线程解释了解决方案,包括这个:
错误:
Building wheel for pyodbc (setup.py): started
Building wheel for pyodbc (setup.py): finished with status 'error'
error: subprocess-exited-with-error
× python setup.py bdist_wheel did not run successfully.
│ exit code: 1
╰─> [10 lines of output]
running bdist_wheel
running build
running build_ext
building 'pyodbc' extension
In file included from src/buffer.cpp:12:0:
src/pyodbc.h:56:17: fatal error: sql.h: No such file or directory
#include <sql.h>
^
compilation terminated.
error: command '/usr/bin/gcc' failed with exit code 1
[end of output]
note: This error originates from a subprocess, and is likely not a problem with pip.
ERROR: Failed building wheel for pyodbc
我的问题是:如何在我的部署中启动 apt 安装(或 sudo)? 我正在使用 OpenShift GUI。
我正在使用 requirements.txt 强制安装所有依赖项的 PIP:
pandas
numpy
dash
dash_core_components
dash_html_components
plotly.express
dash
plotly
sqlalchemy
matplotlib
pyodbc
powershift-image
构建的 YAML 内容:
kind: BuildConfig
apiVersion: build.openshift.io/v1
metadata:
annotations:
app.openshift.io/vcs-ref: master
app.openshift.io/vcs-uri: >-
ssh://git@sourcecode.xxdeletedxx_reports.git
openshift.io/generated-by: OpenShiftWebConsole
selfLink: >-
/apis/build.openshift.io/v1/namespaces/ci-testline-analysis-adp/buildconfigs/adp-testline-reports-git
resourceVersion: '319828205'
name: adp-testline-reports-git
uid: 6d2f69e9-8d8d-4c72-bdc0-5838be4649d9
creationTimestamp: '2022-02-08T18:30:16Z'
managedFields:
- manager: Mozilla
operation: Update
apiVersion: build.openshift.io/v1
time: '2022-02-08T20:25:20Z'
fieldsType: FieldsV1
fieldsV1:
'f:metadata':
'f:annotations':
.: {}
'f:app.openshift.io/vcs-ref': {}
'f:app.openshift.io/vcs-uri': {}
'f:openshift.io/generated-by': {}
'f:labels':
.: {}
'f:app': {}
'f:app.kubernetes.io/component': {}
'f:app.kubernetes.io/instance': {}
'f:app.kubernetes.io/name': {}
'f:app.kubernetes.io/part-of': {}
'f:app.openshift.io/runtime': {}
'f:app.openshift.io/runtime-version': {}
'f:spec':
'f:output':
'f:to':
.: {}
'f:kind': {}
'f:name': {}
'f:runPolicy': {}
'f:source':
'f:contextDir': {}
'f:git':
.: {}
'f:ref': {}
'f:uri': {}
'f:sourceSecret':
.: {}
'f:name': {}
'f:type': {}
'f:strategy':
'f:sourceStrategy':
.: {}
'f:env': {}
'f:from':
.: {}
'f:kind': {}
'f:name': {}
'f:namespace': {}
'f:type': {}
- manager: openshift-apiserver
operation: Update
apiVersion: build.openshift.io/v1
time: '2022-02-10T14:04:32Z'
fieldsType: FieldsV1
fieldsV1:
'f:spec':
'f:triggers': {}
'f:status':
'f:lastVersion': {}
namespace: ci-testline-analysis-adp
labels:
app: adp-testline-reports-git
app.kubernetes.io/component: adp-testline-reports-git
app.kubernetes.io/instance: adp-testline-reports-git
app.kubernetes.io/name: python
app.kubernetes.io/part-of: TestLine-Report
app.openshift.io/runtime: python
app.openshift.io/runtime-version: 3.8-ubi7
spec:
nodeSelector: null
output:
to:
kind: ImageStreamTag
name: 'adp-testline-reports-git:latest'
resources: {}
successfulBuildsHistoryLimit: 5
failedBuildsHistoryLimit: 5
strategy:
type: Source
sourceStrategy:
from:
kind: ImageStreamTag
namespace: openshift
name: 'python:3.8-ubi7'
env:
- name: APP_FILE
value: main.py
postCommit: {}
source:
type: Git
git:
uri: >-
ssh://git@sourcecode.xxdeletedxx_reports.git
ref: master
contextDir: /
sourceSecret:
name: openshift-key-socialcoding
triggers:
- type: Generic
generic:
secretReference:
name: adp-testline-reports-git-generic-webhook-secret
- type: ImageChange
imageChange:
lastTriggeredImageID: >-
image-registry.openshift-image-registry.svc:5000/openshift/python@sha256:c5d24000000000000000000000
- type: ConfigChange
runPolicy: Serial
status:
lastVersion: 15
为了解决我的问题,我必须创建自定义 Docker 文件并将应用程序作为 Docker 映像部署到 OpenShift 中。具体来说,我在 GUI 中使用了 add --> from Dockerfile 而不是 add--> Import from Git (Python builder image)。 从 Git 导入方法不允许足够的灵活性来安装所有需要的包。 (pyodbc 等)