jenkinsci / kubernetes-operator

Kubernetes native Jenkins Operator
https://jenkinsci.github.io/kubernetes-operator
Other
597 stars 233 forks source link

operator expects jenkins pod to exist in default namespace #873

Closed rlratcliffe closed 1 year ago

rlratcliffe commented 1 year ago

Describe the bug after upgrading to v0.8.0-beta2, operator starts fine after deleting old deployment but jenkins pod no longer starts/restarts. I believe it's because

name: WATCH_NAMESPACE
value: default

when I've added the operator to the jenkins namespace and that's where the pod should exist as well, not the default namespace. it looks like v0.6.0 allowed for pulling the namespace from the namespace the operator was in?

          - name: WATCH_NAMESPACE
            valueFrom:
              fieldRef:
                fieldPath: metadata.namespace

To Reproduce

  1. apply operator in jenkins namespace using:

https://raw.githubusercontent.com/jenkinsci/kubernetes-operator/v0.8.0-beta2/config/crd/bases/jenkins.io_jenkins.yaml https://raw.githubusercontent.com/jenkinsci/kubernetes-operator/v0.8.0-beta2/deploy/all-in-one-v1alpha2.yaml

  1. create jenkins instance similar to the manifest in these instructions, but not in the default namespace: https://jenkinsci.github.io/kubernetes-operator/docs/getting-started/latest/deploying-jenkins/

Additional information

Kubernetes version: 1.25.6 Jenkins Operator version: v0.8.0-beta2

Add error logs about the problem here (operator logs and Kubernetes events). operator logs: E0704 22:32:34.593184 1 reflector.go:138] pkg/mod/k8s.io/client-go@v0.20.2/tools/cache/reflector.go:167: Failed to watch v1alpha2.Jenkins: failed to list v1alpha2.Jenkins: jenkins.jenkins.io is forbidden: User "system:serviceaccount:jenkins:jenkins-operator" cannot list resource "jenkins" in API group "jenkins.io" in the namespace "default"

brokenpip3 commented 1 year ago

yep this is my bad, we should put the field from the namespace back, if you have time to create a PR will be great otherwise I will do it later today

brokenpip3 commented 1 year ago

thanks for the bug report and for the fix. I will add the permanent solution in the ci in another PR