Skip to content

Add instance resource allocation example#424

Open
Roxanacmaria wants to merge 12 commits into
unikraft-cloud:mainfrom
Roxanacmaria:instance-resource-allocation
Open

Add instance resource allocation example#424
Roxanacmaria wants to merge 12 commits into
unikraft-cloud:mainfrom
Roxanacmaria:instance-resource-allocation

Conversation

@Roxanacmaria

@Roxanacmaria Roxanacmaria commented Jul 8, 2026

Copy link
Copy Markdown

Summary

This PR adds a new Unikraft Cloud example for Instance Resource Allocation.

The example documents how to configure memory and virtual CPU allocation for instances running on Unikraft Cloud, both through the kraft CLI and through the Unikraft Cloud Platform API.

Current contents

  • README for the new instance-resource-allocation example
  • create files (Dockerfile, Kraftfile,server.py,test_resources.py, ukc.config.template)
  • validate and refine the example implementation
  • functional testing on Unikraft Cloud
  • final cleanup and review

Scope of the example

The example is intended to cover:

  • configuring instance memory with -M / --memory
  • configuring virtual CPUs with -V / --vcpus
  • deploying an instance with custom resource allocation
  • retrieving instance information to verify the configured resources
  • using equivalent API-based operations

Status

Ready for review.

@Roxanacmaria Roxanacmaria marked this pull request as draft July 8, 2026 11:25
@Roxanacmaria Roxanacmaria changed the title Adding the README.md file Add instance resource allocation example Jul 8, 2026
@Roxanacmaria Roxanacmaria marked this pull request as ready for review July 9, 2026 07:54

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a new Unikraft Cloud example that demonstrates explicit per-instance resource allocation (memory and vCPUs) using both the kraft CLI and direct Platform API calls.

Changes:

  • Introduces a new example directory with a Python HTTP server, container packaging, and a Kraftfile for deployment.
  • Documents end-to-end workflows (deploy/create/start/query/logs/stop/delete) for both CLI and API usage.
  • Adds a small client-side validation script plus templated configuration files.

Reviewed changes

Copilot reviewed 19 out of 19 changed files in this pull request and generated 10 comments.

Show a summary per file
File Description
instance-resource-allocation-roxana/README.md Documentation and command walkthroughs for CLI + API resource allocation workflows
instance-resource-allocation-roxana/Dockerfile Builds a minimal Python image running the demo HTTP server
instance-resource-allocation-roxana/Kraftfile Unikraft Cloud packaging/runtime configuration for the example
instance-resource-allocation-roxana/server.py Simple HTTP server used as the deployed workload
instance-resource-allocation-roxana/test_resources.py Client script to verify the deployed instance responds as expected
instance-resource-allocation-roxana/ukc.config.template Template for required Unikraft Cloud environment variables
instance-resource-allocation-roxana/app.config Centralized example naming + default resource settings for API scripts
instance-resource-allocation-roxana/.gitignore Prevents committing local ukc.config credentials
instance-resource-allocation-roxana/api/pkg-image.sh Packages the image for Unikraft Cloud (CLI-based)
instance-resource-allocation-roxana/api/push-image.sh Pushes the packaged image to the registry (CLI-based)
instance-resource-allocation-roxana/api/list-images.sh Lists images via Platform API
instance-resource-allocation-roxana/api/create-instance.sh Creates an instance via Platform API with explicit memory_mb/vcpus
instance-resource-allocation-roxana/api/start-instance.sh Starts an instance via Platform API
instance-resource-allocation-roxana/api/stop-instance.sh Stops an instance via Platform API
instance-resource-allocation-roxana/api/list-instances.sh Lists instances via Platform API
instance-resource-allocation-roxana/api/get-instance-info.sh Retrieves instance info via Platform API
instance-resource-allocation-roxana/api/query.sh Queries the instance endpoint using the fqdn derived from API output
instance-resource-allocation-roxana/api/get-instance-logs.sh Retrieves logs via Platform API and decodes output
instance-resource-allocation-roxana/api/delete-instance.sh Deletes an instance via Platform API
Comments suppressed due to low confidence (2)

instance-resource-allocation-roxana/api/start-instance.sh:15

  • This script pipes curl output directly into jq without preserving curl's stderr/exit status. Other examples in this repo capture curl output to out/err and only run jq on success (e.g. basic-ops/api/start-instance.sh). Without that, failures are harder to diagnose and can surface as confusing jq parse errors.
    "${UKC_API}/instances/start" \
    -d "{
        'name': '${INSTANCE_NAME}'
    }" | jq

instance-resource-allocation-roxana/api/stop-instance.sh:15

  • This script pipes curl output directly into jq without preserving curl's stderr/exit status. Other examples in this repo capture curl output to out/err and only run jq on success (e.g. basic-ops/api/stop-instance.sh). Without that, failures are harder to diagnose and can surface as confusing jq parse errors.
    "${UKC_API}/instances/stop" \
    -d "{
        'name': '${INSTANCE_NAME}'
    }" | jq


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread instance-resource-allocation-roxana/README.md Outdated
Comment thread instance-resource-allocation-roxana/README.md
Comment thread instance-resource-allocation-roxana/README.md
Comment thread instance-resource-allocation-roxana/README.md
Comment thread instance-resource-allocation-roxana/api/create-instance.sh
Comment thread instance-resource-allocation-roxana/api/delete-instance.sh
Comment thread instance-resource-allocation-roxana/api/get-instance-info.sh
Comment thread instance-resource-allocation-roxana/api/list-images.sh
Comment thread instance-resource-allocation-roxana/api/list-instances.sh
Comment thread instance-resource-allocation-roxana/test_resources.py Outdated
@razvand razvand self-assigned this Jul 11, 2026

@stancu-anamaria stancu-anamaria left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I reviewed the implementation and followed the README. The instructions are clear, and the commands worked as expected. I didn't find any issues

@Dan-Andrei-Simionescu Dan-Andrei-Simionescu left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The scripts and commands work just fine, also, the README is written nicely.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants