> For the complete documentation index, see [llms.txt](https://v2.dataos.info/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://v2.dataos.info/references/dataos-resources/service/example.md).

# Example

Use this page for complete Service manifests and related resources.

## TCP Postgres Service with inline disk

This example runs Postgres as a stateful TCP Service. The `disk` block provisions storage mounted at `/var/lib/postgresql/data`. The disk is tied to the Service lifecycle.

{% tabs %}
{% tab title="Secret" %}

```yaml
name: ${TCP_PG_SECRET_NAME}
version: v2alpha
type: secret
description: "Password for TCP Postgres service"
layer: user
secret:
  type: key-value
  data:
    POSTGRES_PASSWORD: ${TCP_PG_PASSWORD}
```

{% endtab %}

{% tab title="Service" %}

```yaml
version: v2alpha
name: ${TCP_PG_SERVICE_NAME}
type: service
tags:
  - postgres
  - database
  - test
description: "Single replica stateful Postgres service for TCP connectivity test"
spec:
  hostname: ${TCP_PG_SERVICE_NAME}
  compute: ${COMPUTE_NAME}
  stateful: true
  replicas: 1
  servicePorts:
    - name: postgres
      port: 5432
  resources:
    requests:
      cpu: 250m
      memory: 512Mi
    limits:
      cpu: "1"
      memory: 1Gi
  disk:
    size: 10Gi
    type: disk
    mountPath: /var/lib/postgresql/data
  use:
    projection:
      templateType: liquid
      secrets:
        - id: ${ENTITY_TENANT_ID}:${TCP_PG_SECRET_NAME}
          contextAlias: pgSecret
      projections:
        envVars:
          - key: POSTGRES_PASSWORD
            template: "{{ secrets['pgSecret'].POSTGRES_PASSWORD }}"
          - key: POSTGRES_USER
            templateType: none
            template: "postgres"
          - key: POSTGRES_DB
            templateType: none
            template: "postgres"
          - key: PGDATA
            templateType: none
            template: "/var/lib/postgresql/data/pgdata"
  stack: container
  stackSpec:
    image: docker.io/library/postgres:18-alpine
    command:
      - docker-entrypoint.sh
    arguments:
      - postgres
```

{% endtab %}
{% endtabs %}

## TCP Postgres Service with existing Volume

Use `use.volumes` when the database files must live in a Volume Resource whose lifecycle is managed separately from the Service.

```yaml
version: v2alpha
name: ${TCP_PG_SERVICE_NAME}vol
type: service
tags:
  - postgres
  - database
  - test
description: "Single replica stateful Postgres service for TCP connectivity test"
spec:
  hostname: ${TCP_PG_SERVICE_NAME}vol
  compute: ${COMPUTE_NAME}
  stateful: true
  replicas: 1
  servicePorts:
    - name: postgres
      port: 5432
  resources:
    requests:
      cpu: 250m
      memory: 512Mi
    limits:
      cpu: "1"
      memory: 1Gi
  use:
    volumes:
      - id: ${TCP_PG_VOLUME_ID}
        directory: /var/lib/postgresql/data
        readOnly: false
    projection:
      templateType: liquid
      secrets:
        - id: ${ENTITY_TENANT_ID}:${TCP_PG_SECRET_NAME}vol
          contextAlias: pgSecret
      projections:
        envVars:
          - key: POSTGRES_PASSWORD
            template: "{{ secrets['pgSecret'].POSTGRES_PASSWORD }}"
          - key: POSTGRES_USER
            templateType: none
            template: "postgres"
          - key: POSTGRES_DB
            templateType: none
            template: "postgres"
          - key: PGDATA
            templateType: none
            template: "/var/lib/postgresql/data/pgdata"
  stack: container
  stackSpec:
    image: docker.io/library/postgres:18-alpine
    command:
      - docker-entrypoint.sh
    arguments:
      - postgres
```

## Deploy with a Bundle

For Services that depend on Secrets, Volumes, or verification Workflows, package the resources in a Bundle so dependencies are applied in order.

```yaml
version: v2alpha
name: test-service-tcp-postgres
type: bundle
description: "Integration test: deploy stateful Postgres service, verify TCP connectivity on port 5432"
tags:
  - test
  - service
  - tcp
  - postgres
bundle:
  resources:
    - id: tcp-pg-secret
      file: tests/service/tcp-postgres/secret.yaml

    - id: tcp-pg-service
      file: tests/service/tcp-postgres/service.yaml
      dependencies:
        - tcp-pg-secret
      dependencyConditions:
        - resourceId: tcp-pg-secret
          status:
            is:
              - active

    - id: verify-tcp-pg
      file: tests/service/tcp-postgres/verify-workflow.yaml
      dependencies:
        - tcp-pg-service
      dependencyConditions:
        - resourceId: tcp-pg-service
          status:
            is:
              - active
          runtime:
            contains:
              - "running"
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://v2.dataos.info/references/dataos-resources/service/example.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
