OpenKruise请教个问题?

OpenKruise请教个问题?按照这个最佳实践
https://openkruise.io/zh/kruisegame/best-practices/pve-game
创建gs挂载obs,pvc创建存在绑定pv了,桶里文件夹及配置已经创建了。为什么一直pod创建失败报错找不到pvccreate Pod gameserver-0 in StatefulSet gameserver failed error: Pod "gameserver-0" is invalid: spec.containers[0].volumeMounts[0].name: Not found: "gs-cluster-pvc-oss"
373d2e2c5b04e465aa456f525d95b3d6.png
apiVersion: game.kruise.io/v1alpha1
kind: GameServerSet
metadata:
name: gameserver
namespace: kruise-game
spec:
replicas: 5
updateStrategy:
rollingUpdate:
podUpdatePolicy: InPlaceIfPossible
gameServerTemplate:
spec:
containers:

  - image: registry.cn-hangzhou.aliyuncs.com/acs/minecraft-demo:1.12.2
    imagePullPolicy: IfNotPresent
    name: minecraft
    env:
    - name: POD_NAME #把pod name作为环境变量传入
      valueFrom:
        fieldRef:
          apiVersion: v1
          fieldPath: metadata.name
    volumeMounts:
    - name: gs-cluster-pvc-oss #挂载oss对应pvc
      mountPath: "/app/sgame.config" #容器中的目录及文件
      subPathExpr: $(POD_NAME)/sgame.config #对应oss目录及文件
    volumes:
    - name: gs-cluster-pvc-oss
      persistentVolumeClaim:
        claimName: gs-cluster-pvc-oss

这个我创建gs的yaml nm是kruise-game

展开
收起
嘟嘟嘟嘟嘟嘟 2024-02-07 02:24:56 96 分享 版权
2 条回答
写回答
取消 提交回答
  • 应该是缩进的问题。volumes应该是在与containers同级,volumeMounts应该在container里。我们后面修复下文档。此回答整理自钉群“OpenKruise 社区交流群”

    2024-02-08 10:37:01
    赞同 展开评论
  • 根据你提供的 YAML 配置片段,看起来你在尝试通过 OpenKruise 创建一个 GameServerSet,并挂载一个名为 gs-cluster-pvc-oss 的 PersistentVolumeClaim (PVC) 到游戏服务器的容器中。Pod 创建失败并报错 "spec.containers[0].volumeMounts[0].name: Not found: "gs-cluster-pvc-oss" 表明 Kubernetes 无法在 Pod 的 volumes 中找到与 volumeMounts 中引用的同名 PVC。

    以下是可能的原因和解决步骤:

    1. 确保 PVC 已经成功创建并处于 Bound 状态。你可以使用以下命令检查 PVC 的状态:
    kubectl describe pvc -n kruise-game gs-cluster-pvc-oss
    
    1. 确保 PVC 存在并位于正确的命名空间中 (kruise-game),且名字 (claimName) 与 GameServerSet YAML 中的 claimName 相匹配。

    2. 如果 PVC 已经存在且已绑定 PV,还需要检查 PV 是否配置正确,包括存储类、访问模式等是否能满足 Pod 的需求。

    3. 检查 YAML 中 volumes 部分的配置,确保正确设置了 PersistentVolumeClaim 字段。以下是完整的 Volume 示例:

    volumes:
    - name: gs-cluster-pvc-oss
      persistentVolumeClaim:
        claimName: gs-cluster-pvc-oss
    
    1. 确保 YAML 文件格式正确无误,特别是缩进和空格。 YAML 对格式敏感,不正确的格式会导致解析错误。

    如果以上所有步骤都没有问题,那可能是 Kubernetes API 服务器在处理请求时遇到了问题。你可以尝试删除并重新创建 GameServerSet 或 PVC,或者查看更详细的 Pod 事件信息以获取更多错误细节:

    kubectl describe pod gameserver-0 -n kruise-game
    

    根据事件信息来进一步排查问题。

    2024-02-07 17:14:46
    赞同 展开评论

国内唯一 Forrester 公共云容器平台领导者象限。

还有其他疑问?
咨询AI助理