k8s

问题总结

  1. 删除Terminating的namespace
# 使用中替换rook-ceph
kubectl get ns rook-ceph -o json | jq '.spec.finalizers=[]' > ns-without-finalizers.json
cat ns-without-finalizers.json

kubectl proxy &
PID=$!
curl -X PUT http://localhost:8001/api/v1/namespaces/rook-ceph/finalize -H "Content-Type: application/json" --data-binary @ns-without-finalizers.json
kill $PID

参考:https://github.com/kubernetes/kubernetes/issues/77086#issuecomment-486840718

traefik

  1. ingress中使用中间件middleware stripprefix
---
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: test-ingress
  annotations:
    kubernetes.io/ingress.class: traefik
    # 格式{namespace}-{name}@kubernetescrd
    traefik.ingress.kubernetes.io/router.middlewares: ns1-test-strip-prefix@kubernetescrd
spec:
  ingressClassName: traefik
  rules:
    - host: "test.example.com"
      http:
        paths:
          - path: /api/v1/test
            pathType: Prefix
            backend:
              service:
                name: test-server
                port:
                  number: 8080

---
apiVersion: traefik.io/v1alpha1
kind: Middleware
metadata:
  name: test-strip-prefix # {name}
  namespace: ns1 # {namespace}
spec:
  stripPrefix:
    prefixes:
      - /api/v1/test

你可能感兴趣的:(k8s)