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/21 06:13]
val [Ingress]
система_kubernetes [2025/03/31 13:51] (current)
val [Metrics Server]
Line 25: Line 25:
  
   * [[https://​kubernetes.io/​docs/​reference/​generated/​kubectl/​kubectl-commands]]   * [[https://​kubernetes.io/​docs/​reference/​generated/​kubectl/​kubectl-commands]]
 +  * [[https://​kubernetes.io/​ru/​docs/​reference/​kubectl/​cheatsheet/​|Шпаргалка по kubectl]]
  
 ==== Установка ==== ==== Установка ====
Line 457: Line 458:
 ~/​kubespray#​ cat inventory/​mycluster/​hosts.yaml ~/​kubespray#​ cat inventory/​mycluster/​hosts.yaml
 </​code><​code>​ </​code><​code>​
 +all:
 +  hosts:
 ... ...
-    ​node4: +    ​kube4:
-      ansible_host:​ 192.168.X.204 +
-      ip: 192.168.X.204 +
-      access_ip: 192.168.X.204+
 ... ...
     kube_node:     kube_node:
 +      hosts:
 ... ...
-        ​node4:+        ​kube4:
 ... ...
 </​code><​code>​ </​code><​code>​
 +(venv1) server:​~/​kubespray#​ time ansible-playbook -i inventory/​mycluster/​hosts.yaml cluster.yml
 +real    6m31.562s
  
-~/​kubespray#​ time ansible-playbook -i inventory/​mycluster/​hosts.yaml --limit=kube4 scale.yml+~/kubespray# ###time ansible-playbook -i inventory/​mycluster/​hosts.yaml --limit=kube4 scale.yml
 real    17m37.459s real    17m37.459s
  
Line 516: Line 519:
 <​code>​ <​code>​
 $ kubectl api-resources $ kubectl api-resources
- 
-$ kubectl run my-debian --image=debian -- "​sleep"​ "​3600"​ 
  
 $ ###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 -- "​sleep"​ "​60"​
  
 $ kubectl get pods $ kubectl get pods
Line 579: 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 666: Line 678:
 #            port: 80 #            port: 80
 #            #scheme: HTTPS #            #scheme: HTTPS
- 
-#        resources: 
-#          requests: 
-#            memory: "​64Mi"​ 
-#            cpu: "​250m"​ 
-#          limits: 
-#            memory: "​128Mi"​ 
-#            cpu: "​500m"​ 
- 
  
 #        volumeMounts:​ #        volumeMounts:​
Line 1149: Line 1152:
 </​code>​ </​code>​
  
-=== PersistentVolume и PersistentVolumeVolumeClaim ​===+=== PersistentVolume и PersistentVolumeClaim ​===
  
   * [[https://​qna.habr.com/​q/​629022|Несколько Claim на один Persistent Volumes?]]   * [[https://​qna.habr.com/​q/​629022|Несколько Claim на один Persistent Volumes?]]
Line 1342: Line 1345:
 <​code>​ <​code>​
 kubeN:~# apt install open-iscsi kubeN:~# apt install open-iscsi
 +
 +(venv1) server:~# ansible all -f 4 -m apt -a '​pkg=open-iscsi state=present update_cache=true'​ -i /​root/​kubespray/​inventory/​mycluster/​hosts.yaml
 </​code>​ </​code>​
   * [[https://​github.com/​longhorn/​longhorn]]   * [[https://​github.com/​longhorn/​longhorn]]
Line 2099: 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.1742526803.txt.gz · Last modified: 2025/03/21 06:13 by val