这里汇集了平常学习和工作中遇到的一些小小的疑难杂症

Linux Service

Nginx

xxx.so is not binary compatible in /etc/nginx/nginx.conf
这个通常发生在编译 Nginx 模块后,我们通过 load_module 加载该模块发出的报错,针对这种的解决方案也很简单,加上 --with-compat 即可,例如
./configure --with-http_image_filter_module=dynamic --with-compat

Kubernetes

如何更新 Terminating 状态的命名空间?

但是在某些情况下,调用删除 Namespace 的指令后,Namespace 一直处于 Terminating 状态

查看命名空间详情

$ kubectl get ns -o yaml -n longhorn-system
...
        instances, nodes.longhorn.io has 1 resource instances'
      reason: SomeResourcesRemain
      status: "True"
      type: NamespaceContentRemaining
    - lastTransitionTime: "2022-03-29T01:40:54Z"
      message: 'Some content in the namespace has finalizers remaining: longhorn.io
        in 2 resource instances'
      reason: SomeFinalizersRemain
      status: "True"
      type: NamespaceFinalizersRemaining
    phase: Terminating
kind: List
metadata:
  resourceVersion: ""
  selfLink: ""

查看并删除该命名空间下的资源

$ kubectl api-resources -o name --verbs=list --namespaced | xargs -n 1 kubectl get --show-kind --ignore-not-found -n longhorn-system
NAME                                  STATE      IMAGE                                    REFCOUNT   BUILDDATE   AGE
engineimage.longhorn.io/ei-b907910b   deployed   longhornio/longhorn-engine:master-head   0          25d         16m
NAME                                   READY   ALLOWSCHEDULING   SCHEDULABLE   AGE
node.longhorn.io/debian-gnu-linux-10   True    true              True          16m

$ kubectl delete crd engineimages.longhorn.io
customresourcedefinition.apiextensions.k8s.io "engineimages.longhorn.io" deleted

然而大部分时间中,我们是无法清理掉这些资源的,即使是强制删除(我在清理CRD的时候就卡住了)

$ kubectl delete ns longhorn-system --force --grace-period=0

调用原生接口进行删除

查看 Namespace 定义的 json 配置,编辑json文件并删除掉spec部分。

$ kubectl get ns longhorn-system -o json > ns.json
$ vim ns.json
```json
            "kubernetes.io/metadata.name": "longhorn-system"
        },
        "name": "longhorn-system",
        "resourceVersion": "9604",
        "uid": "18036516-0a03-4a40-8353-ba8e68729fbf"
    },
    "spec": {
        "finalizers": [
            "kubernetes"
        ]
    },
    "status": {
        "conditions": [
            {
                "lastTransitionTime": "2022-03-29T01:40:54Z",
                "message": "All resources successfully discovered",
                "reason": "ResourcesDiscovered",
                "status": "False",
                "type": "NamespaceDeletionDiscoveryFailure"
            },

$ curl  -k -H "Content-Type:application/json" -X PUT --data-binary @ns.json https://127.0.0.1:6443/api/v1/namespaces/longhorn-system/finalize

其他

如果实在都不行,可以尝试删除 Namespace 的 metadata 部分是否存在finalizers字段,如果存在,需要通过如下命令进入命名空间后删除该字段