PrimeHub
  • Introduction
  • Installation
  • Tiers and Licenses
  • End-to-End Tutorial
    • 1 - MLOps Introduction and Scoping the Project
    • 2 - Train and Manage the Model
    • 3 - Compare, Register and Deploy the Model
    • 4 - Build the Web Application
    • 5 - Summary
  • User Guide
    • User Portal
    • Notebook
      • Notebook Tips
      • Advanced Settings
      • PrimeHub Notebook Extension
      • Submit Notebook as Job
    • Jobs
      • Job Artifacts
      • Tutorial
        • (Part1) MNIST classifier training
        • (Part2) MNIST classifier training
        • (Advanced) Use Job Submission to Tune Hyperparameters
        • (Advanced) Model Serving by Seldon
        • Job Artifacts Simple Usecase
    • Models
      • Manage and Deploy Model
      • Model Management Configuration
    • Deployments
      • Pre-packaged servers
        • TensorFlow server
        • PyTorch server
        • SKLearn server
        • Customize Pre-packaged Server
        • Run Pre-packaged Server Locally
      • Package from Language Wrapper
        • Model Image for Python
        • Model Image for R
        • Reusable Base Image
      • Prediction APIs
      • Model URI
      • Tutorial
        • Model by Pre-packaged Server
        • Model by Pre-packaged Server (PHFS)
        • Model by Image built from Language Wrapper
    • Shared Files
    • Datasets
    • Apps
      • Label Studio
      • MATLAB
      • MLflow
      • Streamlit
      • Tutorial
        • Create Your Own App
        • Create an MLflow server
        • Label Dataset by Label Studio
        • Code Server
    • Group Admin
      • Images
      • Settings
    • Generate an PrimeHub API Token
    • Python SDK
    • SSH Server Feature
      • VSCode SSH Notebook Remotely
      • Generate SSH Key Pair
      • Permission Denied
      • Connection Refused
    • Advanced Tutorial
      • Labeling the data
      • Notebook as a Job
      • Custom build the Seldon server
      • PrimeHub SDK/CLI Tools
  • Administrator Guide
    • Admin Portal
      • Create User
      • Create Group
      • Assign Group Admin
      • Create/Plan Instance Type
      • Add InfuseAI Image
      • Add Image
      • Build Image
      • Gitsync Secret for GitHub
      • Pull Secret for GitLab
    • System Settings
    • User Management
    • Group Management
    • Instance Type Management
      • NodeSelector
      • Toleration
    • Image Management
      • Custom Image Guideline
    • Volume Management
      • Upload Server
    • Secret Management
    • App Settings
    • Notebooks Admin
    • Usage Reports
  • Reference
    • Jupyter Images
      • repo2docker image
      • RStudio image
    • InfuseAI Images List
    • Roadmap
  • Developer Guide
    • GitHub
    • Design
      • PrimeHub File System (PHFS)
      • PrimeHub Store
      • Log Persistence
      • PrimeHub Apps
      • Admission
      • Notebook with kernel process
      • JupyterHub
      • Image Builder
      • Volume Upload
      • Job Scheduler
      • Job Submission
      • Job Monitoring
      • Install Helper
      • User Portal
      • Meta Chart
      • PrimeHub Usage
      • Job Artifact
      • PrimeHub Apps
    • Concept
      • Architecture
      • Data Model
      • CRDs
      • GraphQL
      • Persistence Storages
      • Persistence
      • Resources Quota
      • Privilege
    • Configuration
      • How to configure PrimeHub
      • Multiple Jupyter Notebook Kernels
      • Configure SSH Server
      • Configure Job Submission
      • Configure Custom Image Build
      • Configure Model Deployment
      • Setup Self-Signed Certificate for PrimeHub
      • Chart Configuration
      • Configure PrimeHub Store
    • Environment Variables
Powered by GitBook
On this page
  • Limitations
  • What Is A PhAppTemplate?
  • Predefined Environment Variables
  • podTemplate
  • defaultEnvs
  • svcTemplate and httpPort
  • Persistant Storage
  • More Examples
  1. User Guide
  2. Apps
  3. Tutorial

Create Your Own App

PreviousTutorialNextCreate an MLflow server

Last updated 2 years ago

This tutorial shows how to create your own PrimeHub app using PhAppTemplate CRD.

For more information about the PrimeHub app, please check our .

Limitations

Here are some limitations/constraints when it comes to turning your application into a PrimeHub app.

  1. Your application should be containerized.

  2. Your application can be configured by passing Environment variables or commandline arguments.

  3. PrimeHub app now only supports single container. You can't define multiple containers and initContainer in PhAppTemplate. If you have to run multiple processes, you'll need to run it in the same container or separate them into different PrimeHub apps for now.

What Is A PhAppTemplate?

PhAppTemplate is a CRD defines how an application is installed in PrimeHub. Think it as a stamp, you can create tons of application instances using that stamp very easily.

There are few components you need to define in your PhAppTemplate:

  1. podTemplate: used to create the deployment of the application

  2. svcTemplate: used to create the service

  3. httpPort: The HTTP port if the application has a web interface

  4. rewrite: For certain applications, set rewrite=true if the url path change is causing trouble

  5. defaultEnvs: The default env variables are used when creating the application. When an application is created, the values would be put in enviornment variables of the target application.

    • ENV Name

    • Description

    • Default value

    • Optional

Predefined Environment Variables

Here's list of our predefined environment variables. These predefined environment variables will be injected into your application container at the very beginning.

  1. PRIMEHUB_APP_ID: The PhApplication k8s resource name <app-id>

  2. PRIMEHUB_APP_ROOT: The root of persistence storage for the application.

    • <group-volume>/phapplications/<app-id> (if group volume available)

    • /phapplications/<app-id> (if group volume not available)

  3. PRIMEHUB_APP_BASE_URL: The url prefix for the application /console/apps/<app-id>

  4. PRIMEHUB_URL: The external url of PrimeHub

  5. PRIMEHUB_GROUP: The group name

The common usage of these predefined environment variables are usually these two:

  1. Compose another environment variable at your will.

  2. Pass as an commandline argument into your container endpoint to configure your application.

We'll cover some examples in the following sections.

podTemplate

podTemplate is basically the same as how you describe a native kubernetes pod. But you can only define a single container and an initContainer in your podTemplate. We do not support multiple containers and initContainers for now.

Here's an example podTemplate block:

template:
    spec:
      podTemplate:
        spec:
          containers:
          - name: label-studio
            image: heartexlabs/label-studio:latest
            command:
            - bash
            - -c
            args:
            - |
              label-studio start primehub --init --host $(PRIMEHUB_URL)$(PRIMEHUB_APP_BASE_URL) --username $(DEFAULT_USERNAME) --password $(DEFAULT_PASSWORD)
            ports:
            - containerPort: 8080
              name: http
              protocol: TCP

As you can see, you can use our predefined environment variables or variables you define in the defaultEnvs block to configure and launch your application. We'll cover the defaultEnvs part later.

defaultEnvs

When a PrimeHub user is trying to create a new PrimeHub app from the PhAppTemplate you defined, ze is able to customize/configure the application with defaultEnvs.

Again, take our label-studio phAppTemplate as an example:

  defaultEnvs:
  - name: DEFAULT_USERNAME
    description: "The default username to login"
    defaultValue: "$(PRIMEHUB_GROUP)@infuseai.io"
    optional: false
  - name: DEFAULT_PASSWORD
    description: "The default password to login"
    defaultValue: "$(PRIMEHUB_GROUP)_password!"
    optional: false
  - name: LABEL_STUDIO_BASE_DATA_DIR
    description: "Directory to use to store all application-related data."
    defaultValue: "$(PRIMEHUB_APP_ROOT)/label-studio-data"
    optional: false
  - name: LOCAL_FILES_SERVING_ENABLED
    description: "Serving data from the local file system."
    defaultValue: "true"
    optional: false
  - name: DISABLE_SIGNUP_WITHOUT_LINK
    description: "Deactivate the signup page and use only the invitation link."
    defaultValue: "true"
    optional: false

We defined five default environment variables here and some of them are composed from our predefined environment variables.

Now, when the user is trying to create a new label-studio app, this form will show up.

Please note that if the optional attribute is set to false, then users can remove the defaultEnv. Be sure to set it properly.

svcTemplate and httpPort

svcTemplate and httpPort are used to expose your application through our proxy. If your application does not have a web-interface then you can leave these fields blank.

      svcTemplate:
        spec:
          ports:
          - name: http
            port: 8080
            protocol: TCP
            targetPort: 8080
      httpPort: 8080

The svcTemplate is basically the same as Service resource in Kubernetes. PrimeHub will create a service for your app according to your definition here.

Persistant Storage

If your application requires a persistant storage to keep your data, you can use the group volume.

More Examples

Every PrimeHub app is created inside a group context. If you have feature for that group, then that group volume will be mounted to your application container at <group-volume>/phapplications/<app-id>. You can use the predefined environment variable PRIMEHUB_APP_ROOT to tell your application to store persistant data into that location.

For more examples, please check our built-in phAppTemplate on our .

design document
Github repo
enabled group volume