UCloud Docs
  • Login
  • eScience Center
  • Terms of Service
  • Developer Guide (current)
  • User Guide
  • FAQ

Navigation

  • index
  • next |
  • previous |
  • »
  • Examples »
  • Example: Starting a Job with a public link (Ingress)

Developer Guide

  • Accounting and Project Management
  • Orchestration of Resources
  • Developing UCloud
  • Core

API Reference

  • Remote Procedure Calls
  • Examples
    • Example: Definition of a Provider (Retrieval)
    • Example: A Provider authenticating with UCloud/Core
    • Example: Browse all available products
    • Example: Browse products by type
    • Example: Retrieve a single product
    • Example: Browsing the catalog
    • Example: Creating and retrieving a resource
    • Example: Browsing the catalog with a filter
    • Example: Searching for data
    • Example: Feature detection (Supported)
    • Example: Feature detection (Failure scenario)
    • Example: Resource Collaboration
    • Example: An example collection
    • Example: Renaming a collection
    • Example: Renaming a file
    • Example: Copying a file to itself
    • Example: Uploading a file
    • Example: Downloading a file
    • Example: Creating a folder
    • Example: Moving multiple files to trash
    • Example: Emptying trash folder
    • Example: Browsing the contents of a folder
    • Example: Retrieving a single file
    • Example: Deleting a file permanently
    • Example: Retrieving a list of products supported by accessible providers
    • Example: Complete example
    • Example: The Sensitivity Template
    • Example: Sensitivity Document
    • Example: Creation of Resources
    • Example: Looking up resources by provider generated ID
    • Example: Dealing with partial failures
    • Example: Dealing with partial failures
    • Example: Retrieve a container based Tool
    • Example: Retrieve a virtual machine based Tool
    • Example: Simple batch application
    • Example: Simple virtual machine
    • Example: Simple web application
    • Example: Simple remote desktop application (VNC)
    • Example: Registering a file handler
    • Example: An Application with default values
    • Example: Creating a simple batch Job
    • Example: Following the progress of a Job
    • Example: Starting an interactive terminal session
    • Example: Connecting two Jobs together
    • Example: Starting a Job with a public link (Ingress)
    • Example: Using licensed software
    • Example: Using a remote desktop Application (VNC)
    • Example: Using a web Application
    • Example: Losing access to resources
    • Example: Running out of compute credits
    • Example: Extending a Job and terminating it early
    • Example: Create and configure firewall
    • Example: Create and configure an Ingress
    • Example: Create and configure a license
    • Example: Declaring support full support for containerized applications
    • Example: Declaring minimal support for virtual machines
    • Example: Simple batch Job with life-cycle events
    • Example: Accounting
    • Example: Ensuring UCloud/Core and Provider are in-sync
    • Example: A Provider authenticating with UCloud/Core
    • Example: Creating 2FA credentials
    • Example: News CRUD
    • Example: Making a news post as hidden
    • Example: Creating a notification
    • Example: Listening to notifications
    • Example: List and Clear notifications
    • Example: Counting to 3 (Produced by the service)
    • Example: Counting to 3 (Received by end-user)
    • Example: Creating a ticket
    • Example: Sending an email
    • Example: Forwarding a support ticket to Jira
    • Example: Changing e-mail settings
  • Type Reference
  1. Docs
  2. Examples
  3. Example: Starting a Job with a public link (Ingress)

Example: Starting a Job with a public link (Ingress)¶

Frequency of useCommon
Actors
  • An authenticated user (user)
Communication Flow: Kotlin
/* In this example, the user will create a Job which exposes a web-interface. This web-interface will
become available through a publicly accessible link. */


/* First, the user creates an Ingress resource (this needs to be done once per ingress) */

Ingresses.create.call(
    bulkRequestOf(IngressSpecification(
        domain = "app-my-application.provider.example.com", 
        product = ProductReference(
            category = "example-ingress", 
            id = "example-ingress", 
            provider = "example", 
        ), 
    )),
    user
).orThrow()

/*
BulkResponse(
    responses = listOf(FindByStringId(
        id = "41231", 
    )), 
)
*/

/* This link can now be attached to any Application which support a web-interface */

Jobs.create.call(
    bulkRequestOf(JobSpecification(
        allowDuplicateJob = false, 
        application = NameAndVersion(
            name = "acme-web-app", 
            version = "1.0.0", 
        ), 
        name = null, 
        openedFile = null, 
        parameters = null, 
        product = ProductReference(
            category = "compute-example", 
            id = "compute-example", 
            provider = "example", 
        ), 
        replicas = 1, 
        resources = listOf(AppParameterValue.Ingress(
            id = "41231", 
        )), 
        restartOnExit = null, 
        sshEnabled = null, 
        timeAllocation = null, 
    )),
    user
).orThrow()

/*
BulkResponse(
    responses = listOf(FindByStringId(
        id = "41252", 
    )), 
)
*/

/* The Application is now running, and we can access it through the public link */


/* The Ingress will also remain exclusively bound to the Job. It will remain like this until the Job
terminates. You can check the status of the Ingress simply by retrieving it. */

Ingresses.retrieve.call(
    ResourceRetrieveRequest(
        flags = IngressIncludeFlags(
            filterCreatedAfter = null, 
            filterCreatedBefore = null, 
            filterCreatedBy = null, 
            filterIds = null, 
            filterProductCategory = null, 
            filterProductId = null, 
            filterProvider = null, 
            filterProviderIds = null, 
            filterState = null, 
            hideProductCategory = null, 
            hideProductId = null, 
            hideProvider = null, 
            includeOthers = false, 
            includeProduct = false, 
            includeSupport = false, 
            includeUpdates = false, 
        ), 
        id = "41231", 
    ),
    user
).orThrow()

/*
Ingress(
    createdAt = 1633087693694, 
    id = "41231", 
    owner = ResourceOwner(
        createdBy = "user", 
        project = null, 
    ), 
    permissions = null, 
    specification = IngressSpecification(
        domain = "app-my-application.provider.example.com", 
        product = ProductReference(
            category = "example-ingress", 
            id = "example-ingress", 
            provider = "example", 
        ), 
    ), 
    status = IngressStatus(
        boundTo = listOf("41231"), 
        resolvedProduct = null, 
        resolvedSupport = null, 
        state = IngressState.READY, 
    ), 
    updates = emptyList(), 
    providerGeneratedId = "41231", 
)
*/
Communication Flow: Curl
# ------------------------------------------------------------------------------------------------------
# $host is the UCloud instance to contact. Example: 'http://localhost:8080' or 'https://cloud.sdu.dk'
# $accessToken is a valid access-token issued by UCloud
# ------------------------------------------------------------------------------------------------------

# In this example, the user will create a Job which exposes a web-interface. This web-interface will
# become available through a publicly accessible link.

# First, the user creates an Ingress resource (this needs to be done once per ingress)

# Authenticated as user
curl -XPOST -H "Authorization: Bearer $accessToken" -H "Content-Type: content-type: application/json; charset=utf-8" "$host/api/ingresses" -d '{
    "items": [
        {
            "domain": "app-my-application.provider.example.com",
            "product": {
                "id": "example-ingress",
                "category": "example-ingress",
                "provider": "example"
            }
        }
    ]
}'


# {
#     "responses": [
#         {
#             "id": "41231"
#         }
#     ]
# }

# This link can now be attached to any Application which support a web-interface

curl -XPOST -H "Authorization: Bearer $accessToken" -H "Content-Type: content-type: application/json; charset=utf-8" "$host/api/jobs" -d '{
    "items": [
        {
            "application": {
                "name": "acme-web-app",
                "version": "1.0.0"
            },
            "product": {
                "id": "compute-example",
                "category": "compute-example",
                "provider": "example"
            },
            "name": null,
            "replicas": 1,
            "allowDuplicateJob": false,
            "parameters": null,
            "resources": [
                {
                    "type": "ingress",
                    "id": "41231"
                }
            ],
            "timeAllocation": null,
            "openedFile": null,
            "restartOnExit": null,
            "sshEnabled": null
        }
    ]
}'


# {
#     "responses": [
#         {
#             "id": "41252"
#         }
#     ]
# }

# The Application is now running, and we can access it through the public link

# The Ingress will also remain exclusively bound to the Job. It will remain like this until the Job
# terminates. You can check the status of the Ingress simply by retrieving it.

curl -XGET -H "Authorization: Bearer $accessToken" "$host/api/ingresses/retrieve?includeOthers=false&includeUpdates=false&includeSupport=false&includeProduct=false&id=41231" 

# {
#     "id": "41231",
#     "specification": {
#         "domain": "app-my-application.provider.example.com",
#         "product": {
#             "id": "example-ingress",
#             "category": "example-ingress",
#             "provider": "example"
#         }
#     },
#     "owner": {
#         "createdBy": "user",
#         "project": null
#     },
#     "createdAt": 1633087693694,
#     "status": {
#         "boundTo": [
#             "41231"
#         ],
#         "state": "READY",
#         "resolvedSupport": null,
#         "resolvedProduct": null
#     },
#     "updates": [
#     ],
#     "permissions": null
# }
Communication Flow: Visual

Previous
Next

Navigation

  • index
  • next |
  • previous |
  • »
  • Examples »
  • Example: Starting a Job with a public link (Ingress)

eScience Center

  • Home page
  • Staff
  • News
  • Collaborations
User Support

  • Terms of Service
  • Service Desk
  • Front Office

© Copyright 2020-2024 | SDU eScience Center | All rights reserved