> 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/core-concepts.md).

# Core concepts

### Ports

`servicePorts` declares the ports exposed by the Service. Each port requires a `name` and a numeric `port`.

```yaml
spec:
  servicePorts:
    - name: postgres
      port: 5432
```

For TCP services, consumers can resolve the Service endpoint from the Service runtime metadata. For HTTP services, configure the container to listen on the declared port and add any ingress configuration supported by the runtime.

### Replicas

`replicas` controls how many identical Service instances are maintained. Use more than one replica for stateless services that can handle traffic concurrently. Stateful services, such as a single Postgres instance, commonly run with `replicas: 1`.

```yaml
spec:
  replicas: 1
```

### Stateful Services

Set `stateful: true` when the Service needs stable identity or attached storage.

```yaml
spec:
  stateful: true
```

Stateful Services can use either inline disk storage or an existing Volume Resource:

* Use `disk` when storage belongs to the Service lifecycle and can be deleted with the Service.
* Use `use.volumes` when the data must persist independently of the Service.

See also: [Provision inline storage](/references/dataos-resources/service.md) and [Persist storage across workloads](/references/dataos-resources/service.md).

### Stack and stackSpec

`stack` selects the runtime stack. `stackSpec` contains stack-specific configuration. For the `container` stack, provide the container image, command, and arguments.

```yaml
spec:
  stack: container
  stackSpec:
    image: docker.io/library/postgres:18-alpine
    command:
      - docker-entrypoint.sh
    arguments:
      - postgres
```

### Projections

Use `use.projection` to project Secrets, environment variables, and files into the Service runtime. The following example reads `POSTGRES_PASSWORD` from a Secret and exposes it as an environment variable.

For projection syntax, template engines, data sources, and troubleshooting, see [Projections](/references/dataos-resources/secret/projections.md).

```yaml
spec:
  use:
    projection:
      templateType: liquid
      secrets:
        - id: ${{tenant-id}}:${{secret-name}}
          contextAlias: pgSecret
      projections:
        envVars:
          - key: POSTGRES_PASSWORD
            template: "{{ secrets['pgSecret'].POSTGRES_PASSWORD }}"
```


---

# 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/core-concepts.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.
