Skip to content
This repository was archived by the owner on Sep 21, 2020. It is now read-only.

Create a Memcached CR #32

Closed
ghost opened this issue Dec 30, 2018 · 8 comments
Closed

Create a Memcached CR #32

ghost opened this issue Dec 30, 2018 · 8 comments
Assignees
Labels
kind/documentation Categorizes issue or PR as related to documentation. triage/support Indicates an issue that is a support question.

Comments

@ghost
Copy link

ghost commented Dec 30, 2018

I followed the guide with no issue until section Create a Memcached CR. Then I executed

kubectl apply -f deploy/crds/cache_v1alpha1_memcached_cr.yaml

The example-memcached object is created in the namespace however no new deployments and pods are created.

@Michkov
Copy link

Michkov commented Jul 27, 2019

Having same issue, log from operator:

E0727 18:12:00.305813       1 reflector.go:134] pkg/mod/k8s.io/[email protected]/tools/cache/reflector.go:95: Failed to list *v1.Deployment: deployments.apps is forbidden: User "system:serviceaccount:default:memcached-operator" cannot list resource "deployments" in API group "apps" at the cluster scope
E0727 18:12:00.305995       1 reflector.go:134] pkg/mod/k8s.io/[email protected]/tools/cache/reflector.go:95: Failed to list *v1alpha1.Memcached: memcacheds.cache.example.com is forbidden: User "system:serviceaccount:default:memcached-operator" cannot list resource "memcacheds" in API group "cache.example.com" at the cluster scope

@takara9
Copy link

takara9 commented Aug 16, 2019

I have same issue too.

$ kubectl apply -f deploy/crds/cache_v1alpha1_memcached_cr.yaml
memcached.cache.example.com/example-memcached created

$ kubectl get deploy
NAME DESIRED CURRENT UP-TO-DATE AVAILABLE AGE
memcached-operator 1 1 1 1 8m

$ kubectl get -f deploy/crds/cache_v1alpha1_memcached_cr.yaml
NAME AGE
example-memcached 17s

@camilamacedo86 camilamacedo86 self-assigned this Sep 4, 2019
@camilamacedo86 camilamacedo86 added the triage/support Indicates an issue that is a support question. label Sep 4, 2019
@camilamacedo86
Copy link
Contributor

camilamacedo86 commented Sep 4, 2019

Hi @Michkov , @takara9 and @oscarpicasso-intact,

Looking the error raised here:

E0727 18:12:00.305813       1 reflector.go:134] pkg/mod/k8s.io/[email protected]/tools/cache/reflector.go:95: Failed to list *v1.Deployment: deployments.apps is forbidden: User "system:serviceaccount:default:memcached-operator" cannot list resource "deployments" in API group "apps" at the cluster scope
E0727 18:12:00.305995       1 reflector.go:134] pkg/mod/k8s.io/[email protected]/tools/cache/reflector.go:95: Failed to list *v1alpha1.Memcached: memcacheds.cache.example.com is forbidden: User "system:serviceaccount:default:memcached-operator" cannot list resource "memcacheds" in API group "cache.example.com" at the cluster scope

Shows that the roles were not applied in the cluster. Note that the following files need to be applied to it.

$ kubectl create -f deploy/role.yaml
$ kubectl create -f deploy/role_binding.yaml

In order to be able to troubleshooting and have better information to check what is wrong see the logs of the operator pod created in the cluster.

I hope that this information helps you with.

@camilamacedo86 camilamacedo86 added the kind/documentation Categorizes issue or PR as related to documentation. label Sep 4, 2019
@camilamacedo86
Copy link
Contributor

Dear,

We did a few improvements in the getting started in order to provide more information to help you with. Please, feel free to check it #46.

@skckadiyala
Copy link

I have the same issue...
followed the getting started guide..
$ kubectl create -f deploy/service_account.yaml
serviceaccount/memcached-operator created

$ kubectl create -f deploy/role.yaml
role.rbac.authorization.k8s.io/memcached-operator created

kubectl create -f deploy/role_binding.yaml
rolebinding.rbac.authorization.k8s.io/memcached-operator created

kubectl apply -f deploy/crds/cache_v1alpha1_memcached_cr.yaml
memcached.cache.systest.net/example-memcached created

$ kubectl get deployments
NAME READY UP-TO-DATE AVAILABLE AGE
memcached-operator 1/1 1 1 4m11s

No new deployments are pods created for the example-memchaced.

@camilamacedo86
Copy link
Contributor

camilamacedo86 commented Sep 7, 2019

Hi @skckadiyala,

Could you please follow the changes performed in the PR https://github.com/operator-framework/getting-started/blob/28d3a7d0bce5838e0a3f8ad6a94b195e914684f0/README.md?

Note that you need:

  1. Create the project
  2. Add the API + controller
  3. Build the operator image and push it for your repo
  4. Update the deploy/operator.yaml to use your image
    ( Note that it should be accessible to be pulled from your cluster )
  5. Apply Memcached CRD and CR
  6. Apply operator.yaml , role.yaml, role_binding.yaml, service_account.yaml

Also, I'd recommend applying all in the same namespace.

To troubleshooting:

  • Check the pods and its logs (kubectl get pod and kubectl logs <pod-name>)
  • Also, you are able to check them by the ui/cluster console. If it is OCP check the events tab in the pod.

Please, let me know if with the above info and by following the PR changes you were able to make it works.

@skckadiyala
Copy link

Thanks @camilamacedo86 , the issue is resolved in my environment with the instructions in the PR.

@chrismld
Copy link

chrismld commented May 13, 2020

@camilamacedo86 I'm having the same problem using the operator sdk v0.17.0 in an EKS cluster, I've recreated the cluster, started from scratch with the project, and no luck.

When I see the logs of the memcached operator pod, I see the following:

{"level":"info","ts":1589383835.9011614,"logger":"cmd","msg":"Operator Version: 0.0.1"}
{"level":"info","ts":1589383835.9011846,"logger":"cmd","msg":"Go Version: go1.14.2"}
{"level":"info","ts":1589383835.9011924,"logger":"cmd","msg":"Go OS/Arch: linux/amd64"}
{"level":"info","ts":1589383835.9011998,"logger":"cmd","msg":"Version of operator-sdk: v0.17.0"}
{"level":"info","ts":1589383835.901354,"logger":"leader","msg":"Trying to become the leader."}
{"level":"info","ts":1589383836.2175784,"logger":"leader","msg":"No pre-existing lock was found."}
{"level":"info","ts":1589383836.2232208,"logger":"leader","msg":"Became the leader."}
{"level":"info","ts":1589383836.5271149,"logger":"controller-runtime.metrics","msg":"metrics server is starting to listen","addr":"0.0.0.0:8383"}
{"level":"info","ts":1589383836.5277941,"logger":"cmd","msg":"Registering Components."}
{"level":"info","ts":1589383837.161486,"logger":"metrics","msg":"Metrics Service object created","Service.Name":"memcached-operator-metrics","Service.Namespace":"default"}
{"level":"info","ts":1589383837.463712,"logger":"cmd","msg":"Could not create ServiceMonitor object","error":"no ServiceMonitor registered with the API"}
{"level":"info","ts":1589383837.4637368,"logger":"cmd","msg":"Install prometheus-operator in your cluster to create ServiceMonitor objects","error":"no ServiceMonitor registered with the API"}
{"level":"info","ts":1589383837.463749,"logger":"cmd","msg":"Starting the Cmd."}
{"level":"info","ts":1589383837.463958,"logger":"controller-runtime.manager","msg":"starting metrics server","path":"/metrics"}
{"level":"info","ts":1589383837.4641104,"logger":"controller-runtime.controller","msg":"Starting EventSource","controller":"memcached-controller","source":"kind source: /, Kind="}
E0513 15:30:37.465907       1 reflector.go:153] pkg/mod/k8s.io/[email protected]/tools/cache/reflector.go:105: Failed to list *v1alpha1.Memcached: memcacheds.cache.example.com is forbidden: User "system:serviceaccount:default:memcached-operator" cannot list resource "memcacheds" in API group "cache.example.com" at the cluster scope
E0513 15:30:38.467957       1 reflector.go:153] pkg/mod/k8s.io/[email protected]/tools/cache/reflector.go:105: Failed to list *v1alpha1.Memcached: memcacheds.cache.example.com is forbidden: User "system:serviceaccount:default:memcached-operator" cannot list resource "memcacheds" in API group "cache.example.com" at the cluster scope
E0513 15:30:39.470002       1 reflector.go:153] pkg/mod/k8s.io/[email protected]/tools/cache/reflector.go:105: Failed to list *v1alpha1.Memcached: memcacheds.cache.example.com is forbidden: User "system:serviceaccount:default:memcached-operator" cannot list resource "memcacheds" in API group "cache.example.com" at the cluster scope

And, if I run the following command to verify the SA permissions, I get a "yes" answer:

$ kubectl auth can-i list memcacheds --as system:serviceaccount:default:memcached-operator
yes

I'm not sure what I'm doing wrong but it's not working for me.

Update 1
I've installed the prometheus-operator in the cluster but still not working. I'm running everything in the default namespace.

Update 2
I fixed the problem, it's working now. What I did is that I reverted back the change of putting an empty string for the Namespace property as the guide suggests, build the image and generated the manifests again, then deploy and now it's working. I think the guide should be more clear about that, in the sense that "it's just a comment" ... for someone new (like me) trying the framework will do everything the guide says. I wanted to at least be able to follow the guide.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
kind/documentation Categorizes issue or PR as related to documentation. triage/support Indicates an issue that is a support question.
Projects
None yet
Development

No branches or pull requests

5 participants