quicklyon / zentao-docker

Quickon Docker Image for ZenTao(禅道官方容器镜像)
Other
25 stars 8 forks source link

使用helm部署到子路径下 #13

Closed xinnj closed 9 months ago

xinnj commented 9 months ago

请问使用helm部署时,如何才能部署到子路径下?例如用这种url来访问:http://test.com/pm/ 直接改ingress的path貌似不行,安装页面能出来,但点击“开始安装”后就404了。

SchoIsles commented 9 months ago
env:
  APP_WEB_ROOT: /pm

ingress:
  paths:
  - path: /
    port: 80
    type: Prefix
  - path: /pm
    port: 80
    type: Prefix

helm 部署时追加以上配置,让禅道知道前缀是 /pm, 在 ingress 里添加 /pm 的路由,但是得保留 / 的路由。

如果你是用一个域名的不同前缀来路由多个服务,可以在其它的 ingress 里配置好 /,在这里的ingress里只保留 /pm 即可

xinnj commented 9 months ago

有办法不依赖于“/”路径吗?“/”已经被其他服务用了。 现在设置了一下配置后,安装都正常。但登录时又跳转到“/”路径了。 env: APP_WEB_ROOT: /pm

ingress: paths:

SchoIsles commented 9 months ago

进入容器后手动修改下 config/my.php , 将 $config->webRoot = getWebRoot(); 改为 $config->webRoot = '/pm';

xinnj commented 9 months ago

终于搞定了。把value文件贴出来供大家参考,假设访问路径为http://test.com/a/pm/。感谢@SchoIsles

replicas: 1
scalable: true

image:
  repository: app/zentao
  tag: "18.8"
  pullPolicy: Always

service:
  enabled: true
  type: ClusterIP

ports:
  - name: web
    protocol: tcp
    port: 80
  - name: probe
    protocol: tcp
    port: 80

probe:
  readiness:
    enabled: true
    type: http
    methods:
      http:
        httpGet:
          path: /check.html
          port: 80
  startup:
    enabled: true
    type: tcp
    methods:
      tcp:
        tcpSocket:
          port: 80

resources:
  cpu: 200m
  memory: 256Mi

oversold:
  cpu: 100m
  memory: 128Mi

ingress:
  enabled: true
  annotations:
    nginx.ingress.kubernetes.io/proxy-connect-timeout: "300"
    nginx.ingress.kubernetes.io/proxy-read-timeout: "300"
  host: "test.com"
  paths:
  - path: /a/pm/
    port: 80
    type: Prefix

env:
  ZT_MYSQL_PASSWORD:
    source: secret
    key: mysql_password
    subChartRefs:
    - when: mysql.enabled
      name: mysql
  ZT_MYSQL_DB: "$ref:mysql.auth.database"
  ZT_MYSQL_PORT: "$ref:mysql.auth.port"
  ZT_MYSQL_USER: "$ref:mysql.auth.user"
  IS_CONTAINER: "true"
  SMTP_ENABLED: '$ref:mail.enabled'
  SMTP_FROMNAME: "ZenTao"
  APP_DOMAIN: "$ref:ingress.host"
  APP_WEB_ROOT: "/a/pm"

mysql:
  enabled: true
  auth:
    rootPassword: pass4zenTao
    user: "root"
    password: "pass4zenTao"
    database: "zentao"
    port: 3306

secret:
  data:
    mysql_password:
      value: "$ref:mysql.auth.password"
      length: 20
      allowOverride: true

mail:
  enabled: false
  smtp: {}

configmaps:
  mail:
    mode: kv
    data:
      SMTP_HOST: '$ref:mail.smtp.host'
      SMTP_PORT: '$ref:mail.smtp.port'
      SMTP_USER: '$ref:mail.smtp.user'
      SMTP_PASS: '$ref:mail.smtp.pass'

envFrom:
  configmaps:
   - mail

db:
  config:
    grant_super_privilege: "true"

global:
  allowOverSold: true
  cleanPolicy:
    workflow: true

volumes:
  data:
    type: pvc
    enabled: true
    accessMode: ReadWriteOnce
    size: 1Gi
    mounts:
    - mountPath: /data
      subPath: ""

command:
  - /bin/sh
  - -c
  - |
    if [ ! -e "/apps/zentao/module/install/view/step3.html.php.original" ]; then
      cp /apps/zentao/module/install/view/step3.html.php /apps/zentao/module/install/view/step3.html.php.original
      sed -i -e "s/^\([[:blank:]]*\)\(\$configContent[[:blank:]]*=[[:blank:]]*<<<EOT\)/\1\$webRoot = getenv\('APP_WEB_ROOT'\) \. '\/';\n\1\2/" \
        -e "s/\(config->webRoot[[:blank:]]*=[[:blank:]]*\)getWebRoot();/\1'\$webRoot';/" \
        /apps/zentao/module/install/view/step3.html.php
    fi
    /usr/bin/entrypoint.sh