Tutorials

Sample Application with UDS Core

This tutorial uses UDS CLI to deploy an example application, podinfo, on top of UDS Core as a UDS Bundle.

Prerequisites

Quickstart

To begin, a Zarf Package needs to be created for podinfo. See the Zarf documentation for in-depth information on how to create a Zarf Package, or simply use the information provided below.

Make a Directory

Make a new directory for this package using the following command:

mkdir package

Create the following zarf.yaml in the new directory:

kind: ZarfPackageConfig
metadata:
  name: podinfo
  version: 0.0.1

components:
  - name: podinfo
    required: true
    charts:
      - name: podinfo
        version: 6.4.0
        namespace: podinfo
        url: https://github.com/stefanprodan/podinfo.git
        gitPath: charts/podinfo
    images:
      - ghcr.io/stefanprodan/podinfo:6.4.0
    actions:
      onDeploy:
        after:
          - wait:
              cluster:
                kind: deployment
                name: podinfo
                namespace: podinfo
                condition: available

Create the Zarf Package

Run the following command in the same directory as the above zarf.yaml. This will create a Zarf Package named zarf-package-podinfo-amd64-0.0.1.tar.zst:

zarf package create --confirm

Create the UDS Bundle

Create the UDS Bundle in the same directory as the package directory. The following bundle includes:

  • k3d cluster: uds-k3d.
  • Zarf init package: init.
  • UDS Core: core.
  • Locally built example application: podinfo.

Create the following uds-bundle.yaml:

kind: UDSBundle
metadata:
  name: podinfo-bundle
  description: Bundle with k3d, Zarf init, UDS Core, and podinfo.
  architecture: amd64
  version: 0.0.1

packages:
  - name: uds-k3d
    repository: ghcr.io/defenseunicorns/packages/uds-k3d
    ref: 0.3.1
    overrides:
      uds-dev-stack:
        minio:
          variables:
            - name: buckets
              description: "Set Minio Buckets"
              path: buckets
            - name: svcaccts
              description: "Minio Service Accounts"
              path: svcaccts
            - name: users
              description: "Minio Users"
              path: users
            - name: policies
              description: "Minio policies"
              path: policies

  - name: init
    repository: oci://ghcr.io/defenseunicorns/packages/init
    ref: v0.32.1

  - name: core
    repository: oci://ghcr.io/defenseunicorns/packages/uds/core
    ref: 0.9.1-upstream

  - name: podinfo
    path: ./package/
    ref: 0.0.1

UDS Bundles can easily be configured to include additional applications and capabilities. For example, if you would like to deploy dos-games instead of podinfo, in the uds-bundle.yaml simply replace:

- name: podinfo
  path: ./package/
  ref: 0.0.1

with:

- name: dos-games
  repository: oci://defenseunicorns/dos-games
  ref: 1.0.0

Create and Confirm the UDS Bundle

This process will take a few minutes while UDS CLI pulls down the images that will be deployed. This command will produce a UDS Bundle named uds-bundle-podinfo-bundle-amd64-0.0.1.tar.zst:

uds create --confirm

Deploy

You can now deploy the bundle to create the k3d cluster in order to deploy UDS Core and podinfo. This process will take approximately 5 to 10 minutes to complete:

uds deploy uds-bundle-podinfo-bundle-amd64-0.0.1.tar.zst --confirm

Interact with Cluster (Optional)

Once successfully deployed, you have the option interact with the deployed cluster and applications using kubectl or k9s. Please note that the output for your podinfo pod will likely have a different name:

kubectl get pods -n podinfo
NAME                       READY   STATUS    RESTARTS   AGE
podinfo-67bf846d65-hrl59   1/1     Running   0          66s

Connect to podinfo using kubectl port-forward:

kubectl port-forward pod/<pod_name> <local_port>:9898

Example command using the above sample output from get pods:

kubectl port-forward pod/podinfo-67bf846d65-hrl59 9898:9898 -n podinfo

You can now use a web browser to naviage to http://localhost:<local_port> to interact with podinfo.

Clean up

Execute the following command to clean up your cluster:

k3d cluster delete uds

Last modified June 26, 2024 : (3033e6b)