operator-framework / ansible-operator-plugins

Experimental extraction/refactoring of the Operator SDK's ansible operator plugin
Apache License 2.0
7 stars 17 forks source link

can ansible operator watch a specific k8s resource #34

Open aravinder111 opened 4 years ago

aravinder111 commented 4 years ago

Type of question

Are you asking about community best practices, how to implement a specific feature, or about general context and help around the operator-sdk? Help with operator-sdk's Ansible operator pattern

Question

What did you do? I would like to watch a specific k8s resource, to be specific I want to watch a configmap which is not created by my role. Whenever there is a change to the configmap, I want to reconcile my role.

What did you expect to see? An optional field name to be specified in watches.yaml

What did you see instead? Under which circumstances? I dont see an option to watch a specific resource by its name in documentation https://sdk.operatorframework.io/docs/ansible/reference/watches/

Environment

operator-sdk version: "v0.17.0", commit: "2fd7019f856cdb6f6618e2c3c80d15c3c79d1b6c", kubernetes version: "v1.17.2", go version: "go1.14.2 darwin/amd64"
aravinder111 commented 4 years ago

Slack conversation regarding the ask mentioned above is here

camilamacedo86 commented 4 years ago

With Ansible operator is possible to watch the resources which are dependent. See; https://sdk.operatorframework.io/docs/ansible/reference/dependent-watches/

But, confirmed with @fabianvf that currently has not a way to scope the operator to a single resource (other than checking and ending early from Ansible)

So, it will be flagged as RFE and will be discussed in the next triage meeting.

estroz commented 4 years ago

/cc @fabianvf

openshift-bot commented 3 years ago

Issues go stale after 90d of inactivity.

Mark the issue as fresh by commenting /remove-lifecycle stale. Stale issues rot after an additional 30d of inactivity and eventually close. Exclude this issue from closing by commenting /lifecycle frozen.

If this issue is safe to close now please do so with /close.

/lifecycle stale

openshift-bot commented 3 years ago

Stale issues rot after 30d of inactivity.

Mark the issue as fresh by commenting /remove-lifecycle rotten. Rotten issues close after an additional 30d of inactivity. Exclude this issue from closing by commenting /lifecycle frozen.

If this issue is safe to close now please do so with /close.

/lifecycle rotten /remove-lifecycle stale

camilamacedo86 commented 3 years ago

/remove-lifecycle rotten

c/c @asmacdo @fabianvf

openshift-bot commented 3 years ago

Issues go stale after 90d of inactivity.

Mark the issue as fresh by commenting /remove-lifecycle stale. Stale issues rot after an additional 30d of inactivity and eventually close. Exclude this issue from closing by commenting /lifecycle frozen.

If this issue is safe to close now please do so with /close.

/lifecycle stale

fabianvf commented 3 years ago

@estroz is this supported from golang operators (I assume it is?). If so, we do probably want to add this functionality to keep parity

estroz commented 3 years ago

Yes if a predicate is used that filters by name. Perhaps allowing multiple names per GVK?

Side note: requests like this are really good reasons to use a Go-Ansible hybrid operator; this particularly request is easy to implement and the watches API change is small, so conversion to a hybrid operator isn’t necessary.

openshift-bot commented 3 years ago

Stale issues rot after 30d of inactivity.

Mark the issue as fresh by commenting /remove-lifecycle rotten. Rotten issues close after an additional 30d of inactivity. Exclude this issue from closing by commenting /lifecycle frozen.

If this issue is safe to close now please do so with /close.

/lifecycle rotten /remove-lifecycle stale

fabianvf commented 3 years ago

/lifecycle frozen

absynth76 commented 3 years ago

small remark: I think it's implemented using predicates on golang operator, but it's at reconciliation time that the decision is made to pick up or not the resource. It's also possible with ansible, you can watch all configmaps and execute your action only if the configmap respect your requirements (name/annotation/label, you only have to query for the configmap and filter according to your needs) I don't think this is optimal because you'll actually watch all configmaps, but it does work.

niuxiaojuan-github commented 2 years ago

We also need this feature, can this be implemented soon?

laurieaw63 commented 2 years ago

Side note: requests like this are really good reasons to use a Go-Ansible hybrid operator; this particularly request is easy to implement and the watches API change is small, so conversion to a hybrid operator isn’t necessary.

Is there an example somewhere that demonstrates a hybrid?