k8s推送代码至gitlab报错error: RPC failed; result=22, HTTP code = 413 fatal: The remote end hung up unexpectedly

# git push -u origin main
Username for 'http://gitlab.wjl.net': root
Password for 'http://root@gitlab.wjl.net': 
Counting objects: 1032, done.
Delta compression using up to 8 threads.
Compressing objects: 100% (871/871), done.
error: RPC failed; result=22, HTTP code = 413
fatal: The remote end hung up unexpectedly
Writing objects: 100% (1032/1032), 48.53 MiB | 11.68 MiB/s, done.
Total 1032 (delta 179), reused 0 (delta 0)
fatal: The remote end hung up unexpectedly
Everything up-to-date

报错

error: RPC failed; result=22, HTTP code = 413
fatal: The remote end hung up unexpectedly

由于gitlab是部署在k8s集群上的,所以gitlab需要通过ingress发布出去,后面的pull,push操作都是经过nginx的

解决方法
修改ingress-nginx的默认http上传文件大小(默认文件大小不能超过1MB),导致上传失败,出现了413问题。

# kubectl exec -it ingress-nginx-controller-rgf4j -n ingress-nginx -- bash
bash-5.1$ 
bash-5.1$ nginx -t
2023/08/19 07:31:22 [warn] 858#858: the "http2_max_field_size" directive is obsolete, use the "large_client_header_buffers" directive instead in /etc/nginx/nginx.conf:144
nginx: [warn] the "http2_max_field_size" directive is obsolete, use the "large_client_header_buffers" directive instead in /etc/nginx/nginx.conf:144
2023/08/19 07:31:22 [warn] 858#858: the "http2_max_header_size" directive is obsolete, use the "large_client_header_buffers" directive instead in /etc/nginx/nginx.conf:145
nginx: [warn] the "http2_max_header_size" directive is obsolete, use the "large_client_header_buffers" directive instead in /etc/nginx/nginx.conf:145
2023/08/19 07:31:22 [warn] 858#858: the "http2_max_requests" directive is obsolete, use the "keepalive_requests" directive instead in /etc/nginx/nginx.conf:146
nginx: [warn] the "http2_max_requests" directive is obsolete, use the "keepalive_requests" directive instead in /etc/nginx/nginx.conf:146
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful
bash-5.1$ 
bash-5.1$ cp /etc/nginx/nginx.conf{,.bak20230819}
bash-5.1$ vi /etc/nginx/nginx.conf
找到如下字段修改为300m
client_max_body_size                    300m;
···
编辑nginx.conf后执行nginx -t检查配置文件
没问题执行nginx -s reload

再次推送

# git push -u origin main
Username for 'http://gitlab.wjl.net': root
Password for 'http://root@gitlab.wjl.net': 
Counting objects: 1032, done.
Delta compression using up to 8 threads.
Compressing objects: 100% (871/871), done.
Writing objects: 100% (1032/1032), 48.53 MiB | 13.02 MiB/s, done.
Total 1032 (delta 180), reused 0 (delta 0)
remote: Resolving deltas: 100% (180/180), done.
To http://gitlab.wjl.net/root/ruo-yi-cloud.git
 * [new branch]      main -> main
分支 main 设置为跟踪来自 origin 的远程分支 main
posted @ 2023-08-19 15:38  Chuyio  阅读(242)  评论(0编辑  收藏  举报