User Tools

Site Tools


система_kubernetes

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
система_kubernetes [2025/03/24 10:22]
val [Deployment, Replica Sets, Pods]
система_kubernetes [2025/03/31 13:51] (current)
val [Metrics Server]
Line 522: Line 522:
 $ ###kubectl run -ti --rm my-debian --image=debian --overrides='​{"​spec":​ { "​nodeSelector":​ {"​kubernetes.io/​hostname":​ "​kube4"​}}}'​ $ ###kubectl run -ti --rm my-debian --image=debian --overrides='​{"​spec":​ { "​nodeSelector":​ {"​kubernetes.io/​hostname":​ "​kube4"​}}}'​
  
-$ kubectl run my-debian --image=debian -- "sh" "-c" "while :;do echo -n msg:;od -A n -t d -N 1 /​dev/​urandom;​sleep 5; done"+$ kubectl run my-debian --image=debian -- "sleep" "60"
  
 $ kubectl get pods $ kubectl get pods
Line 582: Line 582:
         image: debian         image: debian
         command: ["/​bin/​sh"​]         command: ["/​bin/​sh"​]
-        args: ["​-c",​ "​while ​true; do echo hello; sleep 3;​done"​]+        args: ["​-c",​ "​while ​:;do echo -n random-value:;​od -A n -t d -N 1 /​dev/​urandom;​sleep ​5; done"] 
 +        resources:​ 
 +          requests: 
 +            memory: "​64Mi"​ 
 +            cpu: "​250m"​ 
 +          limits: 
 +            memory: "​128Mi"​ 
 +            cpu: "​500m"​
       restartPolicy:​ Always       restartPolicy:​ Always
 </​code><​code>​ </​code><​code>​
 $ kubectl apply -f my-debian-deployment.yaml #​--dry-run=client #-o yaml $ kubectl apply -f my-debian-deployment.yaml #​--dry-run=client #-o yaml
 +
 +$ kubectl logs -l app=my-debian -f
 ... ...
 $ kubectl delete -f my-debian-deployment.yaml $ kubectl delete -f my-debian-deployment.yaml
Line 669: Line 678:
 #            port: 80 #            port: 80
 #            #scheme: HTTPS #            #scheme: HTTPS
- 
-#        resources: 
-#          requests: 
-#            memory: "​64Mi"​ 
-#            cpu: "​250m"​ 
-#          limits: 
-#            memory: "​128Mi"​ 
-#            cpu: "​500m"​ 
- 
  
 #        volumeMounts:​ #        volumeMounts:​
Line 2104: Line 2104:
   * http://​localhost:​8001/​api/​v1/​namespaces/​kubernetes-dashboard/​services/​https:​kubernetes-dashboard:/​proxy/​   * http://​localhost:​8001/​api/​v1/​namespaces/​kubernetes-dashboard/​services/​https:​kubernetes-dashboard:/​proxy/​
  
 +===== Мониторинг =====
 +
 +==== Metrics Server ====
 +
 +  * [[https://​kubernetes-sigs.github.io/​metrics-server/​Kubernetes Metrics Server]]
 +  * [[https://​medium.com/​@cloudspinx/​fix-error-metrics-api-not-available-in-kubernetes-aa10766e1c2f|Fix “error: Metrics API not available” in Kubernetes]]
 +
 +<​code>​
 +kube1:​~/​metrics-server#​ curl -L https://​github.com/​kubernetes-sigs/​metrics-server/​releases/​download/​v0.7.2/​components.yaml | tee metrics-server-components.yaml
 +
 +kube1:​~/​metrics-server#​ cat metrics-server-components.yaml
 +</​code><​code>​
 +...
 +      containers:
 +      - args:
 +        - --cert-dir=/​tmp
 +        - --kubelet-insecure-tls ​  # add this
 +...
 +</​code><​code>​
 +kube1:​~/​metrics-server#​ kubectl apply -f metrics-server-components.yaml
 +
 +kube1# kubectl get pods -A | grep metrics-server
 +
 +kube1# kubectl top pod #-n kube-system
 +
 +kube1# kubectl top pod -A --sort-by=memory
 +
 +kube1# kubectl top node
 +</​code>​
 +
 +==== kube-state-metrics ====
 +
 +  * [[https://​github.com/​prometheus-community/​helm-charts/​tree/​main/​charts/​kube-state-metrics]]
 +
 +<​code>​
 +kube1# helm repo add prometheus-community https://​prometheus-community.github.io/​helm-charts
 +
 +kube1# helm repo update
 +kube1# helm install kube-state-metrics prometheus-community/​kube-state-metrics -n vm --create-namespace
 +
 +kube1# curl kube-state-metrics.vm.svc.cluster.local:​8080/​metrics
 +</​code>​
 ===== Отладка,​ troubleshooting ===== ===== Отладка,​ troubleshooting =====
  
система_kubernetes.1742800941.txt.gz · Last modified: 2025/03/24 10:22 by val