recherche

Maison  >  Questions et réponses  >  le corps du texte

Erreur de valeur de mappage : impossible d'identifier la source du problème

Ceci est mon mysql-deployment.yaml, j'essaie de le faire fonctionner sur Kubernetes mais j'obtiens l'erreur, j'ai mentionné l'erreur ci-dessous dans mon déploiement.yml

apiVersion: v1
kind: Service
metadata:
  name: mysql
  labels:
    app: mysql
    tier: database
spec:
  ports:
    - port: 3306
      targetPort: 3306
  selector:
    app: mysql
    tier: database
  clusterIP: None
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: mysql-pv-claim
  labels:
    app: mysql
    tier: database
spec:
  accessMode:
    - ReadWriteOnce
  resources:
    requests:
      storage: 1Gi
---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: mysql
  labels:
    app: mysql
    tier: database
spec:
  selector:
    matchLabels:
      app: mysql
      tier: database
  strategy:
    type: Recreate
  template:
    metadata: 
      labels:
        apps: mysql
        tier: database
    spec:
      containers:
      - image: mysql:5.7
        name: mysql
        env:
        - name: MYSQL_ROOT_PASSWORD
          valueFrom:
            secretKeyRef:
              name: db-root-credentials
              key: password
        - name: MYSQL_USER
          valueFrom:
            secretKeyRef::
              name: db-credentials
              key: username
        - name: MYSQL_PASSWORD
          valueFrom:
            secretkeyRef:
              name: db-credentials
              key: password
        - name: MYSQL_DATABASE
          valueFrom:
            configMapKeyRef:
              name: dbbuddyto_mstr_local
              key: name
      ports:
        - containerPort: 3306
          name: mysql
      volumeMounts:
          - name: mysql-persistent-storage
            mountPath: /var/lib/mysql
      volumes:
          - name: mysql-persistent-storage
            PersistentVolumeClaim:
              claimName: mysql-pv-claim

J'obtiens deux erreurs : 解析 mysql-deployment.yml 时出错:将 YAML 转换为 JSON 时出错:yaml:第 24 行:此上下文中不允许映射值

La deuxième erreur est

来自服务器的错误(BadRequest):创建“mysql-deployment.yml”时出错:版本“v1”中的 PersistentVolumeClaim 无法作为 PersistentVolumeClaim 处理:严格解码错误:未知字段“spec.accessMode”

J'essaie de créer un déploiement Kubernetes pour Angular, Spring et MySQL. L'erreur ci-dessus est celle à laquelle je suis actuellement confronté.

P粉828463673P粉828463673333 Il y a quelques jours504

répondre à tous(1)je répondrai

  • P粉748218846

    P粉7482188462024-01-01 13:48:22

    Votre question PVC est une faute de frappe. Il faut que ce soit spec.accessModes, tu as raté le s à la fin.

    apiVersion: v1
    kind: PersistentVolumeClaim
    metadata:
      name: mysql-pv-claim
      labels:
        app: mysql
        tier: database
    spec:
      accessModes:
        - ReadWriteOnce
      resources:
        requests:
          storage: 1Gi
    

    Éditeur :

    apiVersion: v1
    kind: Service
    metadata:
      name: mysql
      labels:
        app: mysql
        tier: database
    spec:
      ports:
        - port: 3306
          targetPort: 3306
      selector:
        app: mysql
        tier: database
      clusterIP: None
    ---
    apiVersion: v1
    kind: PersistentVolumeClaim
    metadata:
      name: mysql-pv-claim
      labels:
        app: mysql
        tier: database
    spec:
      accessModes:
        - ReadWriteOnce
      resources:
        requests:
          storage: 1Gi
    ---
    apiVersion: apps/v1
    kind: Deployment
    metadata:
      name: mysql
      labels:
        app: mysql
        tier: database
    spec:
      selector:
        matchLabels:
          app: mysql
          tier: database
      strategy:
        type: Recreate
      template:
        metadata:
          labels:
            apps: mysql
            tier: database
        spec:
          containers:
            - image: mysql:5.7
              name: mysql
              env:
                - name: MYSQL_ROOT_PASSWORD
                  valueFrom:
                    secretKeyRef:
                      name: db-root-credentials
                      key: password
                - name: MYSQL_USER
                  valueFrom:
                    secretKeyRef:
                      name: db-credentials
                      key: username
                - name: MYSQL_PASSWORD
                  valueFrom:
                    secretKeyRef:
                      name: db-credentials
                      key: password
                - name: MYSQL_DATABASE
                  valueFrom:
                    configMapKeyRef:
                      name: dbbuddyto_mstr_local
                      key: name
              resources: {}
              ports:
                - containerPort: 3306
                  name: mysql
              volumeMounts:
                - name: mysql-persistent-storage
                  mountPath: /var/lib/mysql
          volumes:
            - name: mysql-persistent-storage
              PersistentVolumeClaim:
                claimName: mysql-pv-claim
    
    

    répondre
    0
  • Annulerrépondre