{"id":36648286,"url":"https://github.com/nscaledev/uni-compute","last_synced_at":"2026-02-06T13:22:36.565Z","repository":{"id":257195553,"uuid":"848717894","full_name":"nscaledev/uni-compute","owner":"nscaledev","description":"UNI Compute Service","archived":false,"fork":false,"pushed_at":"2026-02-03T05:09:52.000Z","size":1201,"stargazers_count":1,"open_issues_count":4,"forks_count":4,"subscribers_count":1,"default_branch":"main","last_synced_at":"2026-02-03T05:43:30.256Z","etag":null,"topics":["uni","unikorn"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/nscaledev.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2024-08-28T09:24:11.000Z","updated_at":"2026-01-30T18:34:06.000Z","dependencies_parsed_at":"2024-11-05T11:27:23.949Z","dependency_job_id":"b117b7f8-b923-42dc-be0b-0079cc1971a5","html_url":"https://github.com/nscaledev/uni-compute","commit_stats":null,"previous_names":["unikorn-cloud/baremetal","unikorn-cloud/compute","nscaledev/uni-compute"],"tags_count":72,"template":false,"template_full_name":null,"purl":"pkg:github/nscaledev/uni-compute","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nscaledev%2Funi-compute","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nscaledev%2Funi-compute/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nscaledev%2Funi-compute/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nscaledev%2Funi-compute/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nscaledev","download_url":"https://codeload.github.com/nscaledev/uni-compute/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nscaledev%2Funi-compute/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29162156,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-06T12:44:37.655Z","status":"ssl_error","status_checked_at":"2026-02-06T12:44:13.991Z","response_time":59,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["uni","unikorn"],"created_at":"2026-01-12T10:02:59.005Z","updated_at":"2026-02-06T13:22:36.556Z","avatar_url":"https://github.com/nscaledev.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Compute Service\n\n## Overview\n\nThe compute service is essentially a cut down version of the [Kubernetes service](https://github.com/nscaledev/uni-kubernetes) that provisions its own compute servers using hardware abstraction provided by the [Region service](https://github.com/nscaledev/uni-region).\n\nWhere possible, as the Compute service is very similar to the Kubernetes service, we must maintain type and API parity to ease creation of UX tools and services.\n\n## Installation\n\n### Prerequisites\n\nTo use the Compute service you first need to install:\n\n* [The identity service](https://github.com/nscaledev/uni-identity) to provide API authentication and authorization.\n* [The region service](https://github.com/nscaledev/uni-region) to provide provider agnostic cloud services (e.g. images, flavors and identity management).\n\n### Installing the Service\n\n#### Installing Prerequisites\n\nThe compute server component has a couple prerequisites that are required for correct functionality.\nIf not installing the server component, skip to the next section.\n\nYou'll need to install:\n\n* cert-manager (used to generate keying material for JWE/JWS and for ingress TLS)\n* nginx-ingress (to perform routing, avoiding CORS, and TLS termination)\n\n#### Installing the Compute Service\n\n\u003cdetails\u003e\n\u003csummary\u003eHelm\u003c/summary\u003e\n\nCreate a `values.yaml` for the server component:\nA typical `values.yaml` that uses cert-manager and ACME, and external DNS might look like:\n\n```yaml\nglobal:\n  identity:\n    host: https://identity.unikorn-cloud.org\n  region:\n    host: https://region.unikorn-cloud.org\n  compute:\n    host: https://compute.unikorn-cloud.org\n```\n\n```shell\nhelm install unikorn-compute charts/compute --namespace unikorn-compute --create-namespace --values values.yaml\n```\n\n\u003c/details\u003e\n\n\u003cdetails\u003e\n\u003csummary\u003eArgoCD\u003c/summary\u003e\n\n```yaml\napiVersion: argoproj.io/v1alpha1\nkind: Application\nmetadata:\n  name: unikorn-compute\n  namespace: argocd\nspec:\n  project: default\n  source:\n    repoURL: https://unikorn-cloud.github.io/compute\n    chart: compute\n    targetRevision: v0.1.0\n  destination:\n    namespace: unikorn\n    server: https://kubernetes.default.svc\n  syncPolicy:\n    automated:\n      prune: true\n      selfHeal: true\n    syncOptions:\n    - CreateNamespace=true\n```\n\n\u003c/details\u003e\n\n### Configuring Service Authentication and Authorization\n\nThe [Identity Service](https://github.com/nscaledev/uni-identity) describes how to configure a service organization, groups and role mappings for services that require them.\n\nThis service requires asynchronous access to the Region API in order to poll cloud identity and physical network status during cluster creation, and delete those resources on cluster deletion.\n\nThis service defines the `unikorn-compute` user that will need to be added to a group in the service organization.\nIt will need the built in role `infra-manager-service` that allows:\n\n* Read access to the `region` endpoints to access external networks\n* Read/delete access to the `identites` endpoints to poll and delete cloud identities\n* Read/delete access to the `physicalnetworks` endpoints to poll and delete physical networks\n* Create/Read/Delete access to the `servers` endpoints to manage compute instances\n\n## Testing\n\n### API Integration Tests\n\nThe compute service includes comprehensive API integration tests that validate cluster lifecycle management, machine operations, security, and metadata discovery endpoints.\n\n#### Test Configuration\n\nTests are configured via environment variables using a `.env` file in the `test/` directory.\n\n**Setup:**\n\n1. **Set up your environment configuration:**\n\n   Copy the example config and update with your values:\n   ```bash\n   cp test/.env.example test/.env\n   ```\n\n   Or create environment-specific files (not tracked in git):\n   ```bash\n   # Create .env.dev with your dev credentials\n   cp test/.env.example test/.env.dev\n   # Edit test/.env.dev with dev values\n\n   # Create .env.uat with your UAT credentials\n   cp test/.env.example test/.env.uat\n   # Edit test/.env.uat with UAT values\n\n   # Use the appropriate environment\n   cp test/.env.dev test/.env    # For dev environment\n   cp test/.env.uat test/.env    # For UAT environment\n   ```\n\n2. **Configure the required values in `test/.env`:**\n   - `API_BASE_URL` - Compute API server URL\n   - `IDENTITY_BASE_URL` - Identity API server URL\n   - `API_AUTH_TOKEN` - Service token from console\n   - `TEST_ORG_ID`, `TEST_PROJECT_ID`, `TEST_SECONDARY_PROJECT_ID` - Test organization and project IDs\n   - `TEST_REGION_ID`, `TEST_SECONDARY_REGION_ID` - Test region IDs\n   - `TEST_NETWORK_ID` - Test network ID\n   - `TEST_FLAVOR_ID`, `TEST_IMAGE_ID` - Test flavor and image IDs\n\n**Note:** All `test/.env` and `test/.env.*` files are gitignored and contain sensitive credentials. They should never be committed to the repository. You can use either `test/.env` directly or create environment-specific files like `test/.env.dev`, `test/.env.uat`, etc.\n\n#### Running Tests Locally (run from project root)\n\n**Run all tests:**\n```bash\nmake test-api\n```\n\n**Run all tests in parallel (not yet implemeted):**\n```bash\nmake test-api-parallel\n```\n\n**Run specific test suite using focus:**\n```bash\n# Example Run only cluster management tests, which is the suite name\nmake test-api-focus FOCUS=\"Core Cluster Management\"\n```\n\n**Run specific test spec using focus:**\n```bash\n# Example Run only the return all clusters test spec, which uses the test spec name.\nmake test-api-focus FOCUS=\"should return all clusters for the organization\"\n```\n\n**Advanced Ginkgo options:**\n```bash\n# Run with different parallel workers\ncd test/api/suites \u0026\u0026 ginkgo run --procs=8 --json-report=test-results.json\n\n# Run with verbose output\ncd test/api/suites \u0026\u0026 ginkgo run -v --show-node-events\n\n# Skip specific tests\ncd test/api/suites \u0026\u0026 ginkgo run --skip=\"Machine Operations\"\n\n# Randomize test order\ncd test/api/suites \u0026\u0026 ginkgo run --randomize-all\n```\n\n#### GitHub Actions Workflow\n\nThe API tests can be triggered manually via GitHub Actions using `workflow_dispatch`:\n\n**Workflow Inputs:**\n\n| Input | Type | Description | Default |\n|-------|------|-------------|---------|\n| `run_dev` | boolean | Run Dev environment tests | `true` |\n| `run_uat` | boolean | Run UAT environment tests | `false` |\n| `focus` | choice | Test suite to run | `All` |\n\n**Available Test Suite Options:**\n- `All` - Run all test suites\n- `Core Cluster Management` - Cluster CRUD operations and lifecycle tests\n- `Discovery and Metadata` - Region, flavor, and image discovery tests\n- `Security and Authentication` - Authentication and input validation tests\n- `Machine Operations` - Machine power operations and eviction tests\n\n**Triggering Manually:**\n\n1. Navigate to **Actions** tab in GitHub\n2. Select **API Tests** workflow\n3. Click **Run workflow**\n4. Select which environments to test:\n   - **Run Dev tests** (checked by default)\n   - **Run UAT tests** (unchecked by default)\n5. Choose test suite from the **focus** dropdown\n6. Click **Run workflow**\n\n**Test Artifacts:**\n\nAfter each run, test results are uploaded as artifacts per environment:\n- `api-test-results-dev` / `api-test-results-uat` - JSON format test results\n- `api-test-junit-dev` / `api-test-junit-uat` - JUnit XML format for CI integration\n\n#### Cleaning Up Test Artifacts locally.\n\n```bash\nmake test-api-clean\n```\n\n### Contract Testing\n\nThe compute service uses consumer-driven contract testing to validate interactions with dependent services (e.g., uni-region, uni-identity) without requiring full service deployments.\n\n#### Prerequisites\n\n**Install Pact FFI Library:**\n\nConsumer contract tests require the Pact FFI library to be installed locally.\n\n**macOS:**\n```bash\nbrew tap pact-foundation/pact-ruby-standalone\nbrew install pact-ruby-standalone\nmkdir -p $HOME/Library/pact\ncp /usr/local/opt/pact-ruby-standalone/libexec/lib/*.dylib $HOME/Library/pact/\n```\n\n**Start Pact Broker:**\n\nThe Pact Broker is required for publishing and managing contracts. Reference the uni-core repository's make target for starting a local broker instance, or run:\n\n```bash\ndocker run -d --name pact-broker \\\n  -p 9292:9292 \\\n  -e PACT_BROKER_DATABASE_URL=sqlite:///pact_broker.sqlite \\\n  pactfoundation/pact-broker:latest\n```\n\n#### Running Consumer Contract Tests\n\n**Run all consumer tests:**\n```bash\nmake test-contracts-consumer\n```\n\n**Publish pacts to broker:**\n```bash\nmake publish-pacts\n```\n\n**Available make targets:**\n- `test-contracts-consumer` - Run consumer contract tests\n- `publish-pacts` - Publish generated pacts to Pact Broker\n- `can-i-deploy` - Check if service version is safe to deploy\n- `record-deployment` - Record deployment to an environment\n- `clean-contracts` - Clean generated pact files\n\n**Configuration:**\n\nBroker settings can be configured via environment variables or Makefile defaults:\n- `PACT_BROKER_URL` - Broker base URL (default: `http://localhost:9292`)\n- `PACT_BROKER_USERNAME` - Broker username (default: `pact`)\n- `PACT_BROKER_PASSWORD` - Broker password (default: `pact`)\n\n#### Writing Consumer Tests\n\nConsumer tests follow a standard pattern:\n\n1. Create a Pact mock provider using `contract.NewV4Pact()`\n2. Define interactions with `Given()`, `UponReceiving()`, `WithRequest()`, `WillRespondWith()`\n3. Execute the test using your actual client code against the mock server\n4. Verify expectations using Gomega matchers\n(you can and should use the OpenAPI spec as a guide here for building tests)\n\n**Example structure:**\n```go\nvar _ = Describe(\"Provider Service Contract\", func() {\n    var pact *consumer.V4HTTPMockProvider\n\n    BeforeEach(func() {\n        pact, _ = contract.NewV4Pact(contract.PactConfig{\n            Consumer: \"uni-compute\",\n            Provider: \"uni-region\",\n            PactDir:  \"../pacts\",\n        })\n    })\n\n    It(\"returns expected response\", func() {\n        pact.AddInteraction().\n            GivenWithParameter(...).\n            UponReceiving(\"a request\").\n            WithRequest(\"GET\", \"/api/v1/endpoint\").\n            WillRespondWith(200, func(b *consumer.V4ResponseBuilder) {\n                b.JSONBody(...)\n            })\n\n        test := func(config consumer.MockServerConfig) error {\n            // Use actual client code here\n            return nil\n        }\n\n        Expect(pact.ExecuteTest(testingT, test)).To(Succeed())\n    })\n})\n```\n\nFor complete examples, see `test/contracts/consumer/region/regions_test.go`.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnscaledev%2Funi-compute","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnscaledev%2Funi-compute","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnscaledev%2Funi-compute/lists"}