Пример #1
0
def inventory_kube_pod(
    section_kube_pod_info: Optional[PodInfo],
    section_kube_pod_containers: Optional[PodContainers],
    section_kube_pod_init_containers: Optional[PodContainers],
    section_kube_pod_container_specs: Optional[ContainerSpecs],
    section_kube_pod_init_container_specs: Optional[ContainerSpecs],
) -> InventoryResult:
    if (section_kube_pod_info is None
            or section_kube_pod_container_specs is None
            or section_kube_pod_init_container_specs is None):
        return
    yield Attributes(
        path=["software", "applications", "kube", "metadata"],
        inventory_attributes={
            "name": section_kube_pod_info.name,
            "namespace": section_kube_pod_info.namespace,
        },
    )

    yield Attributes(
        path=["software", "applications", "kube", "pod"],
        inventory_attributes={
            "dns_policy": section_kube_pod_info.dns_policy,
            "host_ip": section_kube_pod_info.host_ip,
            "host_network": section_kube_pod_info.host_network,
            "node": section_kube_pod_info.node,
            "pod_ip": section_kube_pod_info.pod_ip,
            "qos_class": section_kube_pod_info.qos_class,
        },
    )
    yield from labels_to_table(section_kube_pod_info.labels)
    yield from _containers_to_table(section_kube_pod_container_specs,
                                    section_kube_pod_containers)
    yield from _containers_to_table(section_kube_pod_init_container_specs,
                                    section_kube_pod_init_containers)
Пример #2
0
def inventory_kube_daemonset(
    section_kube_daemonset_info: Optional[DaemonSetInfo],
    section_kube_update_strategy: Optional[UpdateStrategy],
) -> InventoryResult:
    if section_kube_daemonset_info is None or section_kube_update_strategy is None:
        return
    yield Attributes(
        path=["software", "applications", "kube", "metadata"],
        inventory_attributes={
            "object": "DaemonSet",
            "name": section_kube_daemonset_info.name,
            "namespace": section_kube_daemonset_info.namespace,
        },
    )
    selector = section_kube_daemonset_info.selector
    yield Attributes(
        path=["software", "applications", "kube", "daemonset"],
        inventory_attributes={
            "strategy":
            strategy_text(section_kube_update_strategy.strategy),
            "match_labels":
            match_labels_to_str(selector.match_labels),
            "match_expressions":
            match_expressions_to_str(selector.match_expressions),
        },
    )
    yield from labels_to_table(section_kube_daemonset_info.labels)
Пример #3
0
def inventory_kube_node(
    section_kube_node_info: Optional[NodeInfo],
    section_kube_node_kubelet: Optional[KubeletInfo],
) -> InventoryResult:
    if section_kube_node_info is None or section_kube_node_kubelet is None:
        return
    yield Attributes(
        path=["software", "applications", "kube", "metadata"],
        inventory_attributes={
            "name": section_kube_node_info.name,
        },
    )

    yield Attributes(
        path=["software", "applications", "kube", "node"],
        inventory_attributes={
            "operating_system": section_kube_node_info.operating_system,
            "os_image": section_kube_node_info.os_image,
            "kernel_version": section_kube_node_info.kernel_version,
            "architecture": section_kube_node_info.architecture,
            "container_runtime_version":
            section_kube_node_info.container_runtime_version,
            "kubelet_version": section_kube_node_kubelet.version,
            "kube_proxy_version": section_kube_node_kubelet.proxy_version,
        },
    )
    for address in section_kube_node_info.addresses:
        yield TableRow(
            path=["software", "applications", "kube", "network"],
            key_columns={"ip": address.address},
            inventory_columns={"address_type": address.type_},
        )
    yield from labels_to_table(section_kube_node_info.labels)
Пример #4
0
def inventory_kube_deployment(
    section_kube_deployment_info: Optional[DeploymentInfo],
    section_kube_deployment_strategy: Optional[DeploymentStrategy],
) -> InventoryResult:
    if section_kube_deployment_info is None or section_kube_deployment_strategy is None:
        return
    selector = section_kube_deployment_info.selector
    yield Attributes(
        path=["software", "applications", "kube", "deployment"],
        inventory_attributes={
            "name":
            section_kube_deployment_info.name,
            "namespace":
            section_kube_deployment_info.namespace,
            "strategy":
            strategy_text(section_kube_deployment_strategy.strategy),
            "match_labels":
            match_labels_to_str(selector.match_labels),
            "match_expressions":
            match_expressions_to_str(selector.match_expressions),
        },
    )
    yield from labels_to_table(section_kube_deployment_info.labels)