Giter Site home page Giter Site logo

Comments (9)

torstenwalter avatar torstenwalter commented on July 20, 2024 1

jenkins.url template is defined in:

{{/*
Returns the Jenkins URL
*/}}
{{- define "jenkins.url" -}}
{{- if .Values.master.jenkinsUrl }}
{{- .Values.master.jenkinsUrl }}
{{- else }}
{{- if .Values.master.ingress.hostName }}
{{- if .Values.master.ingress.tls }}
{{- default "https" .Values.master.jenkinsUrlProtocol }}://{{ .Values.master.ingress.hostName }}{{ default "" .Values.master.jenkinsUriPrefix }}
{{- else }}
{{- default "http" .Values.master.jenkinsUrlProtocol }}://{{ .Values.master.ingress.hostName }}{{ default "" .Values.master.jenkinsUriPrefix }}
{{- end }}
{{- else }}
{{- default "http" .Values.master.jenkinsUrlProtocol }}://{{ template "jenkins.fullname" . }}:{{.Values.master.servicePort}}{{ default "" .Values.master.jenkinsUriPrefix }}
{{- end}}
{{- end}}
{{- end -}}

That should give you an idea which values you can set to configure it.

This template is then used to configure it via JCasC:

unclassified:
location:
adminAddress: {{ default "" .Values.master.jenkinsAdminEmail }}
url: {{ template "jenkins.url" . }}
{{- end -}}

from helm-charts.

larrycai avatar larrycai commented on July 20, 2024 1

jenkins.url template is defined in:

{{/*
Returns the Jenkins URL
*/}}
{{- define "jenkins.url" -}}
{{- if .Values.master.jenkinsUrl }}
{{- .Values.master.jenkinsUrl }}
{{- else }}
{{- if .Values.master.ingress.hostName }}
{{- if .Values.master.ingress.tls }}
{{- default "https" .Values.master.jenkinsUrlProtocol }}://{{ .Values.master.ingress.hostName }}{{ default "" .Values.master.jenkinsUriPrefix }}
{{- else }}
{{- default "http" .Values.master.jenkinsUrlProtocol }}://{{ .Values.master.ingress.hostName }}{{ default "" .Values.master.jenkinsUriPrefix }}
{{- end }}
{{- else }}
{{- default "http" .Values.master.jenkinsUrlProtocol }}://{{ template "jenkins.fullname" . }}:{{.Values.master.servicePort}}{{ default "" .Values.master.jenkinsUriPrefix }}
{{- end}}
{{- end}}
{{- end -}}

That should give you an idea which values you can set to configure it.

This template is then used to configure it via JCasC:

unclassified:
location:
adminAddress: {{ default "" .Values.master.jenkinsAdminEmail }}
url: {{ template "jenkins.url" . }}
{{- end -}}

This is very nice information, can you add this tip into documentation on how the mapping works, so when we are stuck somewhere, we know where to find the template to check by ourselves.

from helm-charts.

FNSdev avatar FNSdev commented on July 20, 2024

I have changed my values.yaml like this

master:
  serviceType: ClusterIP
  servicePort: 8081
  installPlugins:
    - kubernetes:1.27.0
    - workflow-aggregator:2.6
    - workflow-job:2.39
    - git:4.4.1
    - configuration-as-code:1.41
  JCasC:
    securityRealm: |-
      local:
        allowsSignup: false
    configScripts:
      jenkins-url: |
        unclassified:
          location:
            url: https://example.com/jenkins
            adminAddress: [email protected]
      welcome-message: |
        jenkins:
          systemMessage: Welcome to our CI\CD server.  This Jenkins is configured and managed 'as code'.
  # https://github.com/helm/charts/issues/15453
  customInitContainers:
    - name: "volume-mount-permission"
      image: "busybox"
      command: ["/bin/chown", "-R", "1000", "/var/jenkins_home"]
      volumeMounts:
        - name: "jenkins-home"
          mountPath: "/var/jenkins_home"
      securityContext:
        runAsUser: 0
  jenkinsUriPrefix: "/jenkins"
persistence:
  storageClass: jenkins
  size: "4Gi"

And now I have another issue:

io.jenkins.plugins.casc.ConfiguratorException: Found conflicting configuration at YamlSource: /var/jenkins_home/casc_configs/jenkins-url.yaml  in /var/jenkins_home/casc_configs/jenkins-url.yaml, line 3, column 10:
        url: https://example.com/jenkins
             ^
	at io.jenkins.plugins.casc.yaml.YamlUtils.merge(YamlUtils.java:139)
	at io.jenkins.plugins.casc.yaml.YamlUtils.merge(YamlUtils.java:125)
	at io.jenkins.plugins.casc.yaml.YamlUtils.merge(YamlUtils.java:125)
	at io.jenkins.plugins.casc.yaml.YamlUtils.merge(YamlUtils.java:125)
	at io.jenkins.plugins.casc.yaml.YamlUtils.merge(YamlUtils.java:52)
Caused: io.jenkins.plugins.casc.ConfiguratorException: Failed to read YamlSource: /var/jenkins_home/casc_configs/jenkins-url.yaml
	at io.jenkins.plugins.casc.yaml.YamlUtils.merge(YamlUtils.java:56)
	at io.jenkins.plugins.casc.yaml.YamlUtils.loadFrom(YamlUtils.java:150)
	at io.jenkins.plugins.casc.ConfigurationAsCode.configureWith(ConfigurationAsCode.java:616)
	at io.jenkins.plugins.casc.ConfigurationAsCode.configure(ConfigurationAsCode.java:298)
	at io.jenkins.plugins.casc.ConfigurationAsCode.init(ConfigurationAsCode.java:290)
Caused: java.lang.reflect.InvocationTargetException
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at hudson.init.TaskMethodFinder.invoke(TaskMethodFinder.java:104)
Caused: java.lang.Error
	at hudson.init.TaskMethodFinder.invoke(TaskMethodFinder.java:110)
	at hudson.init.TaskMethodFinder$TaskImpl.run(TaskMethodFinder.java:175)
	at org.jvnet.hudson.reactor.Reactor.runTask(Reactor.java:296)
	at jenkins.model.Jenkins$5.runTask(Jenkins.java:1131)
	at org.jvnet.hudson.reactor.Reactor$2.run(Reactor.java:214)
	at org.jvnet.hudson.reactor.Reactor$Node.run(Reactor.java:117)
	at jenkins.security.ImpersonatingExecutorService$1.run(ImpersonatingExecutorService.java:59)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
	at java.lang.Thread.run(Thread.java:748)
2020-09-04 06:18:34.325+0000 [id=19]	SEVERE	hudson.util.BootFailure#publish: Failed to initialize Jenkins

I guess that's because default config also specifies url.

What am I doing wrong?

from helm-charts.

larrycai avatar larrycai commented on July 20, 2024

those needs to be overwritten in values.yaml for helm chart since jcasc-default-config.yaml already have it.

for url, I guess it is set in ingress part, I guess you removed this in the sample above.

master:
    ingress:
        hostName: xxx

You can check inside your jenkins

$ kubectl exec -it $(kubectl get pods -l app.kubernetes.io/name=jenkins -o=jsonpath='{.items[0].metadata.name}') -c jenkins bash
$ cat $CASC_JENKINS_CONFIG/jcasc-default-config.yaml

from helm-charts.

FNSdev avatar FNSdev commented on July 20, 2024

@larrycai Thank you for the reply
I use custom ingress configuration

apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: jenkins-ingress
  annotations:
    kubernetes.io/ingress.class: "nginx"
spec:
  tls:
    - hosts:
        - example.com
        - www.example.com
      secretName: tls
  rules:
    - host: example.com
      http:
        paths:
        - path: /jenkins
          pathType: Prefix
          backend:
            service:
              name: jenkins
              port:
                number: 8081
    - host: www.example.com
      http:
        paths:
          - path: /jenkins
            pathType: Prefix
            backend:
              service:
                name: jenkins
                port:
                  number: 8081

Is there no other way to configure hostName?

from helm-charts.

FNSdev avatar FNSdev commented on July 20, 2024

@torstenwalter
Thank you! That is exactly what I was looking for.
I'm sorry for being not attentive enough, just getting started with Jenkins.

Could you please also clarify why the example with systemMessage was not working for me?

Do I have to put it into configScripts section?

from helm-charts.

torstenwalter avatar torstenwalter commented on July 20, 2024

Yes

from helm-charts.

torstenwalter avatar torstenwalter commented on July 20, 2024

#29 contains an example. I think we should add it in the README.

@FNSdev Would you like to create a PR for it?

from helm-charts.

FNSdev avatar FNSdev commented on July 20, 2024

@torstenwalter
Please take a look
#32

from helm-charts.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.