现象截图

使用kubectl top pods -A |sort -k 4g

ingress-nginx          nginx-ingress-controller-wldp7               6m           102Mi           
test                   php-demo-85f6dd5bc4-pjsl5                    1m           105Mi           
kube-system            etcd-k8s-master-03                           19m          117Mi           
kube-system            etcd-k8s-master-02                           21m          129Mi           
kube-system            etcd-k8s-master-01                           42m          131Mi           
elk                    k8s-logs-rrmpq                               3m           169Mi           
default                db-0                                         1m           187Mi           
kube-system            kube-apiserver-k8s-master-03                 22m          276Mi           
kube-system            kube-apiserver-k8s-master-02                 13m          358Mi           
kube-system            kibana-59655f997b-prwpf                      6m           373Mi           
elk                    kibana-59655f997b-kxrqc                      5m           388Mi           
kube-system            kube-apiserver-k8s-master-01                 44m          410Mi           
ops                    prometheus-5745bbfdb5-krkxv                  3m           451Mi           
elk                    elasticsearch-0                              8m           769Mi           
ingress-nginx          nginx-ingress-controller-qtgjw               2614m        7338Mi     

日志报错

kubectl logs nginx-ingress-controller-qtgjw -n ingress-nginx
W1112 06:01:25.557359       8 queue.go:130] requeuing &ObjectMeta{Name:sync status,GenerateName:,Namespace:,SelfLink:,UID:,ResourceVersion:,Generation:0,CreationTimestamp:0001-01-01 00:00:00 +0000 UTC,DeletionTimestamp:<nil>,DeletionGracePeriodSeconds:nil,Labels:map[string]string{},Annotations:map[string]string{},OwnerReferences:[],Finalizers:[],ClusterName:,Initializers:nil,}, err services "ingress-nginx" not found
W1112 06:01:25.657502       8 queue.go:130] requeuing &ObjectMeta{Name:sync status,GenerateName:,Namespace:,SelfLink:,UID:,ResourceVersion:,Generation:0,CreationTimestamp:0001-01-01 00:00:00 +0000 UTC,DeletionTimestamp:<nil>,DeletionGracePeriodSeconds:nil,Labels:map[string]string{},Annotations:map[string]string{},OwnerReferences:[],Finalizers:[],ClusterName:,Initializers:nil,}, err services "ingress-nginx" not found
W1112 06:01:25.756839       8 queue.go:130] requeuing &ObjectMeta{Name:sync status,GenerateName:,Namespace:,SelfLink:,UID:,ResourceVersion:,Generation:0,CreationTimestamp:0001-01-01 00:00:00 +0000 UTC,DeletionTimestamp:<nil>,DeletionGracePeriodSeconds:nil,Labels:map[string]string{},Annotations:map[string]string{},OwnerReferences:[],Finalizers:[],ClusterName:,Initializers:nil,}, err services "ingress-nginx" not found
W1112 06:01:25.857530       8 queue.go:130] requeuing &ObjectMeta{Name:sync status,GenerateName:,Namespace:,SelfLink:,UID:,ResourceVersion:,Generation:0,CreationTimestamp:0001-01-01 00:00:00 +0000 UTC,DeletionTimestamp:<nil>,DeletionGracePeriodSeconds:nil,Labels:map[string]string{},Annotations:map[string]string{},OwnerReferences:[],Finalizers:[],ClusterName:,Initializers:nil,}, err services "ingress-nginx" not found

解决办法

apiVersion: v1
kind: Service
metadata:
  name: ingress-nginx
  namespace: ingress-nginx
spec:
  type: ClusterIP
  ports:
  - name: http
    port: 80
    targetPort: 80
    protocol: TCP
  - name: https
    port: 443
    targetPort: 443
    protocol: TCP
  selector:
    app: ingress-nginx
kubectl apply -f ingress-service.yaml

最后重启docker和kubelet

systemctl restart docker
systemctl restart kubelet

解决过后消耗截图

[root@k8s-master-01 k8s]# kubectl top pods -n ingress-nginx  |sort -k 4g
NAME                             CPU(cores)   MEMORY(bytes)   
nginx-ingress-controller-qtgjw   5m           130Mi           
nginx-ingress-controller-wldp7   6m           139Mi        

优化结果: cpu 2614---> 6 内存 7338---> 139