一、k8s的node節點磁盤 /data已使用率超過 85% , 出現disk pressure ,驅逐pod現象
evicted , the node had condition:[DiskPressure]
#修改/var/lib/kubelet/config.yaml
]# cat /var/lib/kubelet/config.yaml
apiVersion: kubelet.config.k8s.io/v1beta1
authentication:anonymous:enabled: falsewebhook:cacheTTL: 0senabled: truex509:clientCAFile: /etc/kubernetes/pki/ca.crt
authorization:mode: Webhookwebhook:cacheAuthorizedTTL: 0scacheUnauthorizedTTL: 0s
cgroupDriver: systemd
clusterDNS:
- 10.96.0.10
clusterDomain: cluster.local
cpuManagerReconcilePeriod: 0s
evictionPressureTransitionPeriod: 0s
fileCheckFrequency: 0s
healthzBindAddress: 127.0.0.1
healthzPort: 10248
httpCheckFrequency: 0s
imageMinimumGCAge: 0s
kind: KubeletConfiguration
logging:flushFrequency: 0options:json:infoBufferSize: "0"verbosity: 0
memorySwap: {}
nodeStatusReportFrequency: 0s
nodeStatusUpdateFrequency: 0s
rotateCertificates: true
runtimeRequestTimeout: 0s
shutdownGracePeriod: 0s
shutdownGracePeriodCriticalPods: 0s
staticPodPath: /etc/kubernetes/manifests
streamingConnectionIdleTimeout: 0s
syncFrequency: 0s
volumeStatsAggPeriod: 0s#202506 添加:
evictionHard:imagefs.available: 1%memory.available: 100Minodefs.available: 1%nodefs.inodesFree: 1%#重啟該node節點的 kubelet
systemctl restart kubelet
systemctl status kubelet
#參考文章:
https://blog.csdn.net/qq_59634082/article/details/136868417 《k8s資源不足時驅趕pod閾值調整》
https://stackoverflow.com/questions/54155534/kubernetes-eviction-manager-evicting-control-plane-pods-to-reclaim-ephemeral-sto/60068671#60068671
https://devpress.csdn.net/k8s/62ffc7fac67703293080625f.html 《Kubernetes 驅逐管理器驅逐控制平面 pod 以回收臨時存儲》
END
二、刪除ES索引和其數據。
k8s上部署3個ES節點 , 版本elasticsearch:7.6.0 。 刪除索引名稱帶202407的索引。kubectl exec -it es-new-0 -n test bash
#查看索引名稱
curl -s "http://192.168.1.100:9200/_cat/indices?h=index" | grep -i "202407"
#刪除索引 【三個ES節點的IP 都要執行】
curl -X DELETE "http://192.168.1.100:9200/api_xxx_202407*"
curl -X DELETE "http://192.168.1.101:9200/api_xxx_202407*"
curl -X DELETE "http://192.168.1.102:9200/api_xxx_202407*"###查看占用容量 , 單位MB
curl "http://192.168.1.100:9200/_cat/allocation?v&bytes=gb"
curl "http://192.168.1.100:9200/_cat/indices/api_xxx_202407*?v&h=index,store.size,pri.store.size,status&bytes=mb&s=store.size:desc"
參考文章:
https://blog.csdn.net/weixin_44711737/article/details/125833601 《ES索引清理腳本-總結》 (清理腳本:ES有密碼,索引按(周、日)時間命名的清理腳本)
END
三、nginx設置反向代理到mysql服務
#環境信息:
192.168.1.100 ,端口 33306,nginx反代
192.168.1.101 ,端口 3306 ,mysql服務#具體配置:
root@7zbkt:/etc/nginx# cat nginx.conf
user nginx;
worker_processes 1;
error_log /var/log/nginx/error.log warn;
pid /var/run/nginx.pid;
events {worker_connections 1024;
}
stream {# mysql生產環境upstream mysqlprod {server 192.168.1.101:3306 weight=5 max_fails=3 fail_timeout=30s;}server {listen 33306; # 數據庫服務器監聽端口proxy_pass mysqlprod;proxy_timeout 30000s; # 設置客戶端和代理服務之間的超時時間,如果5分鐘內沒有操作將自動斷開proxy_connect_timeout 10s;}
}
http {include /etc/nginx/mime.types;default_type application/octet-stream;log_format main '$remote_addr - $remote_user [$time_local] "$request" ''$status $body_bytes_sent "$http_referer" ''"$http_user_agent" "$http_x_forwarded_for"';access_log /var/log/nginx/access.log main;sendfile on; # 開啟高效文件傳輸模式tcp_nopush on; # 防止網絡阻塞tcp_nodelay on; # 防止網絡阻塞server_tokens off; # 屏蔽nginx版本號keepalive_timeout 120; # 用于設置客戶端連接保持活動的超時時間,在超過這個時間之后服務器會關閉該鏈接。client_header_buffer_size 16k; # 用于指定來自客戶端請求頭headerbuffer大小large_client_header_buffers 4 128k; # 用來指定客戶端請求中較大的消息頭的緩存最大數量和大小server_names_hash_bucket_size 128; # 服務器名字的hash表大小proxy_headers_hash_max_size 51200; # 設置頭部哈希表的最大值proxy_headers_hash_bucket_size 6400; # 設置頭部哈希表大小client_body_buffer_size 256k; # 緩沖區代理緩沖用戶端請求的最大字節數# header安全配置add_header X-Frame-Options "SAMEORIGIN";add_header X-XSS-Protection "1; mode=block";add_header X-Content-Type-Options "nosniff";add_header Content-Security-Policy "frame-ancestors 'self'; object-src 'none'";add_header Strict-Transport-Security "max-age=31536000;includeSubDomains";send_timeout 3m; # 服務器超時設置gzip on; # 開啟gzip壓縮輸出gzip_vary on;gzip_proxied any;gzip_comp_level 6;gzip_buffers 4 16k; # 表示申請4個單位為16k的內存作為壓縮結果流緩存,默認值是申請與原始數據大小相同的內存空間來存儲gzip壓縮結果gzip_http_version 1.1;gzip_min_length 1k; # 用于設置允許壓縮的頁面最小字節數gzip_types text/plain text/css application/json application/javascript application/x-javascript text/xml application/xml application/xml+rss text/javascript application/vnd.ms-fontobject application/x-font-ttf font/opentype image/svg+xml image/x-icon;include /etc/nginx/conf.d/*.conf;
}
此時navicat通過訪問192.168.1.100 ,端口 33306 ,就能訪問內部192.168.1.101的mysql服務。