Code Monkey home page Code Monkey logo

k8s-sym-client-controller's Introduction

sym-client-controller

This repository implements a simple controller for running workload and watching SessionJob resources as defined with a CustomResourceDefinition (CRD).

This particular example demonstrates how to perform basic Symphony client operations such as:

  • How to specify the task input/output path and the callback fucntion.
  • How to get the task status.

Details

Running

# deploy the FaaS sample in the Symhony client container and copy related files (input.txt myfunc.py) to folder /share.

# assumes you have a working kubeconfig, not required if operating in-cluster
go build -o sym-client-controller .

# copy sym-client-controller sym.sh sym_monitor.sh into the /opt/ibm/sym-client-controller folder of the Symhony client container, grant 775 permission for the .sh files and then run the following command:
# to handle the requests for a namespace only, set the namespace name with environment variable like "export NAMESPACE=dept-a"
./sym-client-controller

# create a CustomResourceDefinition
kubectl create -f artifacts/examples/crd.yaml

# create a custom resource of type SessionJob to run tasks
# user can specify the task input/output and custom function as following:
#  taskInput: /shared/input.txt
#  taskOutput: /shared/output.txt
#  taskFunction: /shared/myfunc.py
#
# the content in taskInput is from user, Symphony client will create tasks based on it
# the taskOuput is used to record the output from Symphony client
# the taskFunction is the function that defined by user to handle the tasks from taskInput
#
# to create a request for a specific namespace, add the namespace name at the end of the command like "-n dept-a"
kubectl create -f artifacts/examples/example-sessionjob.yaml

# check task status through the custom resource
kubectl describe SessionJob

Part of the result is like:

Spec:
  Deployment Name:  example-sessionjob
  Replicas:         1
  Task Function:    /share/myfunc.py
  Task Input:       /share/input.txt
  Task Output:      /share/output.txt
Status:
  Done Tasks:     100
  Pending Tasks:  72
  Running Tasks:  8

Cleanup

You can clean up the created CustomResourceDefinition with:

kubectl delete crd sessionjobs.samplecontroller.k8s.io

k8s-sym-client-controller's People

Contributors

alvaroaleman avatar ash2k avatar cblecker avatar danielqsj avatar deads2k avatar dims avatar ericchiang avatar fisherxu avatar hzxuzhonghu avatar ixdy avatar jpbetz avatar k8s-publish-robot avatar k8s-publishing-bot avatar krzysied avatar liggitt avatar mikedanese avatar mtaufen avatar munnerz avatar nikhita avatar roycaihw avatar smarterclayton avatar spiffxp avatar sttts avatar suigh avatar tallclair avatar tnozicka avatar tossmilestone avatar wojtek-t avatar xichengliudui avatar yastij avatar

Watchers

 avatar

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.