To shrink a Metrics service volume with data loss:
sudo k0s kubectl get pvc metrics -n kuma -o json | jq '.spec.volumeName'
sudo k0s kubectl scale deployment/metrics -n kuma --replicas=0
sudo k0s kubectl get pods -n kuma
sudo k0s kubectl delete pod metrics-<UID> -n kuma --force
sudo k0s kubectl get volume <volume_name> -n longhorn-system -o json | jq '.status.state'
sudo k0s kubectl delete pvc metrics -n kuma
sudo k0s kubectl get volume <volume_name> -n longhorn-system
On all worker nodes, directories with names beginning with the name of the deleted volume should disappear from the /opt/longhorn/replicas directory. If this does not happen, you need to delete them manually. Take care not to delete replicas that belong to other volumes by mistake.
sudo k0s kubectl apply -f - <<EOF
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: metrics
namespace: kuma
spec:
accessModes:
- ReadWriteOnce
storageClassName: kuma-network-storage
resources:
requests:
storage: 30Gi
EOF
sudo k0s kubectl scale deployment/metrics -n kuma --replicas=1
The Metrics service volume is successfully shrunk with data loss.
Page top