48

我无法删除自定义资源定义。我正在尝试将 kubeless 从 v1.0.0-alpha.7 升级到v1.0.0-alpha.8

我试图通过执行删除所有创建的自定义资源

$ kubectl delete -f kubeless-v1.0.0-alpha.7.yaml
deployment "kubeless-controller-manager" deleted
serviceaccount "controller-acct" deleted
clusterrole "kubeless-controller-deployer" deleted
clusterrolebinding "kubeless-controller-deployer" deleted
customresourcedefinition "functions.kubeless.io" deleted
customresourcedefinition "httptriggers.kubeless.io" deleted
customresourcedefinition "cronjobtriggers.kubeless.io" deleted
configmap "kubeless-config" deleted

但是当我尝试时,

$ kubectl get customresourcedefinition
NAME                    AGE
functions.kubeless.io   21d

因此,当我下次尝试通过做升级时,我看到,

$ kubectl create -f kubeless-v1.0.0-alpha.8.yaml
Error from server (AlreadyExists): error when creating "kubeless-v1.0.0-alpha.8.yaml": object is being deleted: customresourcedefinitions.apiextensions.k8s.io "functions.kubeless.io" already exists

我认为由于函数定义中的这种不匹配,hello world 示例失败了。

$ kubeless function deploy hellopy --runtime python2.7 --from-file test.py --handler test.hello
INFO[0000] Deploying function...
FATA[0000] Failed to deploy hellopy. Received:
the server does not allow this method on the requested resource (post functions.kubeless.io)

最后,这是输出,

$ kubectl describe customresourcedefinitions.apiextensions.k8s.io
Name:         functions.kubeless.io
Namespace:
Labels:       <none>
Annotations:  kubectl.kubernetes.io/last-applied-configuration={"apiVersion":"apiextensions.k8s.io/v1beta1","description":"Kubernetes Native Serverless Framework","kind":"CustomResourceDefinition","metadata":{"anno...
API Version:  apiextensions.k8s.io/v1beta1
Kind:         CustomResourceDefinition
Metadata:
  Creation Timestamp:             2018-08-02T17:22:07Z
  Deletion Grace Period Seconds:  0
  Deletion Timestamp:             2018-08-24T17:15:39Z
  Finalizers:
    customresourcecleanup.apiextensions.k8s.io
  Generation:        1
  Resource Version:  99792247
  Self Link:         /apis/apiextensions.k8s.io/v1beta1/customresourcedefinitions/functions.kubeless.io
  UID:               951713a6-9678-11e8-bd68-0a34b6111990
Spec:
  Group:  kubeless.io
  Names:
    Kind:       Function
    List Kind:  FunctionList
    Plural:     functions
    Singular:   function
  Scope:        Namespaced
  Version:      v1beta1
Status:
  Accepted Names:
    Kind:       Function
    List Kind:  FunctionList
    Plural:     functions
    Singular:   function
  Conditions:
    Last Transition Time:  2018-08-02T17:22:07Z
    Message:               no conflicts found
    Reason:                NoConflicts
    Status:                True
    Type:                  NamesAccepted
    Last Transition Time:  2018-08-02T17:22:07Z
    Message:               the initial names have been accepted
    Reason:                InitialNamesAccepted
    Status:                True
    Type:                  Established
    Last Transition Time:  2018-08-23T13:29:45Z
    Message:               CustomResource deletion is in progress
    Reason:                InstanceDeletionInProgress
    Status:                True
    Type:                  Terminating
Events:                    <none>
4

5 回答 5

91

事实证明,根本原因是带有终结器的自定义资源可能会“死锁”。CustomResource“functions.kubeless.io”有一个

Finalizers: customresourcecleanup.apiextensions.k8s.io

这可能会在删除时使其处于不良状态。

https://github.com/kubernetes/kubernetes/issues/60538

我按照此解决方法中提到的步骤进行操作,现在它已被删除。希望这对遇到此问题的其他人有所帮助。

于 2018-08-24T22:17:46.640 回答
19
$ kc get crd

NAME                                                            CREATED AT
accesscontrolpolicies.networking.zephyr.solo.io                 2020-04-22T12:58:39Z
istiooperators.install.istio.io                                 2020-04-22T13:49:20Z
kubernetesclusters.discovery.zephyr.solo.io                     2020-04-22T12:58:39Z
meshes.discovery.zephyr.solo.io                                 2020-04-22T12:58:39Z
meshservices.discovery.zephyr.solo.io                           2020-04-22T12:58:39Z
meshworkloads.discovery.zephyr.solo.io                          2020-04-22T12:58:39Z
trafficpolicies.networking.zephyr.solo.io                       2020-04-22T12:58:39Z
virtualmeshcertificatesigningrequests.security.zephyr.solo.io   2020-04-22T12:58:39Z
virtualmeshes.networking.zephyr.solo.io                         2020-04-22T12:58:39Z
$ kubectl delete crd istiooperators.install.istio.io

delete error

$ kubectl patch crd/istiooperators.install.istio.io -p '{"metadata":{"finalizers":[]}}' --type=merge
success delete crd istiooperators.install.istio.io

结果

NAME                                                            CREATED AT
accesscontrolpolicies.networking.zephyr.solo.io                 2020-04-22T12:58:39Z
kubernetesclusters.discovery.zephyr.solo.io                     2020-04-22T12:58:39Z
meshes.discovery.zephyr.solo.io                                 2020-04-22T12:58:39Z
meshservices.discovery.zephyr.solo.io                           2020-04-22T12:58:39Z
meshworkloads.discovery.zephyr.solo.io                          2020-04-22T12:58:39Z
trafficpolicies.networking.zephyr.solo.io                       2020-04-22T12:58:39Z
virtualmeshcertificatesigningrequests.security.zephyr.solo.io   2020-04-22T12:58:39Z
virtualmeshes.networking.zephyr.solo.io                         2020-04-22T12:58:39Z
于 2020-04-23T07:52:41.440 回答
6

尝试:

oc patch some.crd/crd_name -p '{"metadata":{"finalizers":[]}}' --type=merge

在尝试强制删除卡住后解决了我的问题。

于 2021-03-02T11:11:25.797 回答
3

我不得不摆脱一些其他的东西

kubectl get mutatingwebhookconfiguration | ack consul | awk '{print $1}' | xargs -I {} kubectl delete mutatingwebhookconfiguration {}

kubectl get clusterrolebinding | ack consul | awk '{print $1}' | xargs -I {} kubectl delete clusterrolebinding {}

kubectl get clusterrolebinding | ack consul | awk '{print $1}' | xargs -I {} kubectl delete clusterrole {}

于 2021-05-27T16:34:52.997 回答
1

就我而言,这是一个问题,我删除了自定义资源对象,但没有删除自定义资源定义 (CRD)。

我用:kubectl delete -f resourcedefinition.yaml. 在那个文件中,我定义了我的 CRD。

所以我认为最好不要手动删除自定义对象,而是删除定义对象和 CRD 的文件。参考

于 2019-01-28T10:39:02.140 回答