ingress-nginx-controller中的配置是通过什么方式来设置的呢?
没有! configmap.
那要修改access.log和error.log日志的路径,该如何设置?下面一起看下。
1、首先,查看当前ingress-nginx-controller中的日志配置
bash-5.1$ cat nginx.conf | grep access_log
access_log /var/log/nginx/access.log upstreaminfo if=$loggable;
access_log off;
access_log off;
access_log off;
access_log off;
access_log off;
access_log /var/log/nginx/access.log log_stream ;
access_log off;
bash-5.1$ cat nginx.conf | grep error_log
error_log /var/log/nginx/error.log notice;
error_log /var/log/nginx/error.log notice;
bash-5.1$
2、修改configmap
kubectl edit configmap -n ingress-nginx ingress-nginx-controller
增加如下的配置:
access-log-path: /var/log/nginx/nginx_access.log error-log-path: /var/log/nginx/nginx_error.log
保存配置!
3、重启ingress-nginx-controller pod.
kubectl delete pod -n ingress-nginx ingress-nginx-controller-z6bh
重启成功
[root@nccztsjb-node-23 ~]# kubectl get pod -n ingress-nginx NAME READY STATUS RESTARTS AGE ingress-nginx-controller-9zlgs 1/1 Running 0 21s [root@nccztsjb-node-23 ~]#
4、验证配置
[root@nccztsjb-node-23 ~]# kubectl exec -it -n ingress-nginx ingress-nginx-controller-9zlgs -- bash
bash-5.1$ cat nginx.conf | grep access_log
access_log /var/log/nginx/nginx_access.log upstreaminfo if=$loggable;
access_log off;
access_log off;
access_log off;
access_log off;
access_log off;
access_log /var/log/nginx/nginx_access.log log_stream ;
access_log off;
bash-5.1$ cat nginx.conf | grep error_log
error_log /var/log/nginx/nginx_error.log notice;
error_log /var/log/nginx/nginx_error.log notice;
bash-5.1$
名字修改成功!
5、注意!
修改之前,必须保证在镜像中存在对应的目录。否则,爆粗如下:
6、所有ingress-nginx-controller需要的configmap条目
参考如下的链接:
https://kubernetes.github.io/ingress-nginx/user-guide/nginx-configuration/configmap/
name |
type |
default |
string |
"" |
|
bool |
"false" |
|
bool |
true |
|
string array |
"" |
|
string array |
empty |
|
string |
"" |
|
string |
"/var/log/nginx/access.log" |
|
string |
"" |
|
string |
"" |
|
bool |
"false" |
|
string |
"/var/log/nginx/error.log" |
|
bool |
"false" |
|
string |
"" |
|
bool |
"false" |
|
string |
"1k" |
|
int |
60 |
|
string |
"8k" |
|
int |
60 |
|
bool |
false |
|
bool |
false |
|
bool |
false |
|
bool |
false |
|
bool |
false |
|
bool |
true |
|
bool |
"false" |
|
string |
"notice" |
|
string |
"4k" |
|
string |
"16k" |
|
int |
1000 |
|
int |
128 |
|
bool |
"true" |
|
bool |
"true" |
|
string |
"15724800" |
|
bool |
"false" |
|
int |
75 |
|
int |
100 |
|
string |
"4 8k" |
|
bool |
"false" |
|
bool |
"false" |
|
string |
$remote_addr - $remote_user [$time_local] "$request" $status $body_bytes_sent "$http_referer" "$http_user_agent" $request_length $request_time [$proxy_upstream_name] [$proxy_alternative_upstream_name] $upstream_addr $upstream_response_length $upstream_response_time $upstream_status $req_id |
|
string |
[$remote_addr] [$time_local] $protocol $status $bytes_sent $bytes_received $session_time |
|
bool |
"true" |
|
int |
16384 |
|
int |
0 |
|
int |
64 |
|
[]string |
"127.0.0.1" |
|
[]string |
"::1" |
|
[]string |
"0.0.0.0/0" |
|
string |
"" |
|
int |
1024 |
|
int |
<size of the processor’s cache line> |
|
int |
512 |
|
int |
64 |
|
[]string |
||
bool |
"true" |
|
bool |
"false" |
|
string |
"ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384" |
|
string |
"auto" |
|
string |
"" |
|
string |
"TLSv1.2 TLSv1.3" |
|
bool |
"true" |
|
string |
"10m" |
|
bool |
"false" |
|
string |
<Randomly Generated> |
|
string |
"10m" |
|
string |
"4k" |
|
bool |
"false" |
|
string |
"5s" |
|
bool |
"false" |
|
bool |
"true" |
|
bool |
"false" |
|
bool |
"false" |
|
int |
4 |
|
int |
20 |
|
string |
"application/xml+rss application/atom+xml application/javascript application/x-javascript application/json application/rss+xml application/vnd.ms-fontobject application/x-font-ttf application/x-web-app-manifest+json application/xhtml+xml application/xml font/opentype image/svg+xml image/x-icon text/css text/javascript text/plain text/x-component" |
|
bool |
"true" |
|
int |
1 |
|
string |
"application/atom+xml application/javascript application/x-javascript application/json application/rss+xml application/vnd.ms-fontobject application/x-font-ttf application/x-web-app-manifest+json application/xhtml+xml application/xml font/opentype image/svg+xml image/x-icon text/css text/javascript text/plain text/x-component" |
|
string |
<Number of CPUs> |
|
string |
"" |
|
string |
"240s" |
|
string |
"round_robin" |
|
int |
128 |
|
int |
2048 |
|
int |
320 |
|
string |
"1h" |
|
int |
60 |
|
int |
10000 |
|
string |
"$binary_remote_addr" |
|
string |
"600s" |
|
bool |
"true" |
|
string |
"600s" |
|
int |
3 |
|
int |
1 |
|
[]string |
"" |
|
bool |
"false" |
|
bool |
"false" |
|
string |
"X-Forwarded-For" |
|
bool |
"false" |
|
bool |
"false" |
|
bool |
"true" |
|
bool |
"false" |
|
string |
"" |
|
string |
"" |
|
string |
"" |
|
int |
9411 |
|
string |
"nginx" |
|
float |
1.0 |
|
string |
"" |
|
int |
6831 |
|
string |
"" |
|
string |
"nginx" |
|
string |
"jaeger" |
|
string |
"const" |
|
string |
"1" |
|
string |
"http://127.0.0.1" |
|
int |
5778 |
|
string |
uber-trace-id |
|
string |
uber-debug-id |
|
string |
jaeger-baggage |
|
string |
uberctx- |
|
string |
"" |
|
int |
8126 |
|
string |
"nginx" |
|
string |
"prod" |
|
string |
"nginx.handle" |
|
bool |
"true" |
|
float |
1.0 |
|
string |
"" |
|
string |
"" |
|
string |
"" |
|
string |
"" |
|
string |
"" |
|
[]int |
[]int{} |
|
string |
"1m" |
|
int |
5 |
|
int |
60 |
|
int |
60 |
|
int |
4 |
|
string |
"4k" |
|
string |
"off" |
|
string |
"off" |
|
string |
"error timeout" |
|
int |
0 |
|
int |
3 |
|
string |
"off" |
|
string |
"on" |
|
bool |
"true" |
|
bool |
"false" |
|
[]string |
[]string{} |
|
[]string |
[]string{} |
|
int |
0 |
|
int |
0 |
|
string |
"" |
|
int |
308 |
|
string |
"off" |
|
int |
503 |
|
int |
503 |
|
bool |
false |
|
string |
"" |
|
int |
514 |
|
string |
"/.well-known/acme-challenge" |
|
string |
"" |
|
string |
"" |
|
string |
"" |
|
string |
"rd" |
|
string |
"" |
|
string |
"" |
|
string |
"" |
|
string |
"" |
|
string |
"200 202 401 5m" |
|
string |
"/.well-known/acme-challenge" |
|
[]string |
"" |
|
[]string |
"" |
|
[]string |
"" |
|
bool |
"false" |
|
string |
"text/html" |
|
string |
"" |
|
int |
11211 |
|
int |
50 |
|
int |
10000 |
|
int |
50 |
|
int |
429 |
|
bool |
"false" |
|
bool |
"false" |
|
[]string |
"127.0.0.1,1.1.1.1/24" |