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
expose.config.urltemplate in environment-clustername-staging/env/values.yaml and deployjx start pipeline and select environment-clustername-dev/masterthe urltemplate not to change
The configured bot set the urltemplate to the default
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
gke
Operating System Ubuntu 18.04.3 LTS
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.
It seems like urltemplate is set to a constant and there is no way to change it
https://github.com/jenkins-x/jx/blob/6c01ab6f498e6a2eb3d82da23f0d996d5be36d22/pkg/cmd/step/verify/step_verify_environments.go#L530
@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.
Most helpful comment
For anyone interested in a workaround in the mean time, what I ended up doing is adding an hardcoded
exposecontrollerConfigMap to the templates in my env repo that overwrites the one created automatically by JX: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.ymlvalue 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.