Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CronJob should curl service name rather than ingress host #16

Closed
elonzh opened this issue Sep 15, 2020 · 4 comments
Closed

CronJob should curl service name rather than ingress host #16

elonzh opened this issue Sep 15, 2020 · 4 comments

Comments

@elonzh
Copy link
Contributor

elonzh commented Sep 15, 2020

Current template:

command: [ "curl" ]
args:
{{- if .Values.cronjob.curlInsecure }}
- "-k"
{{- end }}
- "--fail"
- "-L"
{{- if .Values.ingress.tls }}
- "https://{{ .Values.nextcloud.host }}/cron.php"
{{- else }}
- "http://{{ .Values.nextcloud.host }}/cron.php"
{{- end }}

The problems:

  1. the cronjob requests an external url, which may not exist if we did not enable ingress
  2. even we enable ingress, the ingress may use other ports rather than normal http port(80) or https port(443)
  3. even we use normal http(s) ports, the .Values.ingress.tls is not the only approach to set https

The solution:

just curl the service name and service port, like this:

              command: [ "curl" ]
              args:
                - "--fail"
                - "-L"
                - "http://{{ template "nextcloud.fullname" . }}:{{ .Values.service.port }}/cron.php"

if we use this solution, .Values.cronjob.curlInsecure can be removed.

The test:

image

elonzh added a commit to elonzh/helm that referenced this issue Sep 15, 2020
elonzh added a commit to elonzh/helm that referenced this issue Sep 15, 2020
Signed-off-by: elonzh <elonzh@qq.com>
@pfuhrmann
Copy link
Contributor

This does not work for me @elonzh

root@nextcloud-69c99f6d76-x45qc:/var/www/html# curl -I --fail -L http://nextcloud:8080/cron.php
curl: (22) The requested URL returned error: 400 Bad Request

@chrisjohnson00
Copy link

If the chart is deployed with an ingress the cronjob calls the ingress. There's no reason for the cronjob to ever call the ingress, it's deployed inside the cluster so it should call the service by name, always. I'll test and PR a fix for the case of ingress on when I have time.

@pfuhrmann
Copy link
Contributor

Yes, the above theory should work, except it doesn't. See my comment above.

I suspect that is because of the trusted_domains:
https://github.com/nextcloud/server/blob/master/config/config.sample.php#L71

@pfuhrmann
Copy link
Contributor

If we would be able to dynamically configure trusted_domains to include private IP of the K8s service that could work (maybe).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants