K8s (GKE) 上的元数据库获取就绪探测失败

Metabase on K8s (GKE) get Readiness probe failed

我尝试在我的 GKE 集群上部署 Matabase,但我发现 Readiness probe failed。

我在本地构建并获得 localhost:3000/api/health 我的状态为 200,但在 k8s 上它不起作用。

Docker 文件。我创建自己的推送并构建到我的 GitLab 注册表

FROM metabase/metabase:v0.41.6
EXPOSE 3000
CMD ["/app/run_metabase.sh" ]

我的deployment.yaml

# apiVersion: extensions/v1beta1
kind: Deployment
metadata:
  name: metaba-dev
spec:
  selector:
    matchLabels:
      app: metaba-dev
  replicas: 1
  strategy:
    type: RollingUpdate
    rollingUpdate:
      maxUnavailable: 50%
      maxSurge: 100%
  template:
    metadata:
      labels:
        app: metaba-dev
    spec:
      restartPolicy: Always
      imagePullSecrets:
        - name: gitlab-login
      containers:
        - name: metaba-dev
          image: registry.gitlab.com/team/metabase:dev-{{BUILD_NUMBER}}
          command: ["/app/run_metabase.sh" ]
          livenessProbe:
            httpGet:
              path: /api/health
              port: 3000
            initialDelaySeconds: 60
            periodSeconds: 10
          readinessProbe:
            httpGet:
              path: /api/health
              port: 3000
            initialDelaySeconds: 60
            periodSeconds: 10

          imagePullPolicy: Always
          ports:
            - name: metaba-dev-port
              containerPort: 3000



      terminationGracePeriodSeconds: 90

我从

那里得到了这个错误

kubectl describe pod metaba-dev

  Warning  Unhealthy                61s (x3 over 81s)      kubelet                                Readiness probe failed: Get "http://10.207.128.197:3000/api/health": dial tcp 10.207.128.197:3000: connect: connection refused
  Warning  Unhealthy                61s (x3 over 81s)      kubelet                                Liveness probe failed: Get "http://10.207.128.197:3000/api/health": dial tcp 10.207.128.197:3000: connect: connection refused

kubectl 日志

Picked up JAVA_TOOL_OPTIONS: -Xmx1g -Xms1g -Xmx1g
Warning: environ value jdk-11.0.13+8 for key :java-version has been overwritten with 11.0.13
WARNING: sun.reflect.Reflection.getCallerClass is not supported. This will impact performance.
2022-01-28 15:32:23,966 INFO metabase.util :: Maximum memory available to JVM: 989.9 MB
2022-01-28 15:33:09,703 INFO util.encryption :: Saved credentials encryption is ENABLED for this Metabase instance. 
 For more information, see https://metabase.com/docs/latest/operations-guide/encrypting-database-details-at-rest.html

这里解决

我将 initialDelaySeconds: 添加到 1200 并检查日志记录,这是关于网络 mypod 无法连接到数据库的原因,当我检查日志时我没有看到那个原因我已经重新启动并且它是一个新日志

尝试将 initialDelaySeconds: 60 更改为 100 并且您应该始终在您的容器中设置资源请求和限制以避免探测失败,这是因为当您的应用程序开始达到资源限制时,kubernetes 开始限制您的容器。

containers:


- name: app
    image: images.my-company.example/app:v4
    resources:
      requests:
        memory: "128Mi"
        cpu: "250m"
      limits:
        memory: "100Mi"
        cpu: "500m"