gpt4 book ai didi

kubernetes - 如何将启动参数传递到我的kubernetes pod服务中

转载 作者:行者123 更新时间:2023-12-02 12:01:44 25 4
gpt4 key购买 nike

如果我使用docker启动服务,则应如下所示:

docker run -e PARAMS="--spring.datasource.url=jdbc:mysql://mysql-service.example.com/xxl-job?Unicode=true&characterEncoding=UTF-8 --spring.datasource.username=root --spring.datasource.password=<mysql-password>" -p 8180:8080 -v /tmp:/data/applogs --name xxl-job-admin  -d xuxueli/xxl-job-admin:2.0.2

现在我在kubernetes(v1.15.2)集群中运行它,如何将参数传递到pod的容器中?我试图像这样传递参数:
"name": "xxl-job-service",
"image": "xuxueli/xxl-job-admin:2.0.2",
"args": [
"--spring.datasource.url=jdbc:mysql://mysql-service.ttt208.com/xxl-job?Unicode=true&characterEncoding=UTF-8 --spring.datasource.username=root --spring.datasource.password=<mysql-password>"
],

但它似乎不起作用,它抛出:
19:19:55.563 logback [xxl-job, admin JobFailMonitorHelper] ERROR c.x.j.a.c.t.JobFailMonitorHelper - >>>>>>>>>>> xxl-job, job fail monitor thread error:{}
org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.exceptions.PersistenceException:
### Error querying database. Cause: org.springframework.jdbc.CannotGetJdbcConnectionException: Could not get JDBC Connection; nested exception is com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure
The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.
### The error may exist in class path resource [mybatis-mapper/XxlJobLogMapper.xml]
### The error may involve com.xxl.job.admin.dao.XxlJobLogDao.findFailJobLogIds
### The error occurred while executing a query
### Cause: org.springframework.jdbc.CannotGetJdbcConnectionException: Could not get JDBC Connection; nested exception is com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure
The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.
at org.mybatis.spring.MyBatisExceptionTranslator.translateExceptionIfPossible(MyBatisExceptionTranslator.java:77)
at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:446)
at com.sun.proxy.$Proxy57.selectList(Unknown Source)
at org.mybatis.spring.SqlSessionTemplate.selectList(SqlSessionTemplate.java:230)
at org.apache.ibatis.binding.MapperMethod.executeForMany(MapperMethod.java:139)
at org.apache.ibatis.binding.MapperMethod.execute(MapperMethod.java:76)
at org.apache.ibatis.binding.MapperProxy.invoke(MapperProxy.java:59)
at com.sun.proxy.$Proxy61.findFailJobLogIds(Unknown Source)
at com.xxl.job.admin.core.thread.JobFailMonitorHelper$1.run(JobFailMonitorHelper.java:49)
at java.lang.Thread.run(Thread.java:748)

我应该怎么做才能使服务成功运行?我确定数据库用户名和密码正确。

最佳答案

Docker的-e--env设置环境变量。

Kubernetes pod spec中的等效项是containers env field

  env:
- name: PARAMS
value: ' --spring.datasource.url=jdbc:mysql://mysql-service.example.com/xxl-job?Unicode=true&characterEncoding=UTF-8 --spring.datasource.username=root --spring.datasource.password=<mysql-password>'

关于kubernetes - 如何将启动参数传递到我的kubernetes pod服务中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60705089/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com