nebula-kubernetes


Namenebula-kubernetes JSON
Version 1.0.0 PyPI version JSON
download
home_pagehttps://github.com/kozmoai/nebula-kubernetes
SummaryNebula integrations for interacting with Kubernetes.
upload_time2024-03-24 11:20:04
maintainerNone
docs_urlNone
authorKozmoai, Inc.
requires_python>=3.7
licenseApache License 2.0
keywords nebula
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # nebula-kubernetes

<p align="center">
    <a href="https://pypi.python.org/pypi/nebula-kubernetes/" alt="PyPI version">
        <img alt="PyPI" src="https://img.shields.io/pypi/v/nebula-kubernetes?color=26272B&labelColor=090422"></a>
    <a href="https://github.com/kozmoai/nebula-kubernetes/" alt="Stars">
        <img src="https://img.shields.io/github/stars/kozmoai/nebula-kubernetes?color=26272B&labelColor=090422" /></a>
    <a href="https://pypistats.org/packages/nebula-kubernetes/" alt="Downloads">
        <img src="https://img.shields.io/pypi/dm/nebula-kubernetes?color=26272B&labelColor=090422" /></a>
    <a href="https://github.com/kozmoai/nebula-kubernetes/pulse" alt="Activity">
        <img src="https://img.shields.io/github/commit-activity/m/kozmoai/nebula-kubernetes?color=26272B&labelColor=090422" /></a>
    <br>
    <a href="https://nebula-community.slack.com" alt="Slack">
        <img src="https://img.shields.io/badge/slack-join_community-red.svg?color=26272B&labelColor=090422&logo=slack" /></a>

</p>


## Welcome!

`nebula-kubernetes` is a collection of Nebula tasks, flows, and blocks enabling orchestration, observation and management of Kubernetes resources.

Jump to [examples](#example-usage).

## Resources

For more tips on how to use tasks and flows in a Collection, check out [Using Collections](https://docs.nebula.io/collections/usage/)!

### Installation
Install `nebula-kubernetes` with `pip`:
```bash
 pip install nebula-kubernetes
 ```

Requires an installation of Python 3.8+.

We recommend using a Python virtual environment manager such as pipenv, conda or virtualenv.

These tasks are designed to work with Nebula 2. For more information about how to use Nebula, please refer to the [Nebula documentation](https://docs.nebula.io/).

Then, to register [blocks](https://docs.nebula.io/ui/blocks/) on Nebula Cloud:

```bash
nebula block register -m nebula_kubernetes
```

Note, to use the `load` method on Blocks, you must already have a block document [saved through code](https://docs.nebula.io/concepts/blocks/#saving-blocks) or saved through the UI.


### Example Usage

#### Use `with_options` to customize options on any existing task or flow

```python
from nebula_kubernetes.flows import run_namespaced_job

customized_run_namespaced_job = run_namespaced_job.with_options(
    name="My flow running a Kubernetes Job",
    retries=2,
    retry_delay_seconds=10,
) # this is now a new flow object that can be called
```

For more tips on how to use tasks and flows in a Collection, check out [Using Collections](https://docs.nebula.io/collections/usage/)!


#### Specify and run a Kubernetes Job from a yaml file

```python
from nebula_kubernetes.credentials import KubernetesCredentials
from nebula_kubernetes.flows import run_namespaced_job # this is a flow
from nebula_kubernetes.jobs import KubernetesJob

k8s_creds = KubernetesCredentials.load("k8s-creds")

job = KubernetesJob.from_yaml_file( # or create in the UI with a dict manifest
    credentials=k8s_creds,
    manifest_path="path/to/job.yaml",
)

job.save("my-k8s-job", overwrite=True)

if __name__ == "__main__":
    # run the flow
    run_namespaced_job(job)
```

#### Generate a resource-specific client from `KubernetesClusterConfig`

```python
# with minikube / docker desktop & a valid ~/.kube/config this should ~just work~
from nebula.blocks.kubernetes import KubernetesClusterConfig
from nebula_kubernetes.credentials import KubernetesCredentials

k8s_config = KubernetesClusterConfig.from_file('~/.kube/config')

k8s_credentials = KubernetesCredentials(cluster_config=k8s_config)

with k8s_credentials.get_client("core") as v1_core_client:
    for namespace in v1_core_client.list_namespace().items:
        print(namespace.metadata.name)
```


#### List jobs in a specific namespace

```python
from nebula import flow
from nebula_kubernetes.credentials import KubernetesCredentials
from nebula_kubernetes.jobs import list_namespaced_job

@flow
def kubernetes_orchestrator():
    v1_job_list = list_namespaced_job(
        kubernetes_credentials=KubernetesCredentials.load("k8s-creds"),
        namespace="my-namespace",
    )
```

#### Patch an existing deployment

```python
from kubernetes.client.models import V1Deployment

from nebula import flow
from nebula_kubernetes.credentials import KubernetesCredentials
from nebula_kubernetes.deployments import patch_namespaced_deployment
from nebula_kubernetes.utilities import convert_manifest_to_model

@flow
def kubernetes_orchestrator():

    v1_deployment_updates = convert_manifest_to_model(
        manifest="path/to/manifest.yaml",
        v1_model_name="V1Deployment",
    )

    v1_deployment = patch_namespaced_deployment(
        kubernetes_credentials=KubernetesCredentials.load("k8s-creds"),
        deployment_name="my-deployment",
        deployment_updates=v1_deployment_updates,
        namespace="my-namespace"
    )
```

## Feedback

If you encounter any bugs while using `nebula-kubernetes`, feel free to open an issue in the [nebula-kubernetes](https://github.com/kozmoai/nebula-kubernetes) repository.

If you have any questions or issues while using `nebula-kubernetes`, you can find help in either the [Nebula Discourse forum](https://discourse.nebula.io/) or the [Nebula Slack community](https://nebula.io/slack).

Feel free to star or watch [`nebula-kubernetes`](https://github.com/kozmoai/nebula-kubernetes) for updates too!

## Contributing

If you'd like to help contribute to fix an issue or add a feature to `nebula-kubernetes`, please [propose changes through a pull request from a fork of the repository](https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/proposing-changes-to-your-work-with-pull-requests/creating-a-pull-request-from-a-fork).
 
Here are the steps:
 
1. [Fork the repository](https://docs.github.com/en/get-started/quickstart/fork-a-repo#forking-a-repository)
2. [Clone the forked repository](https://docs.github.com/en/get-started/quickstart/fork-a-repo#cloning-your-forked-repository)
3. Install the repository and its dependencies:
```
 pip install -e ".[dev]"
```
4. Make desired changes
5. Add tests
6. Insert an entry to [CHANGELOG.md](https://github.com/kozmoai/nebula-kubernetes/blob/main/CHANGELOG.md)
7. Install `pre-commit` to perform quality checks prior to commit:
```
 pre-commit install
 ```
8. `git commit`, `git push`, and create a pull request

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/kozmoai/nebula-kubernetes",
    "name": "nebula-kubernetes",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.7",
    "maintainer_email": null,
    "keywords": "nebula",
    "author": "Kozmoai, Inc.",
    "author_email": "help@nebula.io",
    "download_url": "https://files.pythonhosted.org/packages/70/73/8096142285c85194d2950cd67d0e7fbe3c17b04569b3ae3d770e8b7efd7b/nebula-kubernetes-1.0.0.tar.gz",
    "platform": null,
    "description": "# nebula-kubernetes\n\n<p align=\"center\">\n    <a href=\"https://pypi.python.org/pypi/nebula-kubernetes/\" alt=\"PyPI version\">\n        <img alt=\"PyPI\" src=\"https://img.shields.io/pypi/v/nebula-kubernetes?color=26272B&labelColor=090422\"></a>\n    <a href=\"https://github.com/kozmoai/nebula-kubernetes/\" alt=\"Stars\">\n        <img src=\"https://img.shields.io/github/stars/kozmoai/nebula-kubernetes?color=26272B&labelColor=090422\" /></a>\n    <a href=\"https://pypistats.org/packages/nebula-kubernetes/\" alt=\"Downloads\">\n        <img src=\"https://img.shields.io/pypi/dm/nebula-kubernetes?color=26272B&labelColor=090422\" /></a>\n    <a href=\"https://github.com/kozmoai/nebula-kubernetes/pulse\" alt=\"Activity\">\n        <img src=\"https://img.shields.io/github/commit-activity/m/kozmoai/nebula-kubernetes?color=26272B&labelColor=090422\" /></a>\n    <br>\n    <a href=\"https://nebula-community.slack.com\" alt=\"Slack\">\n        <img src=\"https://img.shields.io/badge/slack-join_community-red.svg?color=26272B&labelColor=090422&logo=slack\" /></a>\n\n</p>\n\n\n## Welcome!\n\n`nebula-kubernetes` is a collection of Nebula tasks, flows, and blocks enabling orchestration, observation and management of Kubernetes resources.\n\nJump to [examples](#example-usage).\n\n## Resources\n\nFor more tips on how to use tasks and flows in a Collection, check out [Using Collections](https://docs.nebula.io/collections/usage/)!\n\n### Installation\nInstall `nebula-kubernetes` with `pip`:\n```bash\n pip install nebula-kubernetes\n ```\n\nRequires an installation of Python 3.8+.\n\nWe recommend using a Python virtual environment manager such as pipenv, conda or virtualenv.\n\nThese tasks are designed to work with Nebula 2. For more information about how to use Nebula, please refer to the [Nebula documentation](https://docs.nebula.io/).\n\nThen, to register [blocks](https://docs.nebula.io/ui/blocks/) on Nebula Cloud:\n\n```bash\nnebula block register -m nebula_kubernetes\n```\n\nNote, to use the `load` method on Blocks, you must already have a block document [saved through code](https://docs.nebula.io/concepts/blocks/#saving-blocks) or saved through the UI.\n\n\n### Example Usage\n\n#### Use `with_options` to customize options on any existing task or flow\n\n```python\nfrom nebula_kubernetes.flows import run_namespaced_job\n\ncustomized_run_namespaced_job = run_namespaced_job.with_options(\n    name=\"My flow running a Kubernetes Job\",\n    retries=2,\n    retry_delay_seconds=10,\n) # this is now a new flow object that can be called\n```\n\nFor more tips on how to use tasks and flows in a Collection, check out [Using Collections](https://docs.nebula.io/collections/usage/)!\n\n\n#### Specify and run a Kubernetes Job from a yaml file\n\n```python\nfrom nebula_kubernetes.credentials import KubernetesCredentials\nfrom nebula_kubernetes.flows import run_namespaced_job # this is a flow\nfrom nebula_kubernetes.jobs import KubernetesJob\n\nk8s_creds = KubernetesCredentials.load(\"k8s-creds\")\n\njob = KubernetesJob.from_yaml_file( # or create in the UI with a dict manifest\n    credentials=k8s_creds,\n    manifest_path=\"path/to/job.yaml\",\n)\n\njob.save(\"my-k8s-job\", overwrite=True)\n\nif __name__ == \"__main__\":\n    # run the flow\n    run_namespaced_job(job)\n```\n\n#### Generate a resource-specific client from `KubernetesClusterConfig`\n\n```python\n# with minikube / docker desktop & a valid ~/.kube/config this should ~just work~\nfrom nebula.blocks.kubernetes import KubernetesClusterConfig\nfrom nebula_kubernetes.credentials import KubernetesCredentials\n\nk8s_config = KubernetesClusterConfig.from_file('~/.kube/config')\n\nk8s_credentials = KubernetesCredentials(cluster_config=k8s_config)\n\nwith k8s_credentials.get_client(\"core\") as v1_core_client:\n    for namespace in v1_core_client.list_namespace().items:\n        print(namespace.metadata.name)\n```\n\n\n#### List jobs in a specific namespace\n\n```python\nfrom nebula import flow\nfrom nebula_kubernetes.credentials import KubernetesCredentials\nfrom nebula_kubernetes.jobs import list_namespaced_job\n\n@flow\ndef kubernetes_orchestrator():\n    v1_job_list = list_namespaced_job(\n        kubernetes_credentials=KubernetesCredentials.load(\"k8s-creds\"),\n        namespace=\"my-namespace\",\n    )\n```\n\n#### Patch an existing deployment\n\n```python\nfrom kubernetes.client.models import V1Deployment\n\nfrom nebula import flow\nfrom nebula_kubernetes.credentials import KubernetesCredentials\nfrom nebula_kubernetes.deployments import patch_namespaced_deployment\nfrom nebula_kubernetes.utilities import convert_manifest_to_model\n\n@flow\ndef kubernetes_orchestrator():\n\n    v1_deployment_updates = convert_manifest_to_model(\n        manifest=\"path/to/manifest.yaml\",\n        v1_model_name=\"V1Deployment\",\n    )\n\n    v1_deployment = patch_namespaced_deployment(\n        kubernetes_credentials=KubernetesCredentials.load(\"k8s-creds\"),\n        deployment_name=\"my-deployment\",\n        deployment_updates=v1_deployment_updates,\n        namespace=\"my-namespace\"\n    )\n```\n\n## Feedback\n\nIf you encounter any bugs while using `nebula-kubernetes`, feel free to open an issue in the [nebula-kubernetes](https://github.com/kozmoai/nebula-kubernetes) repository.\n\nIf you have any questions or issues while using `nebula-kubernetes`, you can find help in either the [Nebula Discourse forum](https://discourse.nebula.io/) or the [Nebula Slack community](https://nebula.io/slack).\n\nFeel free to star or watch [`nebula-kubernetes`](https://github.com/kozmoai/nebula-kubernetes) for updates too!\n\n## Contributing\n\nIf you'd like to help contribute to fix an issue or add a feature to `nebula-kubernetes`, please [propose changes through a pull request from a fork of the repository](https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/proposing-changes-to-your-work-with-pull-requests/creating-a-pull-request-from-a-fork).\n \nHere are the steps:\n \n1. [Fork the repository](https://docs.github.com/en/get-started/quickstart/fork-a-repo#forking-a-repository)\n2. [Clone the forked repository](https://docs.github.com/en/get-started/quickstart/fork-a-repo#cloning-your-forked-repository)\n3. Install the repository and its dependencies:\n```\n pip install -e \".[dev]\"\n```\n4. Make desired changes\n5. Add tests\n6. Insert an entry to [CHANGELOG.md](https://github.com/kozmoai/nebula-kubernetes/blob/main/CHANGELOG.md)\n7. Install `pre-commit` to perform quality checks prior to commit:\n```\n pre-commit install\n ```\n8. `git commit`, `git push`, and create a pull request\n",
    "bugtrack_url": null,
    "license": "Apache License 2.0",
    "summary": "Nebula integrations for interacting with Kubernetes.",
    "version": "1.0.0",
    "project_urls": {
        "Homepage": "https://github.com/kozmoai/nebula-kubernetes"
    },
    "split_keywords": [
        "nebula"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "9d833cf163fab30537c809a4cbe3974bbe28a3e8cfb29b2a7a4d8988dabf6032",
                "md5": "d07305824368fb0cb832ac2e8aaf080c",
                "sha256": "cdcb20077f8e031cbd708ebd207796095589b26916eb81e4937d386f96fdd0e8"
            },
            "downloads": -1,
            "filename": "nebula_kubernetes-1.0.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "d07305824368fb0cb832ac2e8aaf080c",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.7",
            "size": 38352,
            "upload_time": "2024-03-24T11:20:01",
            "upload_time_iso_8601": "2024-03-24T11:20:01.667230Z",
            "url": "https://files.pythonhosted.org/packages/9d/83/3cf163fab30537c809a4cbe3974bbe28a3e8cfb29b2a7a4d8988dabf6032/nebula_kubernetes-1.0.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "70738096142285c85194d2950cd67d0e7fbe3c17b04569b3ae3d770e8b7efd7b",
                "md5": "11a52f0229a74c86c5f9b43391805356",
                "sha256": "186bf9d3eb4cf984dc8dd100656963db494072c078c2723ef837704397a9f41b"
            },
            "downloads": -1,
            "filename": "nebula-kubernetes-1.0.0.tar.gz",
            "has_sig": false,
            "md5_digest": "11a52f0229a74c86c5f9b43391805356",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.7",
            "size": 72648,
            "upload_time": "2024-03-24T11:20:04",
            "upload_time_iso_8601": "2024-03-24T11:20:04.565642Z",
            "url": "https://files.pythonhosted.org/packages/70/73/8096142285c85194d2950cd67d0e7fbe3c17b04569b3ae3d770e8b7efd7b/nebula-kubernetes-1.0.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-03-24 11:20:04",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "kozmoai",
    "github_project": "nebula-kubernetes",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "requirements": [],
    "lcname": "nebula-kubernetes"
}
        
Elapsed time: 0.69675s