Prerequisites 🔗︎

  • Thanos operator requires Kubernetes v1.14.x or later.
  • For the Helm based installation you need Helm v3.0.2 or later.
  1. Create the monitor namespace where the Thanos operator and other components will be deployed.

    CAUTION:

    Prometheus operator and Thanos must be deployed into the same namespace.
    kubectl create namespace monitor
    
  2. (Optional) If you want to store your metrics in an object store, complete the following steps.

    1. Create an Object Store secret.

      Example S3 configuration

      cat <<'EOF' >> object-store.yaml
      type: S3
      config:
        endpoint: "s3.eu-west-1.amazonaws.com"
        bucket: "test-bucket"
        region: "eu-west-1"
        access_key: "XXXXXXXXX"
        secret_key: "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
      EOF
      
    2. Deploy the secret on Kubernetes

      kubectl create secret generic thanos --from-file=object-store.yaml=object-store.yaml --namespace monitor
      
    3. Create the Thanos sidecar definition. Remember to set externalLabels as it identifies the Prometheus instance for Thanos.

      Extra configuration for prometheus operator.

      cat <<'EOF' >> thanos-sidecar.yaml
      prometheus:
        prometheusSpec:
          thanos:
            image: quay.io/thanos/thanos:v0.17.2
            version: v0.17.2
            objectStorageConfig:
              name: thanos
              key: object-store.yaml
          externalLabels: 
            cluster: thanos-operator-test
      EOF
      

Install the Thanos operator with Helm 🔗︎

To install the Thanos operator with Helm 3, complete the following steps. Alternatively, you can install the Thanos operator with the One Eye CLI.

  1. Add the Prometheus operator Helm repository.

    helm repo add prometheus-community https://prometheus-community.github.io/helm-charts
    helm repo update
    
  2. Install the Prometheus operator. If you want to use object storage to store your metrics, include the configuration of the Thanos sidecar.

    helm install prometheus-operator --namespace monitor prometheus-community/kube-prometheus-stack -f thanos-sidecar.yaml
    
  3. Add the Thanos operator chart repository.

    helm repo add banzaicloud-stable https://kubernetes-charts.banzaicloud.com
    helm repo update
    
  4. Install the Thanos operator.

    helm install thanos-operator --namespace monitor banzaicloud-stable/thanos-operator
    

Install the Thanos operator from Kubernetes manifests 🔗︎

  1. Complete the Prerequisites.

  2. Install the Thanos operator using the kustomize deploy model from the project repository.

    make install
    make deploy IMG=banzaicloud/thanos-operator:latest
    
  3. Apply the CRDs for a single cluster.

    • Thanos:

      apiVersion: monitoring.banzaicloud.io/v1alpha1
      kind: Thanos
      metadata:
        name: thanos-sample
      spec:
        query: {}
        rule: {}
        storeGateway: {}
      

      To automatically discover all Query instances on the cluster, set the queryDiscovery parameter to true:

      apiVersion: monitoring.banzaicloud.io/v1alpha1
      kind: Thanos
      metadata:
        name: query
      spec:
        query: {}
        queryDiscovery: true
      
    • ObjectStore

      apiVersion: monitoring.banzaicloud.io/v1alpha1
      kind: ObjectStore
      metadata:
        name: objectstore-sample
      spec:
        config:
          mountFrom:
            secretKeyRef:
              name: thanos
              key: object-store.yaml
        bucketWeb: {}
        compactor: {}
      
    • StoreEndpoint

      apiVersion: monitoring.banzaicloud.io/v1alpha1
      kind: StoreEndpoint
      metadata:
      name: storeendpoint-sample
      spec:
      thanos: thanos-sample
      config:
          mountFrom:
          secretKeyRef:
              name: thanos
              key: object-store.yaml
      selector: {}
      

      You can specify the URL of remote Prometheus instances in the following http(s)://: format, for example:

      apiVersion: monitoring.banzaicloud.io/v1alpha1
      kind: StoreEndpoint
      metadata:
        name: storeendpoint-sample
      spec:
        thanos: thanos-sample
        config:
          mountFrom:
            secretKeyRef:
              name: thanos
              key: object-store.yaml
        url: http://example.com:10901
      

      Note: If you are running multiple Prometheus instances on single cluster, you can define different Prometheuses and Endpoints in the StoreEndpoint CRDs.

  4. Validate your deployment

Install the Thanos operator with the One Eye CLI 🔗︎

One Eye is a commercial product that can install and configure the Thanos operator and all its dependencies.

  1. Install the One Eye CLI.

  2. Deploy the Thanos operator, optionally with the secret of the object store you have created in the Prerequisites.

    one-eye thanos install --prometheus --secret one-eye/object-store.yaml
    
  3. Validate your deployment

Validate Thanos operator deployment 🔗︎

To verify that the installation was successful, complete the following steps.

  1. Check the status of the pods. You should see a new thanos-operator pod.

    $ kubectl -n monitor get pods
    NAME                                        READY   STATUS    RESTARTS   AGE
    thanos-operator-7df8485bf6-gf5gk   1/1     Running   0          13s
    
  2. Check the CRDs. You should see the following three new CRDs.

    $  kubectl get crd
    NAME                                    CREATED AT
    objectstores.monitoring.banzaicloud.io      2020-02-07T21:48:20Z
    storeendpoints.monitoring.banzaicloud.io    2020-02-07T21:48:20Z
    thanos.monitoring.banzaicloud.io            2020-02-07T21:48:20Z
    
  3. Verify the installation by opening the Thanos query page.

      one-eye thanos connect