jx boot resets stagging urltemplate to default

Created on 29 Jan 2020  路  6Comments  路  Source: jenkins-x/jx

Summary

After configuring the urltemplate to something custom in the environment-clustername-staging repo running jx boot causes the value to be set back to the default

Steps to reproduce the behavior

  1. set expose.config.urltemplate in environment-clustername-staging/env/values.yaml and deploy
  2. jx start pipeline and select environment-clustername-dev/master

Expected behavior

the urltemplate not to change

Actual behavior

The configured bot set the urltemplate to the default

Jx version

The output of jx version is:

NAME               VERSION
jx                 2.0.1152
Kubernetes cluster v1.13.11-gke.23
kubectl            v1.17.2
helm client        Client: v2.14.3+g0e7f3b6
git                2.17.1
Operating System   Ubuntu 18.04.3 LTS


verifying packages

Jenkins type

  • [x] Serverless Jenkins X Pipelines (Tekton + Prow)
  • [ ] Classic Jenkins

Kubernetes cluster

gke

Operating system / Environment

Operating System Ubuntu 18.04.3 LTS

areboot arefox estimatM kinbug prioritimportant-soon

Most helpful comment

For anyone interested in a workaround in the mean time, what I ended up doing is adding an hardcoded exposecontroller ConfigMap to the templates in my env repo that overwrites the one created automatically by JX:

apiVersion: v1
kind: ConfigMap
metadata:
  name: exposecontroller
data:
  config.yml: |-
    exposer: Ingress
    domain: cluster.example.com
    urltemplate: "{{`{{.Service}}.{{.Namespace}}.{{.Domain}}`}}"
    http: false
    tls-acme: true
    tls-secret-name: tls-cluster-example-com-p

Note that I omitted the annotations and labels metadata, as it seems like the above gets merged with the resource generated by JX. However, the whole config.yml value must be specified at once, because it's actually a single string (note the "|-" operator).
Also note that we need to escape the urltemplate string in order to prevent the template placeholders from getting interpolated by helm.

All 6 comments

commit f711e024a7b16da6ca05513290a6dad2348adc35
Author: OrgBot <[email protected]>
Date:   Wed Jan 29 06:35:03 2020 +0000

    Add environment configuration

diff --git a/env/values.yaml b/env/values.yaml
index 5ec92ad..37d5a2e 100644
--- a/env/values.yaml
+++ b/env/values.yaml
@@ -18,7 +18,7 @@ expose:
     http: "false"
     tlsSecretName: tls-staging-example-com-p
     tlsacme: "true"
-    urltemplate: '{{.Service}}.{{.Domain}}'
+    urltemplate: '{{.Service}}-{{.Namespace}}.{{.Domain}}'
   production: true
 jenkins:
   Servers:

In an attempt to work around the issue, I put protection on the master branch of the environment-clustername-staging repo but now I see step-verify-jenkins-x-environment fail.

Validating git repository for staging environment at URL https://github.com/exergy/environment-clustername-staging.git
Using Git provider github at https://github.com
? Using Git user name: *************
? Using organisation: orgname
Creating repository exergy/environment-clustername-staging
Git repository exergy/environment-clustername-staging already exists
error: failed to create git repository for gitURL https://github.com/orgname/environment-clustername-staging.git: pushing environment master branch: Have you set up a git credential helper? See https://help.github.com/articles/caching-your-github-password-in-git/
: git output: remote: error: GH006: Protected branch update failed for refs/heads/master.
remote: error: 2 of 2 required status checks are expected.
To https://github.com/exergy/environment-clustername-staging.git
 ! [remote rejected] master -> master (protected branch hook declined)
error: failed to push some refs to 'https://************:*******************************************@github.com/orgname/environment-clustername-staging.git': failed to run 'git push origin master' command in directory '/tmp/**-env-repo-497196869/orgname/environment-clustername-staging', output: 'remote: error: GH006: Protected branch update failed for refs/heads/master.
remote: error: 2 of 2 required status checks are expected.
To https://github.com/orgname/environment-clustername-staging.git
 ! [remote rejected] master -> master (protected branch hook declined)
error: failed to push some refs to 'https://***********:******************************************@github.com/orgname/environment-clustername-staging.git''

Pipeline failed on stage 'release' : container 'step-verify-jenkins-x-environment'. The execution of the pipeline has stopped.

@rudolph9 Changes being made soon (~late Feb/March) will help alleviate your issue.

For anyone interested in a workaround in the mean time, what I ended up doing is adding an hardcoded exposecontroller ConfigMap to the templates in my env repo that overwrites the one created automatically by JX:

apiVersion: v1
kind: ConfigMap
metadata:
  name: exposecontroller
data:
  config.yml: |-
    exposer: Ingress
    domain: cluster.example.com
    urltemplate: "{{`{{.Service}}.{{.Namespace}}.{{.Domain}}`}}"
    http: false
    tls-acme: true
    tls-secret-name: tls-cluster-example-com-p

Note that I omitted the annotations and labels metadata, as it seems like the above gets merged with the resource generated by JX. However, the whole config.yml value must be specified at once, because it's actually a single string (note the "|-" operator).
Also note that we need to escape the urltemplate string in order to prevent the template placeholders from getting interpolated by helm.

So #6942 should fix this for new installations.

You'll be able to define urlTemplate for every repository in jx-requirements.yml and this will be configured in the environment's values.yaml.

This will make the exposecontroller ConfigMap have the correct, configured template all the time.

For currently running clusters, I'd advice you to follow https://github.com/jenkins-x/jx/issues/6648#issuecomment-597644456 workaround, updating the value in the git repository will make it work.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ipv1337 picture ipv1337  路  3Comments

kevinsuperped picture kevinsuperped  路  5Comments

empath picture empath  路  3Comments

ysaakpr picture ysaakpr  路  5Comments

sourabhg picture sourabhg  路  4Comments