-
Notifications
You must be signed in to change notification settings - Fork 16
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
local gctl: auto set namespace selector against watch #102
Comments
@AmitKumarDas maybe could you elaborate what is needed to achieve this behavior ? |
I will try to explain via a sample config for GenericController. NOTE: Metac config is a yaml file with schema that adheres to one or more GenericController(s). This config is typically placed at NOTE: Refer https://github.com/AmitKumarDas/metac/blob/master/start/start.go to learn on this mode of running metac NOTE: In my use-case this binary is a golang project that uses metac as a library Following is a sample config that makes use of 2 GenericControllers. On the whole, we want the metac binary to start informers for watches with kind CStorClusterPlan & CStorClusterStorageSet apiVersion: metac.openebs.io/v1alpha1
kind: GenericController
metadata:
name: sync-plan
namespace: cspauto
spec:
# I want to watch kind CStorClusterPlan that are created under namespace
# that matches the namespace of metac binary (that has this config file)
watch:
apiVersion: dao.mayadata.io/v1alpha1
resource: cstorclusterplans
attachments:
- apiVersion: dao.mayadata.io/v1alpha1
resource: cstorclusterstoragesets
updateStrategy:
method: InPlace
- apiVersion: dao.mayadata.io/v1alpha1
resource: cstorclusterconfigs
hooks:
sync:
inline:
funcName: sync/cstorclusterplan
---
apiVersion: metac.openebs.io/v1alpha1
kind: GenericController
metadata:
name: sync-storageset
namespace: cspauto
spec:
# I want to watch kind CStorClusterStorageSet that are created under namespace
# that matches the namespace of metac binary (that has this config file)
watch:
apiVersion: dao.mayadata.io/v1alpha1
resource: cstorclusterstoragesets
attachments:
- apiVersion: dao.mayadata.io/v1alpha1
resource: storages
updateStrategy:
method: InPlace
hooks:
sync:
inline:
funcName: sync/cstorclusterstorageset Coming back to the problem statement, I would like to spin up multiple metac binaries in dedicated namespaces. I want each binary to lookup up the watches that belong to its own namespace & proceed with its reconciliation. Possible solution:We can define following new environment variables e.g.:
Now when metac starts, the resulting GenericControllers will be like following: apiVersion: metac.openebs.io/v1alpha1
kind: GenericController
metadata:
name: sync-plan
namespace: cspauto
spec:
watch:
apiVersion: dao.mayadata.io/v1alpha1
resource: cstorclusterplans
advancedSelector:
selectorTerms:
- matchFields:
metadata.namespace: <POD's namesapce>
attachments:
- apiVersion: dao.mayadata.io/v1alpha1
resource: cstorclusterstoragesets
updateStrategy:
method: InPlace
- apiVersion: dao.mayadata.io/v1alpha1
resource: cstorclusterconfigs
hooks:
sync:
inline:
funcName: sync/cstorclusterplan
---
apiVersion: metac.openebs.io/v1alpha1
kind: GenericController
metadata:
name: sync-storageset
namespace: cspauto
spec:
watch:
apiVersion: dao.mayadata.io/v1alpha1
resource: cstorclusterstoragesets
advancedSelector:
selectorTerms:
- matchFields:
metadata.namespace: <POD's namesapce>
attachments:
- apiVersion: dao.mayadata.io/v1alpha1
resource: storages
updateStrategy:
method: InPlace
hooks:
sync:
inline:
funcName: sync/cstorclusterstorageset Above is applicable when metac binary runs by looking up its config file (described above). In other words metac was started with following args: args:
- --run-as-local |
Problem Statement: I would like to use Metac as a library that is packaged as my own binary. This binary will get deployed as a Kubernetes Deployment or STS. I would like to use MetaController CR as a config that should only consider watches in this Deployment/STS namespace.
The text was updated successfully, but these errors were encountered: