error kubernetes metricserver
#show error
[root@k8s-master kubernetes]# kubectl get pods -n kube-system
NAME READY STATUS RESTARTS AGE
coredns-66bff467f8-glbj5 1/1 Running 0 15d
coredns-66bff467f8-s9zp2 1/1 Running 0 15d
etcd-k8s-master 1/1 Running 0 15d
kube-apiserver-k8s-master 1/1 Running 0 15d
kube-controller-manager-k8s-master 1/1 Running 0 15d
kube-proxy-s7kws 1/1 Running 0 15d
kube-proxy-wd7dj 1/1 Running 0 15d
kube-scheduler-k8s-master 1/1 Running 0 15d
metrics-server-84cf4ddd7f-crd8w 0/1 ImagePullBackOff 0 59m
metrics-server-fb5cb87fd-mdx9m 0/1 CrashLoopBackOff 3997 14d
#fix error
[root@k8s-master kubernetes]# wget https://github.com/kubernetes-sigs/metrics-server/releases/download/v0.3.6/components.yaml
#apply metricserver.yaml
[root@k8s-master kubernetes]# kubectl apply -f ./components.yaml
#show pods
[root@k8s-master kubernetes]# kubectl get pods --all-namespaces
NAMESPACE NAME READY STATUS RESTARTS AGE
default gtomcat 1/1 Running 0 13d
default nginx-f89759699-5vtq5 1/1 Running 0 15d
kube-system coredns-66bff467f8-glbj5 1/1 Running 0 15d
kube-system coredns-66bff467f8-s9zp2 1/1 Running 0 15d
kube-system etcd-k8s-master 1/1 Running 0 15d
kube-system kube-apiserver-k8s-master 1/1 Running 0 15d
kube-system kube-controller-manager-k8s-master 1/1 Running 0 15d
kube-system kube-proxy-s7kws 1/1 Running 0 15d
kube-system kube-proxy-wd7dj 1/1 Running 0 15d
kube-system kube-scheduler-k8s-master 1/1 Running 0 15d
kube-system metrics-server-585dbd8b6c-cb9mp 1/1 Running 0 58s
#whoe error
[root@k8s-master kubernetes]# kubectl get --raw "/apis/metrics.k8s.io/v1beta1/pods"
Error from server (NotFound): the server could not find the requested resource
[root@k8s-master kubernetes]# kubectl get --raw "/apis/metrics.k8s.io/v1beta1/pods"
Error from server (ServiceUnavailable): the server is currently unable to handle the request
[root@k8s-master kubernetes]# kubectl get --raw "/apis/metrics.k8s.io/v1beta1/pods"
{"kind":"PodMetricsList","apiVersion":"metrics.k8s.io/v1beta1","metadata":{"selfLink":"/apis/metrics.k8s.io/v1beta1/pods"},"items":[]}
[root@k8s-master kubernetes]# kubectl top po
W0420 19:09:25.764825 79210 top_pod.go:274] Metrics not available for pod default/gtomcat, age: 319h29m55.764793785s
error: Metrics not available for pod default/gtomcat, age: 319h29m55.764793785s
[root@k8s-master kubernetes]# kubectl get pods -n kube-system -o wide
NAME READY STATUS RESTARTS AGE IP NODE NOMINATED NODE READINESS GATES
coredns-66bff467f8-glbj5 1/1 Running 0 15d 10.244.0.3 k8s-master <none> <none>
coredns-66bff467f8-s9zp2 1/1 Running 0 15d 10.244.0.2 k8s-master <none> <none>
etcd-k8s-master 1/1 Running 0 15d 192.168.0.162 k8s-master <none> <none>
kube-apiserver-k8s-master 1/1 Running 0 15d 192.168.0.162 k8s-master <none> <none>
kube-controller-manager-k8s-master 1/1 Running 0 15d 192.168.0.162 k8s-master <none> <none>
kube-proxy-s7kws 1/1 Running 0 15d 192.168.0.139 k8s-node1 <none> <none>
kube-proxy-wd7dj 1/1 Running 0 15d 192.168.0.162 k8s-master <none> <none>
kube-scheduler-k8s-master 1/1 Running 0 15d 192.168.0.162 k8s-master <none> <none>
metrics-server-67c75d59f8-7dsrv 1/1 Running 0 18s 192.168.0.139 k8s-node1 <none> <none>
[root@k8s-master kubernetes]#
#show pods
I0420 10:09:19.170457 1 serving.go:312] Generated self-signed cert (/tmp/apiserver.crt, /tmp/apiserver.key)
I0420 10:09:21.582240 1 secure_serving.go:116] Serving securely on [::]:4443
E0420 10:09:22.075518 1 reststorage.go:160] unable to fetch pod metrics for pod kube-system/kube-proxy-wd7dj: no metrics known for pod
E0420 10:09:22.075573 1 reststorage.go:160] unable to fetch pod metrics for pod kube-system/kube-proxy-s7kws: no metrics known for pod
E0420 10:09:22.075585 1 reststorage.go:160] unable to fetch pod metrics for pod kube-system/kube-apiserver-k8s-master: no metrics known for pod
E0420 10:09:22.075595 1 reststorage.go:160] unable to fetch pod metrics for pod default/nginx-f89759699-5vtq5: no metrics known for pod
#fix metricserver.yaml
[root@k8s-master kubernetes]# vi components.yaml
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: metrics-server
namespace: kube-system
labels:
k8s-app: metrics-server
spec:
selector:
matchLabels:
k8s-app: metrics-server
template:
metadata:
name: metrics-server
labels:
k8s-app: metrics-server
spec:
hostNetwork: true
serviceAccountName: metrics-server
volumes:
# mount in tmp so we can safely use from-scratch images and/or read-only containers
- name: tmp-dir
emptyDir: {}
containers:
- name: metrics-server
image: k8s.gcr.io/metrics-server-amd64:v0.3.6
imagePullPolicy: IfNotPresent
args:
- --cert-dir=/tmp
- --kubelet-preferred-address-types=InternalIP
- --kubelet-insecure-tls
- --secure-port=4443
ports:
- name: main-port
containerPort: 4443
protocol: TCP
securityContext:
readOnlyRootFilesystem: true
runAsNonRoot: true
runAsUser: 1000
volumeMounts:
- name: tmp-dir
mountPath: /tmp
#test metricserver
[root@k8s-master metricbeat]# kubectl get hpa
NAME REFERENCE TARGETS MINPODS MAXPODS REPLICAS AGE
php-apache Deployment/php-apache 0%/50% 1 10 1 6h9m
[root@k8s-master metricbeat]#
[root@k8s-master metricbeat]#
[root@k8s-master metricbeat]#
[root@k8s-master metricbeat]#
[root@k8s-master metricbeat]# kubectl run --generator=run-pod/v1 -it --rm load-generator --image=busybox /bin/sh
Flag --generator has been deprecated, has no effect and will be removed in the future.
If you don't see a command prompt, try pressing enter.
/ # while true; do wget -q -O- http://php-apache.default.svc.cluster.local; done
OK!OK!OK!OK!OK!OK!OK!OK!OK!OK!OK!OK!OK!OK!OK!OK!OK!OK!OK!OK!OK!OK!OK!OK!OK!OK!OK!OK!OK!OK!OK!OK!OK!OK!OK!OK!OK!OKK!OK!OK!OK!OK!OK!OK!OK!OK!OK!OK!OK!OK!OK!OK!OK!OK!OK!OK!OK!OK!OK!OK!OK!OK!OK!OK!OK!OK!OK!OK!OK!OK!OK!OK!OK!OK!OK!!OK!OK!OK!OK!OK!OK!OK!OK!OK!OK!OK!OK!OK!OK!OK!OK!OK!OK!OK!OK!OK!OK!OK!OK!OK!OK!OK!OK!OK!OK!OK!OK!OK!OK!OK!OK!OK!OOK!OK!OK!OK!OK!OK!OK!OK!OK!OK!OK!OK!OK!OK!OK!OK!OK!OK!OK!OK!OK!OK!OK!OK!OK!OK!OK!OK!OK!OK!OK!OK!OK!OK!OK!OK!^C
/ # Session ended, resume using 'kubectl attach load-generator -c load-generator -i -t' command when the pod is running
pod "load-generator" deleted
[root@k8s-master metricbeat]#
[root@k8s-master metricbeat]# export KUBECONFIG=/etc/kubernetes/admin.conf
[root@k8s-master metricbeat]# kubectl get hpa
NAME REFERENCE TARGETS MINPODS MAXPODS REPLICAS AGE
php-apache Deployment/php-apache 0%/50% 1 10 1 6h10m
[root@k8s-master metricbeat]# kubectl get hpa
NAME REFERENCE TARGETS MINPODS MAXPODS REPLICAS AGE
php-apache Deployment/php-apache 0%/50% 1 10 1 6h10m
[root@k8s-master metricbeat]# kubectl get hpa
NAME REFERENCE TARGETS MINPODS MAXPODS REPLICAS AGE
php-apache Deployment/php-apache 237%/50% 1 10 4 6h10m
[root@k8s-master metricbeat]# kubectl get hpa
NAME REFERENCE TARGETS MINPODS MAXPODS REPLICAS AGE
php-apache Deployment/php-apache 67%/50% 1 10 5 6h11m
[root@k8s-master metricbeat]# kubectl get hpa
NAME REFERENCE TARGETS MINPODS MAXPODS REPLICAS AGE
php-apache Deployment/php-apache 67%/50% 1 10 5 6h12m
[root@k8s-master metricbeat]# kubectl get hpa
NAME REFERENCE TARGETS MINPODS MAXPODS REPLICAS AGE
php-apache Deployment/php-apache 67%/50% 1 10 5 6h12m
[root@k8s-master metricbeat]# kubectl get hpa
NAME REFERENCE TARGETS MINPODS MAXPODS REPLICAS AGE
php-apache Deployment/php-apache 67%/50% 1 10 5 6h12m
[root@k8s-master metricbeat]# kubectl get hpa
NAME REFERENCE TARGETS MINPODS MAXPODS REPLICAS AGE
php-apache Deployment/php-apache 0%/50% 1 10 1 6h22m
[root@k8s-master metricbeat]# kubectl get pods --all-namespaces
NAMESPACE NAME READY STATUS RESTARTS AGE
default gtomcat 1/1 Running 0 13d
default load-generator 1/1 Running 0 31m
default nginx-f89759699-5vtq5 1/1 Running 0 15d
default php-apache-5c4f475bf5-6ch8v 1/1 Running 0 6h41m
kube-system coredns-66bff467f8-glbj5 1/1 Running 0 16d
kube-system coredns-66bff467f8-s9zp2 1/1 Running 0 16d
kube-system etcd-k8s-master 1/1 Running 0 16d
kube-system kube-apiserver-k8s-master 1/1 Running 0 16d
kube-system kube-controller-manager-k8s-master 1/1 Running 0 16d
kube-system kube-proxy-s7kws 1/1 Running 0 16d
kube-system kube-proxy-wd7dj 1/1 Running 0 16d
kube-system kube-scheduler-k8s-master 1/1 Running 0 16d
kube-system metricbeat-759cc94485-4p2zs 1/1 Running 0 63m
kube-system metricbeat-8wdvl 1/1 Running 0 63m
kube-system metrics-server-67c75d59f8-7dsrv 1/1 Running 0 4h42m
[root@k8s-master metricbeat]# kubectl get hpa
NAME REFERENCE TARGETS MINPODS MAXPODS REPLICAS AGE
php-apache Deployment/php-apache 0%/50% 1 10 1 7h17m
[root@k8s-master metricbeat]#
댓글
댓글 쓰기