Skip to content
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

Update KubeLibrary.py: Keywords added to get replicaset #83

Closed
wants to merge 3 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions src/KubeLibrary/KubeLibrary.py
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,24 @@ def get_deployments_in_namespace(self, name_pattern, namespace, label_selector="
r = re.compile(name_pattern)
deployments = [item for item in ret.items if r.match(item.metadata.name)]
return deployments

def get_replicasets_in_namespace(self, name_pattern, namespace, label_selector=""):
"""Gets replicasets matching pattern in given namespace.

Can be optionally filtered by label. e.g. label_selector=label_key=label_value

Returns list of replicasets.

- ``name_pattern``:
replicaset name pattern to check
- ``namespace``:
Namespace to check
"""
ret = self.appsv1.list_namespaced_replica_set(namespace, watch=False, label_selector=label_selector)
r = re.compile(name_pattern)
replicasets = [item for item in ret.items if r.match(item.metadata.name)]
return replicasets

def get_jobs_in_namespace(self, name_pattern, namespace, label_selector=""):
"""Gets jobs matching pattern in given namespace.

Expand Down