github.com/verrazzano/verrazzano@v1.7.0/platform-operator/thirdparty/charts/thanos/templates/storegateway/statefulset-sharded.yaml (about)

     1  {{- if and .Values.storegateway.enabled .Values.storegateway.sharded.enabled }}
     2  
     3  {{- $shards := int 0 }}
     4  {{- $hashPartitioning := false }}
     5  {{- $timePartitioning := false }}
     6  {{- if .Values.storegateway.sharded.hashPartitioning.shards }}
     7    {{- $shards = int .Values.storegateway.sharded.hashPartitioning.shards }}
     8    {{- $hashPartitioning = true }}
     9  {{- else }}
    10    {{- $shards = len .Values.storegateway.sharded.timePartitioning }}
    11    {{- $timePartitioning = true }}
    12  {{- end }}
    13  
    14  {{- range $index, $_ := until $shards }}
    15  apiVersion: {{ include "common.capabilities.statefulset.apiVersion" $ }}
    16  kind: StatefulSet
    17  metadata:
    18    name: {{ printf "%s-storegateway-%s" (include "common.names.fullname" $) (toString $index) | trunc 63 | trimSuffix "-" }}
    19    namespace: {{ $.Release.Namespace | quote }}
    20    labels: {{- include "common.labels.standard" $ | nindent 4 }}
    21      app.kubernetes.io/component: storegateway
    22      shard: {{ $index | quote }}
    23      {{- if $.Values.commonLabels }}
    24      {{- include "common.tplvalues.render" ( dict "value" $.Values.commonLabels "context" $ ) | nindent 4 }}
    25      {{- end }}
    26    {{- if $.Values.commonAnnotations }}
    27    annotations: {{- include "common.tplvalues.render" ( dict "value" $.Values.commonAnnotations "context" $ ) | nindent 4 }}
    28    {{- end }}
    29  spec:
    30    replicas: {{ $.Values.storegateway.replicaCount }}
    31    podManagementPolicy: {{ $.Values.storegateway.podManagementPolicy }}
    32    {{- $svcNamePrefix := printf "%s-storegateway" (include "common.names.fullname" $) | trunc 61 | trimSuffix "-" }}
    33    serviceName: {{ printf "%s-%s" $svcNamePrefix (toString $index) }}
    34    {{- if $.Values.storegateway.updateStrategy }}
    35    updateStrategy: {{- toYaml $.Values.storegateway.updateStrategy | nindent 4 }}
    36    {{- end }}
    37    selector:
    38      matchLabels: {{- include "common.labels.matchLabels" $ | nindent 6 }}
    39        app.kubernetes.io/component: storegateway
    40        shard: {{ $index | quote }}
    41    template:
    42      metadata:
    43        labels: {{- include "common.labels.standard" $ | nindent 8 }}
    44          app.kubernetes.io/component: storegateway
    45          shard: {{ $index | quote }}
    46          {{- if $.Values.commonLabels }}
    47          {{- include "common.tplvalues.render" ( dict "value" $.Values.commonLabels "context" $ ) | nindent 8 }}
    48          {{- end }}
    49          {{- if $.Values.storegateway.podLabels }}
    50          {{- include "common.tplvalues.render" (dict "value" $.Values.storegateway.podLabels "context" $) | nindent 8 }}
    51          {{- end }}
    52        annotations:
    53          checksum/objstore-configuration: {{ include (print $.Template.BasePath "/objstore-secret.yaml") $ | sha256sum }}
    54          {{- if (include "thanos.storegateway.createConfigmap" $) }}
    55          checksum/storegateway-configuration: {{ include (print $.Template.BasePath "/storegateway/configmap.yaml") $ | sha256sum }}
    56          {{- end }}
    57          {{- if $.Values.storegateway.podAnnotations }}
    58          {{- include "common.tplvalues.render" (dict "value" $.Values.storegateway.podAnnotations "context" $) | nindent 8 }}
    59          {{- end }}
    60      spec:
    61        {{- include "thanos.imagePullSecrets" $ | nindent 6 }}
    62        serviceAccount: {{ include "thanos.serviceAccountName" (dict "component" "storegateway" "context" $) }}
    63        automountServiceAccountToken: {{ $.Values.storegateway.automountServiceAccountToken }}
    64        {{- if $.Values.storegateway.hostAliases }}
    65        hostAliases: {{- include "common.tplvalues.render" (dict "value" $.Values.storegateway.hostAliases "context" $) | nindent 8 }}
    66        {{- end }}
    67        {{- if $.Values.storegateway.affinity }}
    68        affinity: {{- include "common.tplvalues.render" (dict "value" $.Values.storegateway.affinity "context" (set $ "shardLoopId" $index)) | nindent 8 }}
    69        {{- else }}
    70        affinity:
    71          podAffinity: {{- include "common.affinities.pods" (dict "type" $.Values.storegateway.podAffinityPreset "component" "storegateway" "context" $) | nindent 10 }}
    72          podAntiAffinity: {{- include "common.affinities.pods" (dict "type" $.Values.storegateway.podAntiAffinityPreset "component" "storegateway" "context" $) | nindent 10 }}
    73          nodeAffinity: {{- include "common.affinities.nodes" (dict "type" $.Values.storegateway.nodeAffinityPreset.type "key" $.Values.storegateway.nodeAffinityPreset.key "values" $.Values.storegateway.nodeAffinityPreset.values) | nindent 10 }}
    74        {{- end }}
    75        {{- if $.Values.storegateway.nodeSelector }}
    76        nodeSelector: {{- include "common.tplvalues.render" (dict "value" $.Values.storegateway.nodeSelector "context" (set $ "shardLoopId" $index)) | nindent 8 }}
    77        {{- end }}
    78        {{- if $.Values.storegateway.tolerations }}
    79        tolerations: {{- include "common.tplvalues.render" (dict "value" $.Values.storegateway.tolerations "context" (set $ "shardLoopId" $index)) | nindent 8 }}
    80        {{- end }}
    81        {{- if $.Values.storegateway.priorityClassName }}
    82        priorityClassName: {{ $.Values.storegateway.priorityClassName | quote }}
    83        {{- end }}
    84        {{- if $.Values.storegateway.schedulerName }}
    85        schedulerName: {{ $.Values.storegateway.schedulerName }}
    86        {{- end }}
    87        {{- if $.Values.storegateway.podSecurityContext.enabled }}
    88        securityContext: {{- omit $.Values.storegateway.podSecurityContext "enabled" | toYaml | nindent 8 }}
    89        {{- end }}
    90        {{- if $.Values.storegateway.topologySpreadConstraints }}
    91        topologySpreadConstraints: {{- include "common.tplvalues.render" (dict "value" $.Values.storegateway.topologySpreadConstraints "context" $) | nindent 8 }}
    92        {{- end }}
    93        {{- if or $.Values.storegateway.initContainers (and $.Values.volumePermissions.enabled $.Values.storegateway.persistence.enabled) }}
    94        initContainers:
    95          {{- if and $.Values.volumePermissions.enabled $.Values.storegateway.persistence.enabled }}
    96          - name: init-chmod-data
    97            image: {{ include "thanos.volumePermissions.image" $ }}
    98            imagePullPolicy: {{ $.Values.volumePermissions.image.pullPolicy | quote }}
    99            command:
   100              - sh
   101              - -c
   102              - |
   103                mkdir -p /data
   104                chown -R "{{ $.Values.storegateway.containerSecurityContext.runAsUser }}:{{ $.Values.storegateway.podSecurityContext.fsGroup }}" /data
   105            securityContext:
   106              runAsUser: 0
   107            volumeMounts:
   108              - name: data
   109                mountPath: /data
   110          {{- end }}
   111          {{- if $.Values.storegateway.initContainers }}
   112          {{- include "common.tplvalues.render" (dict "value" $.Values.storegateway.initContainers "context" $) | nindent 8 }}
   113          {{- end }}
   114        {{- end }}
   115        containers:
   116          {{- if $.Values.storegateway.sidecars }}
   117          {{- include "common.tplvalues.render" (dict "value" $.Values.storegateway.sidecars "context" $) | nindent 8 }}
   118          {{- end }}
   119          - name: storegateway
   120            image: {{ include "thanos.image" $ }}
   121            imagePullPolicy: {{ $.Values.image.pullPolicy | quote }}
   122            {{- if $.Values.storegateway.containerSecurityContext.enabled }}
   123            securityContext: {{- omit $.Values.storegateway.containerSecurityContext "enabled" | toYaml | nindent 12 }}
   124            {{- end }}
   125            {{- if $.Values.storegateway.command }}
   126            command: {{- include "common.tplvalues.render" (dict "value" $.Values.storegateway.command "context" $) | nindent 12 }}
   127            {{- end }}
   128            args:
   129              {{- if $.Values.storegateway.args }}
   130              {{- include "common.tplvalues.render" (dict "value" $.Values.storegateway.args "context" $) | nindent 12 }}
   131              {{- else }}
   132              - store
   133              - --log.level={{ $.Values.storegateway.logLevel }}
   134              - --log.format={{ $.Values.storegateway.logFormat }}
   135              - --grpc-address=0.0.0.0:10901
   136              - --http-address=0.0.0.0:10902
   137              - --data-dir=/data
   138              - --objstore.config-file=/conf/objstore.yml
   139              {{- if (include "thanos.httpConfigEnabled" $) }}
   140              - --http.config=/conf/http/http-config.yml
   141              {{- end }}
   142              {{- if $.Values.indexCacheConfig }}
   143              - --index-cache.config-file=/conf/index-cache.yml
   144              {{- end }}
   145              {{- if $.Values.bucketCacheConfig }}
   146              - --store.caching-bucket.config-file=/conf/bucket-cache.yml
   147              {{- end }}
   148              {{- if or $.Values.storegateway.config $.Values.storegateway.existingConfigmap }}
   149              - --index-cache.config-file=/conf/cache/config.yml
   150              {{- end }}
   151              {{- if $.Values.storegateway.grpc.server.tls.enabled }}
   152              - --grpc-server-tls-cert=/certs/{{ include "common.secrets.key" (dict "existingSecret" $.Values.storegateway.grpc.server.tls.existingSecret "key" "tls-cert") }}
   153              - --grpc-server-tls-key=/certs/{{ include "common.secrets.key" (dict "existingSecret" $.Values.storegateway.grpc.server.tls.existingSecret "key" "tls-key") }}
   154              - --grpc-server-tls-client-ca=/certs/{{ include "common.secrets.key" (dict "existingSecret" $.Values.storegateway.grpc.server.tls.existingSecret "key" "ca-cert") }}
   155              {{- end }}
   156              {{- if $hashPartitioning }}
   157              - |
   158                --selector.relabel-config=
   159                  - action: hashmod
   160                    source_labels: ["__block_id"]
   161                    target_label: shard
   162                    modulus: {{ $shards }}
   163                  - action: keep
   164                    source_labels: ["shard"]
   165                    regex: {{ $index }}
   166              {{- end }}
   167              {{- if $timePartitioning }}
   168              {{- $partion := (slice $.Values.storegateway.sharded.timePartitioning  $index) | first }}
   169              {{- if $partion.max }}
   170              - --max-time={{ $partion.max }}
   171              {{- end }}
   172              {{- if $partion.min }}
   173              - --min-time={{ $partion.min }}
   174              {{- end }}
   175              {{- end }}
   176              {{- if $.Values.storegateway.extraFlags }}
   177              {{- $.Values.storegateway.extraFlags | toYaml | nindent 12 }}
   178              {{- end }}
   179              {{- end }}
   180            {{- if $.Values.storegateway.extraEnvVars }}
   181            env: {{- include "common.tplvalues.render" (dict "value" $.Values.storegateway.extraEnvVars "context" $) | nindent 12 }}
   182            {{- end }}
   183            {{- if or $.Values.storegateway.extraEnvVarsCM $.Values.storegateway.extraEnvVarsSecret }}
   184            envFrom:
   185              {{- if $.Values.storegateway.extraEnvVarsCM }}
   186              - configMapRef:
   187                  name: {{ include "common.tplvalues.render" (dict "value" $.Values.storegateway.extraEnvVarsCM "context" $) }}
   188              {{- end }}
   189              {{- if $.Values.storegateway.extraEnvVarsSecret }}
   190              - secretRef:
   191                  name: {{ include "common.tplvalues.render" (dict "value" $.Values.storegateway.extraEnvVarsSecret "context" $) }}
   192              {{- end }}
   193            {{- end }}
   194            ports:
   195              - name: http
   196                containerPort: 10902
   197                protocol: TCP
   198              - name: grpc
   199                containerPort: 10901
   200                protocol: TCP
   201            {{- if $.Values.storegateway.customLivenessProbe }}
   202            livenessProbe: {{- include "common.tplvalues.render" (dict "value" $.Values.storegateway.customLivenessProbe "context" $) | nindent 12 }}
   203            {{- else if $.Values.storegateway.livenessProbe.enabled }}
   204            livenessProbe: {{- include "common.tplvalues.render" (dict "value" (omit $.Values.storegateway.livenessProbe "enabled") "context" $) | nindent 12 }}
   205              {{- if not $.Values.auth.basicAuthUsers }}
   206              httpGet:
   207                path: /-/healthy
   208                port: http
   209                scheme: {{ ternary "HTTPS" "HTTP" $.Values.https.enabled }}
   210              {{- else }}
   211              tcpSocket:
   212                port: http
   213              {{- end }}
   214            {{- end }}
   215            {{- if $.Values.storegateway.customReadinessProbe }}
   216            readinessProbe: {{- include "common.tplvalues.render" (dict "value" $.Values.storegateway.customReadinessProbe "context" $) | nindent 12 }}
   217            {{- else if $.Values.storegateway.readinessProbe.enabled }}
   218            readinessProbe: {{- include "common.tplvalues.render" (dict "value" (omit $.Values.storegateway.readinessProbe "enabled") "context" $) | nindent 12 }}
   219              {{- if not $.Values.auth.basicAuthUsers }}
   220              httpGet:
   221                path: /-/ready
   222                port: http
   223                scheme: {{ ternary "HTTPS" "HTTP" $.Values.https.enabled }}
   224              {{- else }}
   225              tcpSocket:
   226                port: http
   227              {{- end }}
   228            {{- end }}
   229            {{- if $.Values.storegateway.customReadinessProbe }}
   230            startupProbe: {{- include "common.tplvalues.render" (dict "value" $.Values.storegateway.customStartupProbe "context" $) | nindent 12 }}
   231            {{- else if $.Values.storegateway.startupProbe.enabled }}
   232            startupProbe: {{- include "common.tplvalues.render" (dict "value" (omit $.Values.storegateway.startupProbe "enabled") "context" $) | nindent 12 }}
   233              {{- if not $.Values.auth.basicAuthUsers }}
   234              httpGet:
   235                path: /-/ready
   236                port: http
   237                scheme: {{ ternary "HTTPS" "HTTP" $.Values.https.enabled }}
   238              {{- else }}
   239              tcpSocket:
   240                port: http
   241              {{- end }}
   242            {{- end }}
   243            {{- if $.Values.storegateway.lifecycleHooks }}
   244            lifecycle: {{- include "common.tplvalues.render" (dict "value" $.Values.storegateway.lifecycleHooks "context" $) | nindent 12 }}
   245            {{- end }}
   246            {{- if $timePartitioning }}
   247            {{- $partion := (slice $.Values.storegateway.sharded.timePartitioning  $index) | first }}
   248            {{- if $partion.resources }}
   249            resources: {{- toYaml $partion.resources | nindent 12 }}
   250            {{- else }}
   251            resources: {{- toYaml $.Values.storegateway.resources | nindent 12 }}
   252            {{- end }}
   253            {{- else }}
   254            resources: {{- toYaml $.Values.storegateway.resources | nindent 12 }}
   255            {{- end }}
   256            volumeMounts:
   257              - name: objstore-config
   258                mountPath: /conf
   259              {{- if (include "thanos.httpConfigEnabled" $) }}
   260              - name: http-config
   261                mountPath: /conf/http
   262              {{- if $.Values.https.enabled }}
   263              - name: http-certs
   264                mountPath: /certs
   265              {{- end }}
   266              {{- end }}
   267              - name: data
   268                mountPath: /data
   269              {{- if or $.Values.storegateway.config $.Values.storegateway.existingConfigmap }}
   270              - name: cache-config
   271                mountPath: /conf/cache
   272              {{- end }}
   273              {{- if $.Values.storegateway.grpc.server.tls.enabled }}
   274              - name: grpc-server-tls
   275                mountPath: /certs
   276              {{- end }}
   277              {{- if $.Values.storegateway.extraVolumeMounts }}
   278              {{- include "common.tplvalues.render" (dict "value" $.Values.storegateway.extraVolumeMounts "context" $) | nindent 12 }}
   279              {{- end }}
   280        volumes:
   281          - name: objstore-config
   282            secret:
   283              secretName: {{ include "thanos.objstoreSecretName" $ }}
   284              {{- if $.Values.existingObjstoreSecretItems }}
   285              items: {{- toYaml $.Values.existingObjstoreSecretItems | nindent 14 }}
   286              {{- end }}
   287          {{- if (include "thanos.httpConfigEnabled" $) }}
   288          - name: http-config
   289            secret:
   290              secretName: {{ include "thanos.httpConfigSecretName" $ }}
   291          {{- if $.Values.https.enabled }}
   292          - name: http-certs
   293            secret:
   294              secretName: {{ include "thanos.httpCertsSecretName" $ }}
   295          {{- end }}
   296          {{- end }}
   297          {{- if $.Values.storegateway.extraVolumes }}
   298          {{- include "common.tplvalues.render" (dict "value" $.Values.storegateway.extraVolumes "context" $) | nindent 8 }}
   299          {{- end }}
   300          {{- if or $.Values.storegateway.config $.Values.storegateway.existingConfigmap }}
   301          - name: cache-config
   302            configMap:
   303              name: {{ include "thanos.storegateway.configmapName" $ }}
   304          {{- end }}
   305          {{- if $.Values.storegateway.grpc.server.tls.enabled }}
   306          - name: grpc-server-tls
   307            secret:
   308              secretName: {{ include "common.secrets.name" (dict "existingSecret" $.Values.storegateway.grpc.server.tls.existingSecret "defaultNameSuffix" "store-grpc-server" "context" $) }}
   309          {{- end }}
   310    {{- if and $.Values.storegateway.persistence.enabled $.Values.storegateway.persistence.existingClaim }}
   311          - name: data
   312            persistentVolumeClaim:
   313              claimName: {{ $.Values.storegateway.persistence.existingClaim }}
   314    {{- else if not $.Values.storegateway.persistence.enabled }}
   315          - name: data
   316            emptyDir: {}
   317    {{- else if and $.Values.storegateway.persistence.enabled (not $.Values.storegateway.persistence.existingClaim) }}
   318    volumeClaimTemplates:
   319      - metadata:
   320          name: data
   321          {{- if $.Values.storegateway.persistence.labels }}
   322          labels: {{- include "common.tplvalues.render" ( dict "value" $.Values.storegateway.persistence.labels "context" $) | nindent 10 }}
   323          {{- end }}
   324          {{- if $.Values.storegateway.persistence.annotations }}
   325          annotations: {{- include "common.tplvalues.render" ( dict "value" $.Values.storegateway.persistence.annotations "context" $) | nindent 10 }}
   326          {{- end }}
   327        spec:
   328          accessModes:
   329          {{- range $.Values.storegateway.persistence.accessModes }}
   330            - {{ . | quote }}
   331          {{- end }}
   332          resources:
   333            requests:
   334              storage: {{ $.Values.storegateway.persistence.size | quote }}
   335          {{- include "common.storage.class" (dict "persistence" $.Values.storegateway.persistence "global" $.Values.global) | nindent 8 }}
   336    {{- end }}
   337  ---
   338  {{- end }}
   339  {{- end }}