https://github.com/agnostiqhq/covalent-kubernetes-plugin

Executor plugin interfacing Covalent with Kubernetes

https://github.com/agnostiqhq/covalent-kubernetes-plugin

Science Score: 39.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
    Found .zenodo.json file
  • DOI references
    Found 2 DOI reference(s) in README
  • Academic publication links
  • Committers with academic emails
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (11.1%) to scientific vocabulary

Keywords

cloud-computing docker elastic-kubernetes-service etl kubernetes parallelization pipelines python python3 workflow

Keywords from Contributors

covalent quantum-computing quantum-machine-learning data-pipeline hpc-applications machinelearning-python orchestration quantum workflow-automation workflow-management
Last synced: 6 months ago · JSON representation

Repository

Executor plugin interfacing Covalent with Kubernetes

Basic Info
  • Host: GitHub
  • Owner: AgnostiqHQ
  • License: apache-2.0
  • Language: Python
  • Default Branch: develop
  • Homepage: https://agnostiq.ai/covalent
  • Size: 336 KB
Statistics
  • Stars: 9
  • Watchers: 10
  • Forks: 1
  • Open Issues: 10
  • Releases: 1
Topics
cloud-computing docker elastic-kubernetes-service etl kubernetes parallelization pipelines python python3 workflow
Created over 3 years ago · Last pushed 6 months ago
Metadata Files
Readme Changelog Contributing License Code of conduct

README.md

 

 

Covalent Kubernetes Plugin

Covalent is a Pythonic workflow tool used to execute tasks on advanced computing hardware. This executor plugin interfaces Covalent with Kubernetes clusters. In order for workflows to be deployable, users must be authenticated to an existing Kubernetes cluster. Users can view their Kubernetes configuration file and validate the connection using the commands

kubectl config view kubectl get nodes

Users who simply wish to test the plugin on minimal infrastructure should skip to the deployment instructions in the following sections.

Installation

To use this plugin with Covalent, simply install it using pip:

pip install covalent-kubernetes-plugin

Users can optionally enable support for AWS Elastic Kubernetes Service using

pip install covalent-kubernetes-plugin[aws]

You will also need to install Docker to use this plugin.

Configuration

The following shows a reference of a Covalent configuration:

[executors.k8s] base_image = "python:3.8-slim-bullseye" k8s_config_file = "/home/user/.kube/config" k8s_context = "minikube" registry = "localhost" registry_credentials_file = "" data_store = "/tmp" vcpu = "500m" memory = "1G" cache_dir = "/home/user/.cache/covalent" poll_freq = 10

This describes a configuration for a minimal local deployment with images and data stores also located on the local machine.

Example workflow

Next, interact with the Kubernetes backend via Covalent by declaring an executor class object and attaching it to an electron:

``` import covalent as ct from covalentkubernetesplugin.k8s import KubernetesExecutor

localk8sexecutor = KubernetesExecutor( k8s_context="minikube" vcpu="100m", memory="500Mi" )

eksexecutor = KubernetesExecutor( k8scontext=user@covalent-eks-cluster.us-east-1.eksctl.io, imagerepo="covalent-eks-task", registry="<accountid>.dkr.ecr.us-east-1.amazonaws.com", datastore="s3://<bucketname>//", vcpu="2.0", memory="4G" )

Run on a local cluster

@ct.electron(executor=localk8sexecutor) def join_words(a, b): return ", ".join([a, b])

Run on the cloud

@ct.electron(executor=eks_executor) def excitement(a): return f"{a}!"

Construct a workflow

@ct.lattice def simpleworkflow(a, b): phrase = joinwords(a, b) return excitement(phrase)

Dispatch the workflow

dispatchid = ct.dispatch(simpleworkflow)("Hello", "World")

```

For more information about how to get started with Covalent, check out the project homepage and the official documentation.

Local deployment with minikube

First, install kubectl as well as minikube following the instructions here. One or both of these may be available through your system's package manager.

Cluster deployment

Next, create a basic minikube cluster:

minikube start

From here you can view the UI using the command minikube dashboard which should open a page in your browser.

Before deploying the job, you will need to mount the Covalent cache directory so the Covalent server can communicate with the task container:

minikube mount ~/.cache/covalent:/data

If you experience a Connection refused error, ensure that the subnet used by minikube is whitelisted in your firewall. If you use iptables, you can use these commands:

iptables -A INPUT -s 192.168.49.0/24 -j ACCEPT iptables-save

Task deployment

Next, deploy the test job using the command

kubectl apply -f infra/sample_job.yaml

which should return job.batch/covalent-k8s-test created. You can view the status move from pending to succeeded on the dashboard. After some time, query the status of the job with

kubectl describe jobs/covalent-k8s-test

which returns

``` Name: test Namespace: default Selector: controller-uid=eaa319c3-4440-4411-b178-6289398cdb6a Labels: controller-uid=eaa319c3-4440-4411-b178-6289398cdb6a job-name=covalent-k8s-test Annotations: Parallelism: 1 Completions: 1 Completion Mode: NonIndexed Start Time: Thu, 21 Jul 2022 14:25:55 -0400 Completed At: Thu, 21 Jul 2022 14:26:06 -0400 Duration: 11s Pods Statuses: 0 Active (0 Ready) / 1 Succeeded / 0 Failed Pod Template: Labels: controller-uid=eaa319c3-4440-4411-b178-6289398cdb6a job-name=test Containers: test: Image: hello-world:latest Port: Host Port: Environment: Mounts: Volumes: Events: Type Reason Age From Message


Normal SuccessfulCreate 112s job-controller Created pod: test-5fs64 Normal Completed 101s job-controller Job completed ```

You are now ready to use the Covalent Kubernetes Plugin with your minikube cluster!

Reference configuration

The steps above generated the following authentication and configuration settings:

```

kubectl config view --minify apiVersion: v1 clusters: - cluster: certificate-authority: /home/user/.minikube/ca.crt extensions: - extension: last-update: Sun, 24 Jul 2022 16:09:01 EDT provider: minikube.sigs.k8s.io version: v1.26.0 name: clusterinfo server: https://192.168.59.100:8443 name: minikube contexts: - context: cluster: minikube extensions: - extension: last-update: Sun, 24 Jul 2022 16:09:01 EDT provider: minikube.sigs.k8s.io version: v1.26.0 name: contextinfo namespace: default user: minikube name: minikube current-context: minikube kind: Config preferences: {} users: - name: minikube user: client-certificate: /home/user/.minikube/profiles/minikube/client.crt client-key: /home/user/.minikube/profiles/minikube/client.key ```

Cleanup

When you are done using your cluster, delete it:

minikube delete

AWS Elastic Kubernetes Service deployment with Terraform

This section assumes you have already downloaded and configured the AWS CLI tool with an IAM user who has permissions to create an EKS cluster. To get started, download and install Terraform.

Cluster deployment

You can edit the input variables by copying the file infra/defaults.tfvars to infra/.tfvars and editing the contents.

Next, run the following:

make deploy

It may take 15 to 20 minutes to deploy this infrastructure. Note that AWS charges \$0.10 per hour for EKS clusters and EC2 instances vary in price. Running this command will cost money on AWS.

To view the Kubernetes dashboard, update your KUBECONFIG environment variable as instructed in the deployment output, run kubectl proxy and then navigate to the dashboard. It may take some time for resources to initially appear.

Adding users

Initially only the user who created the cluster will be able to access it. To view the auth config map, run

kubectl -n kube-system get configmap aws-auth -o yaml

We can add another IAM user newuser as a cluster administrator using

kubectl -n kube-system edit configmap aws-auth

and inserting the following entry:

data: mapUsers: | - userarn: arn:aws:iam::<account_id>:user/newuser username: newuser groups: - system:masters

The IAM user should not need any additional permissions.

Task deployment

Make sure the context is properly set, check with

kubectl config get-contexts

If it is set to anything other than the EKS cluster, execute

kubectl config use-context <my-cluster-name>

You can now deploy a job using the same method as you did with minikube.

To view the status of jobs, run

kubectl describe jobs --selector=job-name=test

Reference configuration

The steps above generated the following authentication and configuration settings:

```

kubectl get configmap -n kube-system aws-auth -o yaml apiVersion: v1 data: mapRoles: | - groups: - system:bootstrappers - system:nodes rolearn: arn:aws:iam:::role/covalent-eks-cluster-nodegroup-NodeInstanceRole-1VH95YLZKOX47 username: system:node:{{EC2PrivateDNSName}} - groups: - system:bootstrappers - system:nodes rolearn: arn:aws:iam:::role/covalent-eks-cluster-nodegroup-NodeInstanceRole-1NDG6XAZXQKJM username: system:node:{{EC2PrivateDNSName}} mapUsers: | - userarn: "arn:aws:iam:::user/newuser" username: newuser groups: - system:masters kind: ConfigMap

kubectl config view --minify apiVersion: v1 clusters: - cluster: certificate-authority-data: DATA+OMITTED server: https://0A418BB2CE053D6E26E86072C9B2BAFF.yl4.us-east-1.eks.amazonaws.com name: arn:aws:eks:us-east-1:836486484887:cluster/covalent-eks-cluster contexts: - context: cluster: arn:aws:eks:us-east-1:836486484887:cluster/covalent-eks-cluster user: arn:aws:eks:us-east-1:836486484887:cluster/covalent-eks-cluster name: arn:aws:eks:us-east-1:836486484887:cluster/covalent-eks-cluster current-context: arn:aws:eks:us-east-1:836486484887:cluster/covalent-eks-cluster kind: Config preferences: {} users: - name: arn:aws:eks:us-east-1:836486484887:cluster/covalent-eks-cluster user: exec: apiVersion: client.authentication.k8s.io/v1alpha1 args: - --region - us-east-1 - eks - get-token - --cluster-name - covalent-eks-cluster command: aws env: null interactiveMode: IfAvailable provideClusterInfo: false ```

Cleanup

When you are done, delete the cluster:

make clean

Release Notes

Release notes are available in the Changelog.

Citation

Please use the following citation in any publications:

W. J. Cunningham, S. K. Radha, F. Hasan, J. Kanem, S. W. Neagle, and S. Sanand. Covalent. Zenodo, 2022. https://doi.org/10.5281/zenodo.5903364

License

Covalent is licensed under the Apache License 2.0. See the LICENSE file or contact the support team for more details.

Owner

  • Name: Agnostiq
  • Login: AgnostiqHQ
  • Kind: organization
  • Email: contact@agnostiq.ai
  • Location: Toronto

Developing Software for Advanced Computing

GitHub Events

Total
  • Push event: 5
Last Year
  • Push event: 5

Committers

Last synced: over 1 year ago

All Time
  • Total Commits: 15
  • Total Committers: 6
  • Avg Commits per committer: 2.5
  • Development Distribution Score (DDS): 0.6
Past Year
  • Commits: 2
  • Committers: 1
  • Avg Commits per committer: 2.0
  • Development Distribution Score (DDS): 0.0
Top Committers
Name Email Commits
Will Cunningham w****l@a****i 6
CovalentOpsBot c****t 2
Poojith U Rao 1****o 2
Will Cunningham w****7 2
mpvgithub 1****b 2
Scott Wyman Neagle w****a@p****m 1
Committer Domains (Top 20 + Academic)

Issues and Pull Requests

Last synced: 6 months ago

All Time
  • Total issues: 10
  • Total pull requests: 14
  • Average time to close issues: 4 days
  • Average time to close pull requests: 9 days
  • Total issue authors: 1
  • Total pull request authors: 7
  • Average comments per issue: 0.2
  • Average comments per pull request: 0.79
  • Merged pull requests: 9
  • Bot issues: 0
  • Bot pull requests: 1
Past Year
  • Issues: 0
  • Pull requests: 0
  • Average time to close issues: N/A
  • Average time to close pull requests: N/A
  • Issue authors: 0
  • Pull request authors: 0
  • Average comments per issue: 0
  • Average comments per pull request: 0
  • Merged pull requests: 0
  • Bot issues: 0
  • Bot pull requests: 0
Top Authors
Issue Authors
  • wjcunningham7 (10)
Pull Request Authors
  • mpvgithub (6)
  • poojithurao (2)
  • wjcunningham7 (2)
  • cjao (1)
  • pre-commit-ci[bot] (1)
  • madhur-tandon (1)
  • scottwn (1)
Top Labels
Issue Labels
Pull Request Labels

Packages

  • Total packages: 1
  • Total downloads:
    • pypi 19 last-month
  • Total dependent packages: 0
  • Total dependent repositories: 0
  • Total versions: 1
  • Total maintainers: 1
pypi.org: covalent-kubernetes-plugin

Covalent Kubernetes Plugin

  • Versions: 1
  • Dependent Packages: 0
  • Dependent Repositories: 0
  • Downloads: 19 Last month
Rankings
Dependent packages count: 6.6%
Stargazers count: 19.5%
Average: 27.1%
Forks count: 30.5%
Dependent repos count: 30.6%
Downloads: 48.1%
Maintainers (1)
Last synced: 6 months ago

Dependencies

requirements.txt pypi
  • covalent ==0.177.0
  • docker ==6.0.0
  • kubernetes ==24.2.0
.github/workflows/changelog.yml actions
  • EndBug/add-and-commit v9 composite
  • actions/checkout v3 composite
.github/workflows/changelog_reminder.yml actions
  • actions/checkout master composite
  • peterjgrainger/action-changelog-reminder v1.3.0 composite
.github/workflows/license.yml actions
  • actions/checkout v3 composite
  • pilosus/action-pip-license-checker main composite
.github/workflows/release.yml actions
  • actions/checkout v2 composite
  • actions/setup-python v2 composite
  • ncipollo/release-action v1 composite
.github/workflows/tests.yml actions
  • actions-ecosystem/action-get-latest-tag v1 composite
  • actions/checkout v3 composite
  • actions/setup-python v2 composite
.github/workflows/version.yml actions
  • AgnostiqHQ/covalent/.github/actions/version develop composite
  • actions/checkout v3 composite
pyproject.toml pypi
setup.py pypi