Repository navigation
Closed
Description
Is there an existing issue already for this bug?
- I have searched for an existing issue, and could not find anything. I believe this is a new bug.
I have read the troubleshooting guide
- I have read the troubleshooting guide and I think this is a new bug.
I am running a supported version of CloudNativePG
- I have read the troubleshooting guide and I think this is a new bug.
Contact Details
No response
Version
trunk (main)
What version of Kubernetes are you using?
1.30 (unsupported)
What is your Kubernetes environment?
Self-managed: kind (evaluation)
How did you install the operator?
YAML manifest
What happened?
I created a new kind environment as follows:
(cat <<EOF
kind: Cluster
apiVersion: kind.x-k8s.io/v1alpha4
name: multi-node-taints-template
nodes:
# Control Plane node
- role: control-plane
# Infrastructure/Application nodes (2)
- role: worker
labels:
infra.node.kubernetes.io:
- role: worker
labels:
app.node.kubernetes.io:
# PostgreSQL nodes (3)
- role: worker
labels:
postgres.node.kubernetes.io:
kubeadmConfigPatches:
- |
kind: JoinConfiguration
nodeRegistration:
taints:
- key: node-role.kubernetes.io/postgres
effect: NoSchedule
- role: worker
labels:
postgres.node.kubernetes.io:
kubeadmConfigPatches:
- |
kind: JoinConfiguration
nodeRegistration:
taints:
- key: node-role.kubernetes.io/postgres
effect: NoSchedule
- role: worker
labels:
postgres.node.kubernetes.io:
kubeadmConfigPatches:
- |
kind: JoinConfiguration
nodeRegistration:
taints:
- key: node-role.kubernetes.io/postgres
effect: NoSchedule
EOF
) | kind create cluster --config - --name cnpgI then ran:
kubectl label node -l postgres.node.kubernetes.io node-role.kubernetes.io/postgres=
kubectl label node -l infra.node.kubernetes.io node-role.kubernetes.io/infra=
kubectl label node -l app.node.kubernetes.io node-role.kubernetes.io/app=I installed the latest snapshot of the operator.
Then I created a new cluster using the manifest in the next section.
Once it was up, I ran:
kubectl scale cluster --replicas 4 cluster-examplewhich produced:
NAME READY STATUS RESTARTS AGE
cluster-example-1 1/1 Running 0 25m
cluster-example-2 1/1 Running 0 19m
cluster-example-3 1/1 Running 0 18m
cluster-example-4-join-8pds8 0/1 Pending 0 73sIf I run describe on the pod, I get:
Events:
Type Reason Age From Message
---- ------ ---- ---- -------
Warning FailedScheduling 2m54s (x2 over 8m19s) default-scheduler 0/6 nodes are available: 1 node(s) had untolerated taint {node-role.kubernetes.io/control-plane: }, 2 node(s) didn't match Pod's node affinity/selector, 3 node(s) didn't match pod anti-affinity rules. preemption: 0/6 nodes are available: 3 No preemption victims found for incoming pod, 3 Preemption is not helpful for scheduling.I tried to scale down again to 3, but the cluster hangs. I even tried to delete the job. Nothing.
Cluster resource
apiVersion: postgresql.cnpg.io/v1
kind: Cluster
metadata:
name: cluster-example
spec:
instances: 3
storage:
size: 1Gi
affinity:
nodeSelector:
node-role.kubernetes.io/postgres: ""
# Set the toleration for the taint
tolerations:
- key: node-role.kubernetes.io/postgres
operator: Exists
effect: NoSchedule
# Ensure that instances are scheduled and run on different nodes
enablePodAntiAffinity: true
topologyKey: kubernetes.io/hostname
podAntiAffinityType: requiredRelevant log output
No response
Code of Conduct
- I agree to follow this project's Code of Conduct
Metadata
Metadata
Assignees
Labels
triagePending triage
Type
Projects
- StatusShow more project fieldsDone
Activity
leonardoce commentedon Aug 15, 2024
This happens because you needed to delete the corresponding PVC groups and the Job too.
I think we can improve our
kubectl cnpg destroy <cluster-name> <instance-number>to do that too.leonardoce commentedon Aug 15, 2024
@gbartolini If we want to use
kubectl cnpg destroyfor that, I filed #5298jsilvela commentedon Aug 15, 2024
I was able to repro this exactly locally
jsilvela commentedon Aug 15, 2024
And I confirm that @leonardoce 's fix works well (of course) :)
gbartolini commentedon Aug 15, 2024
Well ... it makes sense now. My fault, I should have deleted the PVC too. However, I think we need to document this, as the behavior is fine, given that we don't delete PVCs at the moment.
Ultimately in real world we just need to add nodes.
jsilvela commentedon Aug 15, 2024
I scaled back to 3 and deleted the job only, didn't have to delete any PVC.
I agree, even if we update the plugin, you'd have to know to use the plugin to delete the instance.
jsilvela commentedon Aug 15, 2024
Interesting. Until I deleted the dangling PVC-4, the cluster was in
Creating a new replicagbartolini commentedon Aug 16, 2024
So essentially, there are two possible ways to exit this impasse:
kubectl scale cluster --replicas 3 cluster-examplekubectl delete job cluster-example-4-joinkubectl delete pvc cluster-example-4Ideally, IMHO, once we scale down to 3, the operator should automate the deletion of the job and the PVC. Thoughts?
gbartolini commentedon Aug 16, 2024
I have recapped everything here: https://www.gabrielebartolini.it/articles/2024/08/cloudnativepg-recipe-11-isolating-postgresql-workloads-in-kubernetes-with-kind/
feat: delete jobs during `kubectl cnpg destroy`
fix(plugin): delete jobs with `destroy` command (#5298)
fix(plugin): delete jobs with `destroy` command (#5298)
fix(plugin): delete jobs with `destroy` command (cloudnative-pg#5298)