User Tools

Site Tools


topic:k8

Differences

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

Link to this comparison view

Both sides previous revisionPrevious revision
topic:k8 [2024/12/24 17:55] – removed arietopic:k8 [2024/12/31 09:00] (current) – created - external edit 127.0.0.1
Line 1: Line 1:
 +====== k8 notes of Arie ======
  
 +<code>
 +#Bash into container
 +k exec -it wiki-dokuwiki-9f9fd859d-2wfx6 bash
 +
 +### Useful aliases ###
 +kush [-n ns] pod_name   # get shell into pod
 +kud pod_name            # kubectl describe pod
 +kug pod pod_name        # kubectl get pod_name
 +ktail pod_name          # get logs for the pod
 +
 +# fetch chart to analyse values.yaml
 +helm fetch gitlab/gitlab --untar
 +
 +# debug certs
 +kug orders,challenges -o wide
 +
 +# Delete PV that has finalizers
 +pv=pvc-daec7eed-fc8e-4281-a15b-6b370df54804
 +echo '{"metadata": {"finalizers": null}}' | kubectl patch pv $pv --patch-file=/dev/stdin
 +# Delete POD that got stuck (and no finalizers to delete)
 +kubectl delete pods fluent-bit-xczr2 --grace-period=0 --force
 +
 +#copy file into pod
 +kubectl cp /mnt/common/tmp/run dev/page2-dp-77f87664bb-4l8mc:/tmp/run 
 +
 +# Delete namespace that got stuck
 +namespaceToDelete=brocha
 +kubectl get namespace "$namespaceToDelete" -o json | \
 + jq 'del(.spec.finalizers)'   | \
 + kubectl replace --raw /api/v1/namespaces/$namespaceToDelete/finalize -f -
 +
 +# drain and evict pods from a node
 +kubectl drain --ignore-daemonsets --delete-emptydir-data k8i03
 +#untaint
 +kubectl uncordon k8i03
 +
 +# port forwarding of localport 40090 to port 9090 of the svc
 +kubectl port-forward -n monitoring svc/prometheus-k8s 40090:9090 --address='0.0.0.0'
 +
 +# see nodes labels
 +kug nodes --show-labels
 +# remove label worker from a node:
 +kubectl label node ip-10-0-7-187.ec2.internal worker-
 +# add control-plane label
 +kubectl label node k8r05 node-role.kubernetes.io/control-plane=
 +kubectl label node k8p01 general=yes
 +
 +# See cpu/mem usage by nodes
 +kubectl top node
 +
 +# Show pod by label
 +kug pod -n monitoring -l app.kubernetes.io/name=kube-state-metrics
 +# kill pods by label
 +kudel pod -n nqa -l app=etljobs-sel
 +
 +# watch hpa of gwpa@rnd
 +kug hpa -n rnd gwpa-hpa --watch
 +
 +# events on API of prod2 farm
 +kug events -n prod2
 +</code>
topic/k8.1735062955.txt.gz · Last modified: 2024/12/31 08:55 (external edit)

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki