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
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?
Best Answer
I have achieved this by deploying the mssql and mongo pod without a persistent volume claim.