无效的对象存储密钥内容:S3端点URL的协议不受支持:minio.minio.svc.cluster.local

前端开发 2026-07-09

我在使用 Openshift

我想把 Lokiminio 搭配使用。

Minio已经安装在 minio 命名空间中,且有一个名为 loki. 的桶。对外暴露的服务名为 minio。可以通过以下命令从任意Pod进行ping:

 curl minio.minio.svc.cluster.local:9000

我已在 openshift-logging 命名空间中安装了Loki Operator。

它有一个secret,里面包含下面的YAML,用来获取minio。

apiVersion: v1
kind: Secret
metadata:
  name: loki-s3
  namespace: openshift-logging
type: Opaque
stringData:
  # MinIO credentials
  access_key_id: minio
  access_key_secret: minio123
  bucketnames: loki
  endpoint: http://minio.minio.svc.cluster.local:9000

Loki堆栈有如下YAML。目前处于降级状态。

apiVersion: loki.grafana.com/v1
kind: LokiStack
metadata:
  annotations:
    kubectl.kubernetes.io/last-applied-configuration: |
      {"apiVersion":"loki.grafana.com/v1","kind":"LokiStack","metadata":{"annotations":{},"name":"logging-loki","namespace":"openshift-logging"},"spec":{"managementState":"Managed","size":"1x.small","storage":{"schemas":[{"effectiveDate":"2024-01-01","version":"v13"}],"secret":{"name":"loki-s3","type":"s3"}},"storageClassName":"odf-localblock-immediate","tenants":{"mode":"openshift-logging"}}}
    loki.grafana.com/rulesDiscoveredAt: '2026-04-29T09:39:27Z'
    operator.loki.grafana.com/reconcile: '1777455870'
  creationTimestamp: '2026-04-29T09:35:37Z'
  generation: 1
  managedFields:
    - apiVersion: loki.grafana.com/v1
      fieldsType: FieldsV1
      fieldsV1:
        'f:spec':
          .: {}
          'f:limits': {}
          'f:managementState': {}
          'f:size': {}
          'f:storage':
            .: {}
            'f:schemas': {}
            'f:secret':
              .: {}
              'f:name': {}
              'f:type': {}
          'f:storageClassName': {}
          'f:template': {}
          'f:tenants':
            .: {}
            'f:mode': {}
      manager: Mozilla
      operation: Update
      time: '2026-04-29T09:35:37Z'
    - apiVersion: loki.grafana.com/v1
      fieldsType: FieldsV1
      fieldsV1:
        'f:metadata':
          'f:annotations':
            .: {}
            'f:kubectl.kubernetes.io/last-applied-configuration': {}
      manager: kubectl-client-side-apply
      operation: Update
      time: '2026-04-29T09:37:12Z'
    - apiVersion: loki.grafana.com/v1
      fieldsType: FieldsV1
      fieldsV1:
        'f:metadata':
          'f:annotations':
            'f:loki.grafana.com/rulesDiscoveredAt': {}
      manager: manager
      operation: Update
      time: '2026-04-29T09:39:27Z'
    - apiVersion: loki.grafana.com/v1
      fieldsType: FieldsV1
      fieldsV1:
        'f:metadata':
          'f:annotations':
            'f:operator.loki.grafana.com/reconcile': {}
      manager: kubectl-annotate
      operation: Update
      time: '2026-04-29T09:44:32Z'
    - apiVersion: loki.grafana.com/v1
      fieldsType: FieldsV1
      fieldsV1:
        'f:status':
          .: {}
          'f:components':
            'f:ruler':
              .: {}
              'f:Failed': {}
              'f:Pending': {}
              'f:Ready': {}
              'f:Running': {}
            'f:ingester':
              .: {}
              'f:Pending': {}
            'f:queryFrontend':
              .: {}
              'f:Pending': {}
              'f:Ready': {}
            'f:indexGateway':
              .: {}
              'f:Pending': {}
            .: {}
            'f:gateway':
              .: {}
              'f:Ready': {}
            'f:querier':
              .: {}
              'f:Pending': {}
              'f:Ready': {}
            'f:compactor':
              .: {}
              'f:Pending': {}
            'f:distributor':
              .: {}
              'f:Pending': {}
              'f:Ready': {}
          'f:conditions': {}
          'f:networkPolicyRuleSet': {}
          'f:storage':
            .: {}
            'f:credentialMode': {}
            'f:schemas': {}
      manager: manager
      operation: Update
      subresource: status
      time: '2026-04-29T09:47:11Z'
  name: logging-loki
  namespace: openshift-logging
  resourceVersion: '11637898'
  uid: dbcf306d-2067-42af-9150-5bfe8f7c9e7b
spec:
  limits: {}
  managementState: Managed
  size: 1x.small
  storage:
    schemas:
      - effectiveDate: '2024-01-01'
        version: v13
    secret:
      name: loki-s3
      type: s3
  storageClassName: odf-localblock-immediate
  template: {}
  tenants:
    mode: openshift-logging
status:
  components:
    compactor:
      Pending:
        - logging-loki-compactor-0
    distributor:
      Pending:
        - logging-loki-distributor-5b659dfdc6-5wb8w
      Ready:
        - logging-loki-distributor-8c47d5c7c-7v89m
        - logging-loki-distributor-8c47d5c7c-hrfq4
    gateway:
      Ready:
        - logging-loki-gateway-688db8c5d9-zrc4j
        - logging-loki-gateway-688db8c5d9-84d9s
    indexGateway:
      Pending:
        - logging-loki-index-gateway-0
    ingester:
      Pending:
        - logging-loki-ingester-0
    querier:
      Pending:
        - logging-loki-querier-7ff79586d5-wkt8g
      Ready:
        - logging-loki-querier-d75fc956d-b8w6z
        - logging-loki-querier-d75fc956d-627r7
    queryFrontend:
      Pending:
        - logging-loki-query-frontend-5b557d95d5-7bnrg
        - logging-loki-query-frontend-765cf958dd-mrkwp
      Ready:
        - logging-loki-query-frontend-765cf958dd-n9j6l
    ruler:
      Failed: []
      Pending: []
      Ready: []
      Running: []
  conditions:
    - lastTransitionTime: '2026-04-29T09:47:11Z'
      message: The ingester replicas (2) are less than or equal to the replication factor (2). Which causes log ingestion to stop when ingester pods get restarted.
      reason: InsufficientIngesterReplicas
      status: 'True'
      type: Warning
    - lastTransitionTime: '2026-04-29T09:47:11Z'
      message: One or more LokiStack components pending on dependencies
      reason: PendingComponents
      status: 'True'
      type: Pending
    - lastTransitionTime: '2026-04-29T09:47:10Z'
      message: Missing object storage secret
      reason: MissingObjectStorageSecret
      status: 'False'
      type: Degraded
    - lastTransitionTime: '2026-04-29T09:44:15Z'
      message: 'Invalid object storage secret contents: scheme of S3 endpoint URL is unsupported: minio.minio.svc.cluster.local'
      reason: InvalidObjectStorageSecret
      status: 'False'
      type: Degraded
  networkPolicyRuleSet: None
  storage:
    credentialMode: static
    schemas:
      - effectiveDate: '2024-01-01'
        version: v13

它抛出了如下错误。

'Invalid object storage secret contents: scheme of S3 endpoint URL is unsupported: minio.minio.svc.cluster.local'

解决方案

查看Loki-Minio配置 - Configuring the log store 你需要向secret中添加以下内容:

forcepathstyle="true"

引文文档:

AWS端点(以.amazonaws.com结尾的那些)默认使用虚拟主机样式,这相当于将forcepathstyle属性设置为false。相反,非AWS端点使用路径样式,相当于将forcepathstyle属性设置为true。如果你需要在非AWS的 S3服务上使用虚拟主机样式,必须显式将forcepathstyle设置为false。

看看是否有帮助 ;-)

为澄清,看起来你使用了 path-style
在一个 虚拟主机样式(virtual-hosted–style)
http://bucket.s3.amazonaws.com
http://bucket.s3-aws-region.amazonaws.com

在一个 路径样式URL(path-style URL)
http://s3.amazonaws.com/bucket
http://s3-aws-region.amazonaws.com/bucket

备选方案

只需添加以下内容:

forcepathstyle: "true"

最终可用的代码:

apiVersion: v1
kind: Secret
metadata:
  name: loki-s3
  namespace: openshift-logging
type: Opaque
stringData:
  access_key_id: minio
  access_key_secret: minio123
  bucketnames: loki
  endpoint: http://minio.minio.svc.cluster.local:9000
  forcepathstyle: "true"

MinIO使用的是 路径样式S3,而Loki默认为AWS风格。
没有这个标志,即使协议正确,Loki也会拒绝该端点。

站内所有文章版权归属LeftHeroAI导航站,无授权禁止任何主体转载、抄袭、复制内容,亦不得私自架设镜像站点。一经侵权,本站将通过法律途径追责。

相关文章