operator-sdk: Failed with "the server could not find the requested resource"

Bug Report

What did we do? Trying to deploy custom resource via the operator: Facing the issue: the server could not find the requested resource

What we expect: Below is the stdout log from the operator deployed on Openshift 3.11: 2019-02-21T13:55:19.173Z INFO logging_event_handler [playbook task] {"name": "example-full", "namespace": "redis-cluster", "gvk": "db.mysite.com/v1alpha1, Kind=RedisCluster", "event_type": "playbook_on_task_start", "job": "3033838985510594553", "EventData.Name": "Gathering Facts"}

What we see instead: The same CRD, the same role, service account, permissions etc. on Openshift 3.10: {"level":"error","ts":1550756524.2727947,"logger":"kubebuilder.controller","msg":"Reconciler error","controller":"rediscluster-controller","request":"redis-cluster/example-full","error":"the server could not find the requested resource","stacktrace":"github.com/operator-framework/operator-sdk/vendor/github.com/go-logr/zapr.(*zapLogger).Error\n\t/home/joe/go/src/github.com/operator-framework/operator-sdk/vendor/github.com/go-logr/zapr/zapr.go:128\ngithub.com/operator-framework/operator-sdk/vendor/sigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller).processNextWorkItem\n\t/home/joe/go/src/github.com/operator-framework/operator-sdk/vendor/sigs.k8s.io/controller-runtime/pkg/internal/controller/controller.go:215\ngithub.com/operator-framework/operator-sdk/vendor/sigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller).Start.func1\n\t/home/joe/go/src/github.com/operator-framework/operator-sdk/vendor/sigs.k8s.io/controller-runtime/pkg/internal/controller/controller.go:158\ngithub.com/operator-framework/operator-sdk/vendor/k8s.io/apimachinery/pkg/util/wait.JitterUntil.func1\n\t/home/joe/go/src/github.com/operator-framework/operator-sdk/vendor/k8s.io/apimachinery/pkg/util/wait/wait.go:133\ngithub.com/operator-framework/operator-sdk/vendor/k8s.io/apimachinery/pkg/util/wait.JitterUntil\n\t/home/joe/go/src/github.com/operator-framework/operator-sdk/vendor/k8s.io/apimachinery/pkg/util/wait/wait.go:134\ngithub.com/operator-framework/operator-sdk/vendor/k8s.io/apimachinery/pkg/util/wait.Until\n\t/home/joe/go/src/github.com/operator-framework/operator-sdk/vendor/k8s.io/apimachinery/pkg/util/wait/wait.go:88"}

Environment

  • operator-sdk version: 0.3.0, 0.4.1, 0.5.0
  • openshift v3.10.0+fd501dd-48 *
  • kubernetes v1.10.0+b81c8f8 *
  • operator code is written on: Ansible *

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Comments: 17 (7 by maintainers)

Commits related to this issue

Most upvoted comments

I saw the same error with kubebuilder version 2.0.0-alpha.1:

"error": "the server could not find the requested resource (put cronjobs.batch.sun.kubebuilder.io cronjob-sample)"}

Adding the // +kubebuilder:subresource:status comment above the CronJob struct in cronjob_types.go, and then running make manifests per https://book-v1.book.kubebuilder.io/basics/status_subresource.html resolved the error for me:

// +kubebuilder:subresource:status
type CronJob struct {
make manifests

status subresource in CRD after running make manifests:

spec:
...
  subresources:
    status: {}
...

I am facing the same issue when I followed this link https://github.com/operator-framework/operator-sdk/blob/master/doc/ansible/user-guide.md

operator-sdk version: v0.7.0 Kubectl Client Version: v1.9.11 K8s Server Version: v1.9.11 ansible 2.7.9

I tried to run both inside and outside the cluster as per README.md and receiving the same errors:

{"level":"error","ts":1556555179.8817847,"logger":"reconciler","msg":"Unable to update the status to mark cr as running","job":"1730092421274156201","name":"example-foo","namespace":"default","error":"the server could not find the requested resource","stacktrace":"github.com/operator-framework/operator-sdk/vendor/github.com/go-logr/zapr.(*zapLogger).Error\n\tsrc/github.com/operator-framework/operator-sdk/vendor/github.com/go-logr/zapr/zapr.go:128\ngithub.com/operator-framework/operator-sdk/pkg/ansible/controller.(*AnsibleOperatorReconciler).Reconcile\n\tsrc/github.com/operator-framework/operator-sdk/pkg/ansible/controller/reconcile.go:126\ngithub.com/operator-framework/operator-sdk/vendor/sigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller).processNextWorkItem\n\tsrc/github.com/operator-framework/operator-sdk/vendor/sigs.k8s.io/controller-runtime/pkg/internal/controller/controller.go:215\ngithub.com/operator-framework/operator-sdk/vendor/sigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller).Start.func1\n\tsrc/github.com/operator-framework/operator-sdk/vendor/sigs.k8s.io/controller-runtime/pkg/internal/controller/controller.go:158\ngithub.com/operator-framework/operator-sdk/vendor/k8s.io/apimachinery/pkg/util/wait.JitterUntil.func1\n\tsrc/github.com/operator-framework/operator-sdk/vendor/k8s.io/apimachinery/pkg/util/wait/wait.go:133\ngithub.com/operator-framework/operator-sdk/vendor/k8s.io/apimachinery/pkg/util/wait.JitterUntil\n\tsrc/github.com/operator-framework/operator-sdk/vendor/k8s.io/apimachinery/pkg/util/wait/wait.go:134\ngithub.com/operator-framework/operator-sdk/vendor/k8s.io/apimachinery/pkg/util/wait.Until\n\tsrc/github.com/operator-framework/operator-sdk/vendor/k8s.io/apimachinery/pkg/util/wait/wait.go:88"}