Skip to content

Commit

Permalink
minor fix for kubernetes plugin (#20)
Browse files Browse the repository at this point in the history
* minor fix for kubernetes plugin

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* modified MANIFEST.in

* modified MANIFEST.in file

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* removed templates folder

* covalent version change in requirements.txt

* minor modifications to requirements.txt

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
mpvgithub and pre-commit-ci[bot] authored Jan 24, 2024
1 parent da9b1b6 commit d990e89
Showing 15 changed files with 34 additions and 47 deletions.
11 changes: 5 additions & 6 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -114,9 +114,8 @@ ipython_config.py
# Coverage
.coverage

infra/.terraform/*
infra/*.tfstate*
infra/cluster_autoscaler.yml
infra/.terraform.lock.hcl
infra/covalent-eks-cluster_config
infra/.tfvars
.terraform
*.tfstate*
*.terraform.lock.hcl
covalent-eks-cluster_config
*.tfvars
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -7,6 +7,14 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [UNRELEASED]

## Changed

- Changed the folder structure for the terraform files matching standard plugin folder format
- Minor code changes to kubernetes yml files
- Modified MANIFEST.in to validate plugin
- Modified **requirements.txt** to remove the exact pins for the version to be installed.
- Modified **requirements.txt** to set covalent version minimum from **0.232.0**

## [0.2.0] - 2023-09-20

### Changed
3 changes: 3 additions & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
include VERSION
include requirements.txt
include covalent_kubernetes_plugin/assets/infra/*
exclude covalent_kubernetes_plugin/assets/infra/*.swp
include covalent_kubernetes_plugin/assets/infra/*.tf
6 changes: 3 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
@@ -5,8 +5,8 @@ all:
@echo "To tear down infrastructure, use 'make clean'."

deploy:
(cd infra && bash ./deploy-eks.sh)
(cd covalent_kubernetes_plugin/assets/infra && bash ./deploy-eks.sh)

clean:
(cd infra && terraform destroy -auto-approve -state $(HOME)/.cache/covalent/terraform.tfstate)
rm -f infra/cluster_autoscaler.yml
(cd covalent_kubernetes_plugin/assets/infra && terraform destroy -auto-approve -state $(HOME)/.cache/covalent/terraform.tfstate)
rm -f covalent_kubernetes_plugin/infra/cluster_autoscaler.yml
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -18,7 +18,7 @@ terraform {
required_providers {
aws = {
source = "hashicorp/aws"
version = "~> 4.23"
version = "5.17.0"
}
}
}
@@ -83,6 +83,7 @@ resource "aws_ecr_repository" "ecr_repository" {

resource "aws_s3_bucket" "s3_bucket" {
bucket = var.aws_s3_bucket
force_destroy = true
}

data "aws_iam_policy_document" "s3_access_document" {
@@ -227,7 +228,7 @@ resource "aws_eks_node_group" "private_node_group" {
}

data "template_file" "config" {
template = file("${path.module}/templates/config.tpl")
template = file("${path.module}/config.tpl")
vars = {
certificate_data = aws_eks_cluster.eks_cluster.certificate_authority[0].data
cluster_endpoint = aws_eks_cluster.eks_cluster.endpoint
Original file line number Diff line number Diff line change
@@ -50,7 +50,7 @@ export KUBECONFIG=`jq -r '.kubeconfig.value' <<< $outputs`
cluster_name=`jq -r '.cluster_name.value' <<< $outputs`
autoscaler_role=`jq -r '.eks_ca_iam_role_arn.value' <<< $outputs`
sed "s|%CLUSTERNAME%|$cluster_name|;s|%ASROLE%|$autoscaler_role|" < templates/cluster_autoscaler.yml > cluster_autoscaler.yml
sed "s|%CLUSTERNAME%|$cluster_name|;s|%ASROLE%|$autoscaler_role|" < cluster_autoscaler.yml > cluster_autoscaler.yml
echo -e "\nEnabling node autoscaler..."
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -21,8 +21,8 @@ metadata:
spec:
template:
spec:
restartPolicy: Never
containers:
- name: covalent-k8s-test
image: "hello-world:latest"
restartPolicy: Never
image: hello-world:latest
backoffLimit: 4
File renamed without changes.
10 changes: 6 additions & 4 deletions covalent_kubernetes_plugin/k8s.py
Original file line number Diff line number Diff line change
@@ -220,11 +220,12 @@ def _format_exec_script(

# Execution preamble
exec_script = """
import os
import cloudpickle as pickle
local_func_filename = os.path.join("{docker_working_dir}", "{func_filename}")
local_result_filename = os.path.join("{docker_working_dir}", "{result_filename}")
import os
import cloudpickle as pickle
local_func_filename = os.path.join("{docker_working_dir}", "{func_filename}")
local_result_filename = os.path.join("{docker_working_dir}", "{result_filename}")
""".format(
docker_working_dir=docker_working_dir,
@@ -449,6 +450,7 @@ def _package_and_upload(
raise Exception(proc.stderr.decode("utf-8"))
else:
app_log.debug("Uploading image to ECR.")
app_log.debug(f"the image URI is {image_uri}")
response = docker_client.images.push(image_uri, tag=image_tag)
app_log.debug(f"Response: {response}")

26 changes: 0 additions & 26 deletions infra/defaults.tfvars

This file was deleted.

6 changes: 3 additions & 3 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
covalent==0.177.0.post1.dev1
docker==6.0.0
kubernetes==24.2.0
covalent>=0.232.0
docker>=6.0.0
kubernetes>=24.2.0

0 comments on commit d990e89

Please sign in to comment.