无法删除处于错误状态的 perconaxtradbclusters

Unable to delete perconaxtradbclusters which are in errored state

我已经使用 1.3.0 运算符在 kubernetes 上安装了 Percona XtraDB。

使用后想删除命名空间。所以我按照应用它们的顺序删除了它们。 一切都被删除,svc 中什么都看不到,pods 但是有两个资源处于错误状态,无法删除。

~ kubectl get perconaxtradbclusters -n pxc
NAME       ENDPOINT   STATUS   PXC   PROXYSQL   AGE
cluster1              Error    0     0          4h1m
cluster2              Error    0     0          3h34m

我无法同时删除它们,因此我无法创建同名的集群。

当我 运行 删除命令时,它永远卡住了

~ kubectl delete  perconaxtradbclusters -n pxc cluster1
perconaxtradbcluster.pxc.percona.com "cluster1" deleted

命令执行永远不会完成。

对象的yaml

apiVersion: pxc.percona.com/v1
kind: PerconaXtraDBCluster
metadata:
  annotations:
    kubectl.kubernetes.io/last-applied-configuration: |
      {"apiVersion":"pxc.percona.com/v1-3-0","kind":"PerconaXtraDBCluster"}
  creationTimestamp: "2020-04-21T18:06:13Z"
  deletionGracePeriodSeconds: 0
  deletionTimestamp: "2020-04-21T18:38:33Z"
  finalizers:
  - delete-pxc-pods-in-order
  generation: 2
  name: cluster2
  namespace: pxc
  resourceVersion: "5445879"
  selfLink: /apis/pxc.percona.com/v1/namespaces/pxc/perconaxtradbclusters/cluster2
  uid: 8c100840-b7a8-40d1-b976-1f80c469622b
spec:
  allowUnsafeConfigurations: false
  backup:
    image: percona/percona-xtradb-cluster-operator:1.3.0-backup
    schedule:
    - keep: 3
      name: sat-night-backup
      schedule: 0 0 * * 6
      storageName: s3-us-west
    - keep: 5
      name: daily-backup
      schedule: 0 0 * * *
      storageName: fs-pvc
    serviceAccountName: percona-xtradb-cluster-operator
    storages:
      fs-pvc:
        type: filesystem
        volume:
          persistentVolumeClaim:
            accessModes:
            - ReadWriteOnce
            resources:
              requests:
                storage: 6Gi
      s3-us-west:
        s3:
          bucket: S3-BACKUP-BUCKET-NAME-HERE
          credentialsSecret: my-cluster-name-backup-s3
          region: us-west-2
        type: s3
  pmm:
    enabled: false
    image: percona/percona-xtradb-cluster-operator:1.3.0-pmm
    serverHost: monitoring-service
    serverUser: pmm
  proxysql:
    affinity:
      antiAffinityTopologyKey: kubernetes.io/hostname
    enabled: true
    gracePeriod: 30
    image: percona/percona-xtradb-cluster-operator:1.3.0-proxysql
    podDisruptionBudget:
      maxUnavailable: 1
    resources:
      requests:
        cpu: 600m
        memory: 1G
    size: 3
    volumeSpec:
      persistentVolumeClaim:
        resources:
          requests:
            storage: 2Gi
  pxc:
    affinity:
      antiAffinityTopologyKey: kubernetes.io/hostname
    gracePeriod: 600
    image: percona/percona-xtradb-cluster-operator:1.3.0-pxc
    podDisruptionBudget:
      maxUnavailable: 1
    resources:
      requests:
        cpu: 600m
        memory: 4G
    size: 3
    volumeSpec:
      persistentVolumeClaim:
        accessModes:
        - ReadWriteOnce
        resources:
          requests:
            storage: 60Gi
        storageClassName: local-storage
  secretsName: my-cluster-secrets
  sslInternalSecretName: my-cluster-ssl-internal
  sslSecretName: my-cluster-ssl
status:
  conditions:
  - lastTransitionTime: "2020-04-21T18:06:13Z"
    message: 'wrong PXC options: set version: new version: Malformed version: '
    reason: ErrorReconcile
    status: "True"            
    type: Error
  message:
  - 'Error: wrong PXC options: set version: new version: Malformed version: '
  proxysql:
    ready: 0
  pxc:
    ready: 0
  state: Error

我怎样才能摆脱它们

您的 perconaxtradbclusters yaml 示例提到了 pvc 资源,因此您可能必须先删除关联的 pvc,如果您还没有这样做的话。

您能否编辑资源以删除终结器块,然后再次尝试删除它们?

kubectl edit perconaxtradbclusters cluster1 -n pxc

并删除

finalizers: 
- delete-pxc-pods-in-order

如果没有什么可以依赖这些资源,那就是。

编辑:

我通常只会在用尽所有其他可能性并且找不到阻止删除的挂起资源时才使用此方法。我做了一些挖掘。此评论 here 描述了在求助于删除终结器之前要采取的其他步骤。 - 检查 API 服务是否可用 - 找到任何仍然存在的挥之不去的资源并删除它们。