# First steps

> Deploy and verify a Hive metastore cluster with PostgreSQL and MinIO. Follow the setup guide and ensure all pods are ready for operation.

After going through the [Installation](https://docs.stackable.tech/home/stable/hive/getting_started/installation/index.md) section and having installed all the operators, deploy a Hive metastore cluster and it’s dependencies. Afterward you can [verify that it works](https://docs.stackable.tech/home/stable/hive/getting_started/first_steps/index.md).

## Setup

Several requirements should have already been installed in the [Installation guide](https://docs.stackable.tech/home/stable/hive/getting_started/installation/index.md):

-   [Commons Operator](https://docs.stackable.tech/home/stable/commons-operator/index.md)

-   [Secret Operator](https://docs.stackable.tech/home/stable/secret-operator/index.md)

-   [Listener Operator](https://docs.stackable.tech/home/stable/listener-operator/index.md)

-   [Hive Operator](https://docs.stackable.tech/home/stable/hive/index.md)

-   PostgreSQL

-   MinIO for S3


### S3Connection

In order to connect Hive to MinIO we need to create several files (or concat in one file).

An [S3Connection](https://docs.stackable.tech/home/stable/concepts/s3/index.md) to connect to MinIO (`hive-minio-s3-connection.yaml`)

```yaml
---
apiVersion: s3.stackable.tech/v1alpha1
kind: S3Connection
metadata:
  name: minio
spec:
  host: minio
  port: 9000
  accessStyle: Path
  credentials:
    secretClass: hive-s3-secret-class
```

Credentials for the S3Connection to log into MinIO (`hive-minio-credentials.yaml`)

```yaml
---
apiVersion: v1
kind: Secret
metadata:
  name: hive-s3-secret
  labels:
    secrets.stackable.tech/class: hive-s3-secret-class
stringData:
  accessKey: hive
  secretKey: hivehive
```

A SecretClass for the credentials to the Minio. The credentials were defined in the installation of Minio (`hive-minio-credentials-secret-class.yaml`)

```yaml
---
apiVersion: secrets.stackable.tech/v1alpha1
kind: SecretClass
metadata:
  name: hive-s3-secret-class
spec:
  backend:
    k8sSearch:
      searchNamespace:
        pod: {}
```

And lastly the actual Apache Hive cluster definition (`hive-postgres-s3.yaml`). Note how it references the `minio` S3 object

```yaml
---
apiVersion: hive.stackable.tech/v1alpha1
kind: HiveCluster
metadata:
  name: hive-postgres-s3
spec:
  image:
    productVersion: 4.2.0
  clusterConfig:
    metadataDatabase:
      postgresql:
        host: postgresql
        database: hive
        credentialsSecretName: hive-credentials
    s3:
      reference: minio
  metastore:
    roleGroups:
      default:
        replicas: 1
---
apiVersion: v1
kind: Secret
metadata:
  name: hive-credentials
type: Opaque
stringData:
  username: hive
  password: hive
```

Once the files are created apply them to the cluster:

```bash
kubectl apply -f hive-minio-credentials.yaml
kubectl apply -f hive-minio-credentials-secret-class.yaml
kubectl apply -f hive-minio-s3-connection.yaml
kubectl apply -f hive-postgres-s3.yaml
```

## Verify that it works

Make sure that all the Pods in the StatefulSets are ready:

```bash
kubectl get statefulset
```

The output should show all pods ready:

```bash
NAME                                 READY   AGE
hive-postgres-s3-metastore-default   1/1     48s
```

For further testing we recommend to use e.g. the python [hive-metastore-client](https://github.com/quintoandar/hive-metastore-client) in order to e.g. create tables or connect a product like Trino via the [Stackable Trino Operator](https://docs.stackable.tech/home/stable/trino/index.md).

## What’s next

Have a look at the [usage guide](https://docs.stackable.tech/home/stable/hive/usage-guide/index.md) to find out more about the features of the Operator.
