0

So i want to deploy mssql pod on kubernetes altough i'm having some trouble in deplooying my peristent volume.

I deployed first my storageclass in my namespaces which seems to be deployed, my persistent volume didn't mssql deployed with pending status and when using the describe command it said it could not bind my volume

So I google this type of error and came across another persistent volume configuration which made me change my yaml file altough now I come across another error.

This error is already asked on this forum but the answer doesn't seem to fit or fix my issue. -> reference: same issue

error message:

the persistent volume pvc-mssql is invalid: spec.persistentvolumesource: forbidden: is immutable after creation nodeaffinity: invalid value: core.volumenodeaffinity(required:(*core.nodeselector) (0xc007163b00)}: field is immutable

error image

my storageclass(deployed):

kind: StorageClass
apiVersion: storage.k8s.io/v1
metadata:
  name: local-storage
provisioner: kubernetes.io/no-provisioner
volumeBindingMode: WaitForFirstConsumer

my pvc (errored):

apiVersion: v1
kind: PersistentVolume
metadata:
  name: pvc-mssql
  labels:
    type: local
spec:
  capacity:
    storage: 12Gi
  accessModes:
  - ReadWriteOnce
  persistentVolumeReclaimPolicy: Retain
  storageClassName: local-storage
  hostPath:
    path: /mnt/data
  nodeAffinity:
    required:
      nodeSelectorTerms:
      - matchExpressions:
        - key: kubernetes.io/hostname
          operator: In
          values:
          - master-production-internal

my mssql (waiting to be deployed):

apiVersion: apps/v1
kind: Deployment
metadata:
  name: mssql
  labels:
    app: mssql
spec:
  replicas: 1
  selector:
    matchLabels:
      app: mssql
  template:
    metadata:
      labels:
        app: mssql
    spec:
      containers:
      - name: mssql
        image: mcr.microsoft.com/mssql/server
        resources:
          requests:
            cpu: 1
            memory: 2Gi
        env:
          - name: ACCEPT_EULA
            value: "Y"
          - name: SA_PASSWORD
            value: mypassword
        ports:
        - containerPort: 1433
        volumeMounts:
        - name: mssql
          mountPath: /var/opt/mssql
      volumes:
      - name: mssql
        persistentVolumeClaim:
          claimName: pvc-mssql

all are deployed in the same namespace of course. my kubernetes exists of 4 node aka 4 vm's where each vm has about 2vcpus and 4GB ram with 128GB disk space running ubuntu server: configured with fail2ban, ufw, I got 1 master and 3 nodes. I have the latest version cluster has been deployed about less than 2 months ago

What seems to be the issue and or what do i need to change in my pvc and maybe something i have to change in my mssql deployedment yaml?

As i understand the error correctly of my mssql it cannot bind the shred volume on another node thats why i have got a specific node in my pvc now which is my master. <- is this correct too or should I change it?

9
  • Please edit your question and fix the code formatting, as well as using text for error messages instead of hard to read images. The how to ask page will provider guidance for what is considered a good question
    – mdaniel
    Aug 21 '20 at 16:02
  • @mdaniel thx all fix it directly but weird i used the code block quote :/ Aug 21 '20 at 16:13
  • kind: Deployment is bad news with databases; that's what a StatefulSet is designed for -- a Deployment makes zero promises about how many concurrent Pods attempt to bind to a PVC, whereas a StatefulSet knows that pod-0 should wait until its PVC is available before scaling back up.
    – mdaniel
    Aug 22 '20 at 0:31
  • so if i uderstand you correctly I should change my kind from deployemnt to statefulset? Aug 22 '20 at 10:48
  • Yes, he meant that. Can you past this comment in a proper format as an answer ?
    – Malgorzata
    Aug 24 '20 at 11:35
1

I have achieved this by deploying the mssql and mongo pod without a persistent volume claim.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.