DO Block storage only can mount into a single Node (VM). So, when I provision PV/PVC it creates a block storage.
I am implementing helm chart bitnami/mysql where I want to create the mysql pod only into the node the PVC is mounted.
How should I go about it? I have tried with Affinity but I have some issues with it as I can not label nodes. Here is my configuration values.yml
file
global:
storageClass: do-block-storage
architecture: standalone
primary:
name: primary
persistence:
enabled: true
existingClaim: backend-mysql-primary
accessModes:
- ReadWriteOnce
size: 10Gi
selector: {}
affinity:
podAffinity:
requiredDuringSchedulingIgnoredDuringExecution:
- topologyKey: topology.kubernetes.io/region
namespaces:
- sportsdemy
labelSelector:
matchExpressions:
- key: pvc
operator: In
values:
- backend-mysql-primary
This config throws the following error:
error validating "": error validating data: ValidationError(StatefulSet.spec.template.spec.affinity.podAffinity.requiredDuringSchedulingIgnoredDuringExecution[0]): missing required field "topologyKey" in io.k8s.api.core.v1.PodAffinityTerm
So it looks like a topologyKey
is required but I am not sure how it is helpful here.
But I went ahead and tried to add the topologyKey
from labels assigned to the node by DOKS. topology.kubernetes.io/region
Deployment is applying without issues but pod is assigned to any node:
0/2 nodes are available: 2 node(s) didn't match pod affinity rules. preemption: 0/2 nodes are available: 2 Preemption is not helpful for scheduling.
pod didn't trigger scale-up: 1 node(s) didn't match pod affinity rules
Here is the yml file for volumes:
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: backend-mysql-primary
namespace: sportsdemy
labels:
pvc: backend-mysql-primary
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 10Gi
storageClassName: do-block-storage
Goal: I have labeled my pv as pvc: backend-mysql-primary
and want to a node where I have the PV.
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!