kubectl get nodes
NAME STATUS ROLES AGE VERSION
master NotReady control-plane 10h v1.26.2
node1 NotReady <none> 10h v1.26.2
node2 Ready <none> 8h v1.26.2
wget https://raw.githubusercontent.com/projectcalico/calico/v3.25.0/manifests/tigera-operator.yaml
wget https://raw.githubusercontent.com/projectcalico/calico/v3.25.0/manifests/custom-resources.yaml
kubectl apply -f tigera-operator.yaml
The CustomResourceDefinition "installations.operator.tigera.io" is invalid: metadata.annotations: Too long: must have at most 262144 bytes
metadata:
annotations:
controller-gen.kubebuilder.io/version: v0.3.0
name: installations.operator.tigera.io
对于大多数资源来说,这不是问题,但有些对象超过了 256kb 的限制,例如 kube-prometheus-stack Helm 图表中的 Prometheus CRD,其大小为 500kb。
在 Argo CD 中同步 Prometheus CRD 将运行 kubectl apply 并尝试添加它的 500kb JSON 表示作为注释。这将导致“Too long: must have at most 262144 bytes”错误,因为它超过了 256kb(或 262144 字节)的 Kubernetes 注释大小限制
解决方案是停止使用 Client Side Apply(运行 kubectl apply 时的当前默认设置),而是使用 Server Side Apply,它不会将 last-applied-configuration 注释添加到对象。
Server Side Apply 计划成为未来 Kubernetes 和 Argo CD 版本中的默认应用方法,但现在我们必须明确启用它。
在 Argo CD v2.5 中添加了对服务器端应用的支持,可以通过在应用程序资源的同步选项中设置它来启用:
kubectl apply -f custom-resources.yaml
[root@master calico]# kubectl apply -f custom-resources.yaml
apiserver.operator.tigera.io/default unchanged
error: resource mapping not found for name: "default" namespace: "" from "custom-resources.yaml": no matches for kind "Installation" in version "operator.tigera.io/v1"
参考文档
https://medium.com/pareture/kubectl-install-crd-failed-annotations-too-long-2ebc91b40c7d
https://www.arthurkoziel.com/fixing-argocd-crd-too-long-error/
kubectl create -f tigera-operator.yaml
kubectl create -f custom-resources.yaml
kubectl delete pods <pod> --grace-period=0
kubectl patch pod <pod> -p '{"metadata":{"finalizers":null}}'
kubectl create -f https://raw.githubusercontent.com/projectcalico/calico/v3.25.0/manifests/tigera-operator.yaml
kubectl create -f https://raw.githubusercontent.com/projectcalico/calico/v3.25.0/manifests/custom-resources.yaml
修改custom-resources.yaml
cidr: 10.244.0.0/16
kubectl get pods --all-namespaces
NAMESPACE NAME READY STATUS RESTARTS AGE
tigera-operator tigera-operator-54b47459dd-jdj8c 1/1 Running 0 13m
kubectl get pods -n calico-system
NAME READY STATUS RESTARTS AGE
calico-kube-controllers-6b7b9c649d-7w62w 0/1 ContainerCreating 0 4m16s
calico-node-9c2nw 0/1 Init:1/2 0 4m16s
calico-node-pbshp 0/1 PodInitializing 0 4m16s
calico-typha-7f79b56575-wzmcf 1/1 Running 0 4m16s
csi-node-driver-lt8tp 0/2 ContainerCreating 0 44s
菜鸟的自白