<@ULVA73B9P> in this code snippet, what is plural ...
# ask-marvin
p
@Marvin in this code snippet, what is plural and what is group? would you give me an example?
Copy code
from prefect import flow
from prefect_kubernetes.credentials import KubernetesCredentials
from prefect_kubernetes.custom_objects import get_namespaced_custom_object

@flow
def kubernetes_orchestrator():
    custom_object_metadata = get_namespaced_custom_object(
        kubernetes_credentials=KubernetesCredentials.load("k8s-creds"),
        group="crd-group",
        version="crd-version",
        plural="crd-plural",
        name="my-custom-object",
    )
m
In the code snippet you provided, we're looking at part of an orchestration script written with Prefect, which interfaces with Kubernetes. `plural`: This refers to the plural form of the
kind
of the Kubernetes Custom Resource Definition (CRD). For example, if the
kind
is
Pod
, the
plural
might be
pods
. `group`: This is the name of the API group that the Custom Resource Definition (CRD) belongs to. Kubernetes supports multiple API groups to extend its functionality, and CRDs can be a part of custom groups. As for an example, suppose you have a Kubernetes cluster with a custom resource of kind
MyCustomResource
and you have defined a CRD for it. Let's also assume your CRD is within the group
<http://example.com|example.com>
and the version is
v1alpha1
. The
plural
might be defined as
mycustomresources
because you typically access multiple instances of the resource at a time. Your Python code would look something like this:
Copy code
python
from prefect import flow
from prefect_kubernetes.credentials import KubernetesCredentials
from prefect_kubernetes.custom_objects import get_namespaced_custom_object

@flow
def kubernetes_orchestrator():
    custom_object_metadata = get_namespaced_custom_object(
        kubernetes_credentials=KubernetesCredentials.load("k8s-creds"),
        group="<http://example.com|example.com>",
        version="v1alpha1",
        plural="mycustomresources",
        name="my-custom-object-name",
    )
Here,
mycustomresources
is the
plural
indicating how you refer to the resources in API calls, and
<http://example.com|example.com>
is the
group
specifying the grouping under the Kubernetes API groups.
my-custom-object-name
is the specific name of the custom object instance you want to retrieve.