jenkins-x / jx

Jenkins X provides automated CI+CD for Kubernetes with Preview Environments on Pull Requests using Cloud Native pipelines from Tekton
https://jenkins-x.io/
Apache License 2.0
4.58k stars 788 forks source link

configmap 'jenkins-x-docker-registry' not set when using internal docker registry #7029

Closed vvanouytsel closed 3 years ago

vvanouytsel commented 4 years ago

Summary

Running jx boot in combination with the kubernetes provider and using the internal docker registry results in an empty configmap jenkins-x-docker-registry.

The message error: Missing option: --docker-registry is thrown when creating quickstart projects.

In order to work around this issue we can manually edit the configmap and specify the service address of the docker registry.

$ kubectl edit cm jenkins-x-docker-registry -n jx
apiVersion: v1
data:
  docker.registry: 10.0.45.198:5000 # Add the service address and port of the jenkins-x-docker-registry service
kind: ConfigMap
metadata:
  annotations:
    expose.config.fabric8.io/clusterip-port-if-empty-key: docker.registry
    jenkins.io/chart: env
    kubectl.kubernetes.io/last-applied-configuration: |
      {"apiVersion":"v1","data":{"docker.registry":null},"kind":"ConfigMap","metadata":{"annotations":{"expose.config.fabric8.io/clusterip-port-if-empty-key":"docker.registry","jenkins.io/chart":"env"},"labels":{"jenkins.io/chart-release":"jenkins-x","jenkins.io/namespace":"jx","jenkins.io/version":"1"},"name":"jenkins-x-docker-registry","namespace":"jx"}}
  creationTimestamp: "2020-04-07T12:22:44Z"
  labels:
    jenkins.io/chart-release: jenkins-x
    jenkins.io/namespace: jx
    jenkins.io/version: "1"
  name: jenkins-x-docker-registry
  namespace: jx
  resourceVersion: "16916"
  selfLink: /api/v1/namespaces/jx/configmaps/jenkins-x-docker-registry
  uid: f2a59568-06bd-4802-a0ba-5103093b37d8

We should populate the configmap automatically with the service address when the user uses the local docker registry.

Steps to reproduce the behavior

Specify the kubernetes provider in the jx-requirements.yml file and do not configure an external docker registry.

? Do you want to configure an external Docker Registry? No
# jx-requirements.yml
cluster:
  clusterName: myclustername
  environmentGitPublic: true
  gitKind: github
  gitName: github
  gitServer: https://github.com
  namespace: jx
  provider: kubernetes
$ kubectl get cm jenkins-x-docker-registry -n jx

jenkins-x-docker-registry                     0      110m

Expected behavior

Configmap jenkins-x-docker-registry configured with the service address of the internal docker registry

$ kubectl get cm jenkins-x-docker-registry -n jx

jenkins-x-docker-registry                     1      110m
$ kubectl get cm -o yaml jenkins-x-docker-registry -n jx

apiVersion: v1
data:
  docker.registry: 10.0.45.198:5000
kind: ConfigMap
metadata:
  annotations:
    expose.config.fabric8.io/clusterip-port-if-empty-key: docker.registry
    jenkins.io/chart: env
    kubectl.kubernetes.io/last-applied-configuration: |
      {"apiVersion":"v1","data":{"docker.registry":null},"kind":"ConfigMap","metadata":{"annotations":{"expose.config.fabric8.io/clusterip-port-if-empty-key":"docker.registry","jenkins.io/chart":"env"},"labels":{"jenkins.io/chart-release":"jenkins-x","jenkins.io/namespace":"jx","jenkins.io/version":"1"},"name":"jenkins-x-docker-registry","namespace":"jx"}}
  creationTimestamp: "2020-04-07T12:22:44Z"
  labels:
    jenkins.io/chart-release: jenkins-x
    jenkins.io/namespace: jx
    jenkins.io/version: "1"
  name: jenkins-x-docker-registry
  namespace: jx
  resourceVersion: "20700"
  selfLink: /api/v1/namespaces/jx/configmaps/jenkins-x-docker-registry
  uid: f2a59568-06bd-4802-a0ba-5103093b37d8

Actual behavior

Cofigmap jenkins-x-docker-registry is empty and quickstart projects fail with the message error: Missing option: --docker-registry.

$ kubectl get cm jenkins-x-docker-registry -n jx

jenkins-x-docker-registry                     0      110m
$ jx step syntax effective
error: Missing option: --docker-registry

Jx version

The output of jx version is:

NAME               VERSION
jx                 2.0.1265
Kubernetes cluster v1.15.10
kubectl            v1.15.10
helm client        2.16.5
git                2.17.1
Operating System   Ubuntu 18.04.4 LTS

Jenkins type

Kubernetes cluster

AKS cluster created via the Azure portal.

Operating system / Environment

Ubuntu 18.04.4 LTS

nodece commented 4 years ago

It seems cannot read docker.registry from jenkins-x-docker-registry .

https://github.com/jenkins-x/jx/blob/master/pkg/cmd/step/syntax/step_syntax_effective.go#L172

jenkins-x-bot commented 4 years ago

Issues go stale after 90d of inactivity. Mark the issue as fresh with /remove-lifecycle stale. Stale issues rot after an additional 30d of inactivity and eventually close. If this issue is safe to close now please do so with /close. Provide feedback via https://jenkins-x.io/community. /lifecycle stale

kdoustar commented 4 years ago

I have also booted jx on my local kubernetes cluster and I get this error eveytime I want to create a quickstart (in container logs) error: Missing option: --docker-registry

My configmap is not empty, but no usefull registery is included:

$ kubectl get cm -o yaml jenkins-x-docker-registry -n jx
apiVersion: v1
data:
  docker.registry: ""
kind: ConfigMap
metadata:
  annotations:
    expose.config.fabric8.io/clusterip-port-if-empty-key: docker.registry
    jenkins.io/chart: env
    kubectl.kubernetes.io/last-applied-configuration: |
      {"apiVersion":"v1","data":{"docker.registry":null},"kind":"ConfigMap","metadata":{"annotations":{"expose.config.fabric8.io/clusterip-port-if-empty-key":"docker.registry","jenkins.io/chart":"env"},"labels":{"jenkins.io/chart-release":"jenkins-x","jenkins.io/namespace":"jx","jenkins.io/version":"1"},"name":"jenkins-x-docker-registry","namespace":"jx"}}
  creationTimestamp: "2020-07-10T15:54:51Z"
  labels:
    jenkins.io/chart-release: jenkins-x
    jenkins.io/namespace: jx
    jenkins.io/version: "1"
  managedFields:
  - apiVersion: v1
    fieldsType: FieldsV1
    fieldsV1:
      f:data:
        .: {}
        f:docker.registry: {}
      f:metadata:
        f:annotations:
          .: {}
          f:expose.config.fabric8.io/clusterip-port-if-empty-key: {}
          f:jenkins.io/chart: {}
          f:kubectl.kubernetes.io/last-applied-configuration: {}
        f:labels:
          .: {}
          f:jenkins.io/chart-release: {}
          f:jenkins.io/namespace: {}
          f:jenkins.io/version: {}
    manager: kubectl
    operation: Update
    time: "2020-07-10T15:54:51Z"
  name: jenkins-x-docker-registry
  namespace: jx
  resourceVersion: "3615245"
  selfLink: /api/v1/namespaces/jx/configmaps/jenkins-x-docker-registry
  uid: 0e37f992-20b5-4399-bf5f-98d738dad9fd
$
$ jx version
Version        2.1.98
Commit         a6747c4
Build date     2020-07-09T15:16:45Z
Go version     1.13.8
Git tree state clean
kdoustar commented 4 years ago

/remove-lifecycle stale

jenkins-x-bot commented 4 years ago

Issues go stale after 90d of inactivity. Mark the issue as fresh with /remove-lifecycle stale. Stale issues rot after an additional 30d of inactivity and eventually close. If this issue is safe to close now please do so with /close. Provide feedback via https://jenkins-x.io/community. /lifecycle stale

jenkins-x-bot commented 3 years ago

Stale issues rot after 30d of inactivity. Mark the issue as fresh with /remove-lifecycle rotten. Rotten issues close after an additional 30d of inactivity. If this issue is safe to close now please do so with /close. Provide feedback via https://jenkins-x.io/community. /lifecycle rotten

jenkins-x-bot commented 3 years ago

Rotten issues close after 30d of inactivity. Reopen the issue with /reopen. Mark the issue as fresh with /remove-lifecycle rotten. Provide feedback via https://jenkins-x.io/community. /close

jenkins-x-bot commented 3 years ago

@jenkins-x-bot: Closing this issue.

In response to [this](https://github.com/jenkins-x/jx/issues/7029#issuecomment-742541220): >Rotten issues close after 30d of inactivity. >Reopen the issue with `/reopen`. >Mark the issue as fresh with `/remove-lifecycle rotten`. >Provide feedback via https://jenkins-x.io/community. >/close Instructions for interacting with me using PR comments are available [here](https://git.k8s.io/community/contributors/guide/pull-requests.md). If you have questions or suggestions related to my behavior, please file an issue against the [jenkins-x/lighthouse](https://github.com/jenkins-x/lighthouse/issues/new?title=Command%20issue:) repository.