# sdb-operator.yaml

This generates the Operator Deployment object that will spawn and maintain the Operator.

Create a deployment definition file using the template below.

The `--cluster-id` argument must match the name of the SingleStore custom resource as defined in the `sdb-cluster.yaml` (`"sdb-cluster"` by default). This value can be edited as long as these values match, so that the Operator knows which custom resource to manage.

```yaml
apiVersion: apps/v1
kind: Deployment
metadata:
  name: sdb-operator
  labels:
    app.kubernetes.io/component: operator
spec:
  replicas: 1
  selector:
    matchLabels:
      name: sdb-operator
  template:
    metadata:
      labels:
        name: sdb-operator
    spec:
      serviceAccountName: sdb-operator
      containers:
        - name: sdb-operator
          image: operator_image_tag
          imagePullPolicy: Always
          args: [
            # Cause the operator to merge rather than replace annotations on services
            "--merge-service-annotations",
            # Allow the process inside the container to have read/write access to the `/var/lib/memsql` volume.
            "--fs-group-id", "5555",
            "--cluster-id", "sdb-cluster"          ]
          env:
            - name: WATCH_NAMESPACE
              valueFrom:
                fieldRef:
                  fieldPath: metadata.namespace
            - name: POD_NAME
              valueFrom:
                fieldRef:
                  fieldPath: metadata.name
            - name: OPERATOR_NAME
              value: "sdb-operator"

```

You must edit this file and replace `operator_image_tag` with the either the local `singlestore/operator` Docker image you pulled down (such as `"sdb-operator"`), or add in an `imagePullSecrets` section under the `spec` section and reference a Kubernetes Secret that you can create via `kubectl apply`.

Refer to the [Kubernetes documentation](https://kubernetes.io/docs/concepts/containers/images/#specifying-imagepullsecrets-on-a-pod) for more information on `imagePullPolicy` and creating Secrets.

***

Modified at: July 20, 2023

Source: [/db/v9.1/deploy/kubernetes/create-the-object-definition-files/sdb-operator-yaml/](https://docs.singlestore.com/db/v9.1/deploy/kubernetes/create-the-object-definition-files/sdb-operator-yaml/)

(An index of the documentation is available at /llms.txt)
