Giter Site home page Giter Site logo

Comments (4)

duanhongyi avatar duanhongyi commented on July 22, 2024

Please refer to the web procfile for initial restrictions

from workflow.

duanhongyi avatar duanhongyi commented on July 22, 2024

design

  • drycc run to asynchronous execution, use job.
  • drycc run returns pod_name, add timeout parameter.
  • drycc ps:logs can view pod logs
> drycc run -t 3600 echo 111
appname-run-a91321-adf141
> drycc ps:logs appname-run-a91321-adf141
111

job structure

{
   "apiVersion":"batch/v1",
   "kind":"Job",
   "metadata":{
      "name":"appname-run"
   },
   "spec":{
      "template":{
         "spec":{
            "containers":[
               {
                  "name":"appname-run",
                  "image":"127.0.0.1:5555/appname/appname:v3",
                  "command":[
                     "echo",
                     "111"
                  ]
               }
            ],
            "restartPolicy":"Never"
         }
      },
      "backoffLimit":0,
      "activeDeadlineSeconds":3600,
      "ttlSecondsAfterFinished":86400
   }
}

from workflow.

duanhongyi avatar duanhongyi commented on July 22, 2024

K8s pod logs code snippet:

import asyncio
from kubernetes import config
from kubernetes.client import Configuration
from kubernetes.client.api import core_v1_api
from asgiref.sync import sync_to_async, async_to_sync


async def send(line):
    print(line)


@sync_to_async
def exec_commands(api_instance):
    kwargs = {"tail_lines": 10, "follow": True,  "_preload_content": False, "container": ""}
    stream = api_instance.read_namespaced_pod_log(
        'drycc-timeseries-main-0', 'drycc', **kwargs
    ).stream()
    for line in stream:
        async_to_sync(send)(line=line)

def main():
    config.load_kube_config()
    try:
        c = Configuration().get_default_copy()
    except AttributeError:
        c = Configuration()
        c.assert_hostname = False
    Configuration.set_default(c)
    core_v1 = core_v1_api.CoreV1Api()
    loop = asyncio.get_event_loop()
    loop.run_until_complete(exec_commands(core_v1))


if __name__ == '__main__':
    main()

from workflow.

duanhongyi avatar duanhongyi commented on July 22, 2024

complete

from workflow.

Related Issues (10)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.