Compare commits

..
5 Commits
Author SHA1 Message Date
Márcio Fernandes c8aabe2532 modified: README.md 2026-07-19 10:54:44 +00:00
Márcio Fernandes 86f971fb35 modified: README.md 2026-07-18 11:47:48 +00:00
Márcio Fernandes fd14473b99 modified: docs/fluxcd.md 2026-07-17 12:59:30 +00:00
Márcio Fernandes e8fe8c449c modified: README.md 2026-07-15 13:50:42 +00:00
Márcio Fernandes 3433a2f7f2 modified: README.md 2026-07-13 13:08:52 +00:00
2 changed files with 108 additions and 1 deletions
+72 -1
View File
@@ -12,11 +12,13 @@ Kubernetes is an opensource platform that automates the deployment, scaling,
- [OOMKilled](#oomkilled)
- [Attach to an pod](#attach-to-an-pod)
- [Run command on pod](#run-command-on-pod)
- [Container TTY](#container-tty)
- [Persistent volumes](#persistent-volumes)
- [create PersistentVolumes - host path](#create-persistentvolumes---host-path)
- [find persistent volume used pvc](#find-persistent-volume-used-pvc)
- [Patch pv - change to retain policy](#patch-pv---change-to-retain-policy)
- [Patch pv - remove finalizers](#patch-pv---remove-finalizers)
- [check orphans](#check-orphans)
- [persistent volume claims](#persistent-volume-claims)
- [Create an pod with PVC](#create-an-pod-with-pvc)
- [kubectl](#kubectl)
@@ -57,6 +59,7 @@ Kubernetes is an opensource platform that automates the deployment, scaling,
- [k3s](#k3s)
- [Install / Setup](#install--setup)
- [prune old images](#prune-old-images)
- [kill all](#kill-all)
- [Prune ephemeral containerd data](#prune-ephemeral-containerd-data)
- [check system logs](#check-system-logs)
- [Workarounds \& Fixes](#workarounds--fixes)
@@ -223,7 +226,7 @@ kubectl delete pod -n appNamespace -l app=myAppName
### OOMKilled
**list all OOMKilled pods:**
**list all OOMKilled:**
``` bash
kubectl get events --all-namespaces | grep -i "OOMKilled"
@@ -235,6 +238,16 @@ kubectl get pods --all-namespaces \
| grep OOMKilled
```
On cluster node
```bash
sudo dmesg -T | grep -i kill
sudo dmesg -T | grep -Ei "oom|kill"
sudo journalctl -k | grep -Ei "oom|kill"
sudo journalctl -k --since "1 hour ago" | grep -Ei "oom|kill"
sudo journalctl -k -o short-iso | grep -Ei "oom|kill"
```
### Attach to an pod
Attach connects your terminal to the main process of the container (PID 1), or another running process if specified.
@@ -263,6 +276,20 @@ POD_NAME=$(kubectl get pod -l app=$MY_APP_NAME -n $NAMESPACE -o jsonpath='{.item
kubectl exec -n $NAMESPACE -it ${POD_NAME} -- sh
```
### Container TTY
```yaml
...
command: ["bash", "-c"]
tty: true
args:
- |
while true; do
sleep 100
done
...
```
``` bash
# bash
POD_NAME=$(kubectl get pod -l app=myAppName -n appNamespace -o jsonpath='{.items[0].metadata.name}')
@@ -320,6 +347,39 @@ kubectl patch pv $PV_NAME \
-p '{"metadata":{"finalizers": null}}'
```
### check orphans
**Execute on host:**
``` bash
#/bin/bash
STORAGE_DIR="/var/lib/rancher/k3s/storage"
# clean if already been used
unset PV_PATHS
declare -A PV_PATHS
ORPHANS=()
for name in $(kubectl get pv -o jsonpath='{.items[*].metadata.name}'); do
path=$(kubectl get pv ${name} -o jsonpath='{.spec.local.path}' 2>/dev/null)
# check if path is no empty
[[ -n "${path}" ]] && PV_PATHS["${path}"]="1"
done
for dir in "$STORAGE_DIR"/*; do
[ -d "$dir" ] || continue
if [[ -z "${PV_PATHS[$dir]}" ]]; then
ORPHANS+=("$dir")
fi
done
if [[ ${#ORPHANS[@]} -eq 0 ]]; then
echo "No orphans found."
else
echo "orphans:"
printf "%s\n" "${ORPHANS[@]}"
fi
```
### persistent volume claims
``` yaml
@@ -832,6 +892,17 @@ crictl rmi --prune
sudo ctr --address /run/k3s/containerd/containerd.sock images prune --all
```
### kill all
``` bash
k3s-killall.sh
```
If k3s using mount. Force kill by mount
```bash
kill -9 $(lsof +f -- /mount | awk 'NR>1 {print $2}')
```
### Prune ephemeral containerd data
+36
View File
@@ -80,6 +80,24 @@ spec:
**Disable:**
``` bash
FLUX_RESOURCE_NAME="???"
FLUX_RESOURCE_NS="???"
kubectl patch kustomization ${FLUX_RESOURCE_NAME} -n ${FLUX_RESOURCE_NS} --type merge -p '{"spec":{"prune":false}}'
```
**Enable:**
``` bash
FLUX_RESOURCE_NAME="???"
FLUX_RESOURCE_NS="???"
kubectl patch kustomization ${FLUX_RESOURCE_NAME} -n ${FLUX_RESOURCE_NS} --type merge -p '{"spec":{"prune":true}}'
```
## kustomization helm release
**Disable:**
``` bash
FLUX_RESOURCE_NAME="???"
FLUX_RESOURCE_NS="???"
@@ -93,3 +111,21 @@ FLUX_RESOURCE_NAME="???"
FLUX_RESOURCE_NS="???"
kubectl patch helmrelease ${FLUX_RESOURCE_NAME} -n ${FLUX_RESOURCE_NS} --type merge -p '{"spec":{"prune":true}}'
```
## Reconcile
**Source git:**
``` bash
FLUX_RESOURCE_NAME="???"
FLUX_RESOURCE_NS="???"
flux reconcile source git ${FLUX_RESOURCE_NAME} -n ${FLUX_RESOURCE_NS}
```
**Kustomization:**
``` bash
FLUX_RESOURCE_NAME="???"
FLUX_RESOURCE_NS="???"
flux reconcile kustomization ${FLUX_RESOURCE_NAME} -n ${FLUX_RESOURCE_NS}
```