UCS Microservice Additional Features#

Horizontal Pod Autoscaler (HPA) support#

HPA is a useful feature in Kubernetes. It allows workloads to dynamically scale up and down based on resource usage. This includes memory, CPU, or custom resources.

A UCS Microservice definition allows you to set these HPA requirements. In the manifest.yaml, you can set the hpa parameter of the ucf.k8s.app.deployment built-in component. Below is an example of setting memory and CPU target utilization values for an example echo server (note that several manifest components have been omitted for brevity). The HPA settings indicate that pods should scale up and down between a minimum of 1 pod and a maximum of 4. This scaling is based on CPU resource utilization and memory utilization thresholds. The threshold defined for each is a percentage (75% in this example) of the corresponding target value defined within the pod resource requests.

type: msapplication
specVersion: 2.5.0
name: ucf.svc.echo
chartName: echo-server
description: Echo server example
version: 0.0.1
displayName: "Echo Server"
nSpectId: NSPECT-0000-0000

ingress-endpoints:
  - name: http-api
    description: Short description of http-api ingress endpoint
    scheme: http
    data-flow: in-out # Or in or out


#params:
  #stringToEcho: someString
  #> type: string
  #> enum_values: someString, someOtherString
  #> description: String to echo in init container

---
spec:
  - name: echo-deployment
    type: ucf.k8s.app.deployment
    parameters:
      apptype: stateless
      hpa:
        maxReplicas: 4
        minReplicates: 1 # default if not specified
        cpu:
          averageUtilization: 75
        memory:
          averageUtilization: 75
  - name: "echo-container"
    type: ucf.k8s.container
    parameters:
      image:
        repository: ealen/echo-server
        tag: "0.9.2"
      ports:
      - containerPort: 80
        name: http
      - containerPort: 8002
        name: metrics
      resources:
        limits:
          cpu: "0.5"
          memory: "500Mi"

  - name: echo-service
    type: ucf.k8s.service
    parameters:
      fullNameOverride: true
      ports:
      - port: 3000
        name: http-api
        targetPort: 80

See the Kubernetes HPA documentation for more information about HPA.

Tagging a UCS Microservice#

As of version 2.10.0, there is a new command ucf_ms_builder_cli service tag:

usage: ucf_ms_builder_cli service tag [-h] -u URI -n NEW_VERSION

Retag a microservice in a given team as a new version. Associated Helm Charts will also be tagged

options:
  -h, --help            show this help message and exit
  -u URI, --uri URI     The NGC URI of the existing version of the microservice to tag, specified as <org>/<team>/<name>:<version>
  -n NEW_VERSION, --new-version NEW_VERSION
                        The new version of the microservice to create

A common use case is to retag a version that was a release candidate (RC) to a non-RC version. For example:

ucf_ms_builder_cli service tag --uri "eevaigoeixww/staging/ucf.svc.tika:0.0.2-rc1" --new-version "0.0.2"

Note

The resource name (ucf.svc.tika in this case) can be specified in NGC format where the . is replaced by an underscore. Passing eevaigoeixww/staging/ucf_svc_tika to the --uri argument is also acceptable.

This command also adds some JSON metadata to the NGC resource in the customAttributes field. You can view this using the NGC CLI:

ngc registry resource info eevaigoeixww/staging/ucf_svc_tika:0.0.2 --org eevaigoeixww --format_type json

{
    "createdByUser": "69vle3sf391vsrbmddhegf7j7h",
    "createdDate": "2025-02-20T21:55:14.544Z",
    "customMetrics": [
        {
            "attributes": [
                {
                    "key": "tagged_from_version",
                    "value": "0.0.2-rc1"
                },
                {
                    "key": "created_from",
                    "value": "UCS Tools 2.10.0-rc8"
                }
            ],
            "name": "ucs_tools"
        }
    ],
    "status": "UPLOAD_COMPLETE",
    "totalFileCount": 5,
    "totalSizeInBytes": 5717,
    "versionId": "0.0.2"
}

customMetrics is a list of objects. UCS Tools adds an object with the “name” property set to “ucs_tools”. Its attributes include:

  1. tagged_from_version: The version of the UCS MS that was used for the source tag

  2. created_from: The version of the tools that was used to tag the UCS MS.