I am trying to deploy, to a Kubernetes cluster hosted on Azure (AKS v1.26.6), the following configurations: statefulset.yml
and storageclass.yml
.
storageclass.yml
apiVersion: storage.k8s.io/v1
kind: StorageClass
metadata:
name: managed-premium-retain
provisioner: kubernetes.io/azure-disk
reclaimPolicy: Retain
parameters:
storageaccounttype: Premium_LRS
statefulset.yml
apiVersion: v1
kind: Service
metadata:
name: eventstore-cluster
labels:
app: eventstore-cluster
spec:
clusterIP: "None"
ports:
- port: 2113
name: eventstore-web
- port: 1113
name: eventstore-tcp
- port: 2112
name: gossip
selector:
app: eventstore-cluster
---
apiVersion: apps/v1
kind: StatefulSet
metadata:
name: eventstore-cluster
spec:
selector:
matchLabels:
app: eventstore-cluster
serviceName: eventstore-cluster
replicas: 3
template:
metadata:
labels:
app: eventstore-cluster
spec:
affinity:
podAntiAffinity:
requiredDuringSchedulingIgnoredDuringExecution:
- labelSelector:
matchExpressions:
- key: "app"
operator: In
values:
- eventstore-cluster
topologyKey: "kubernetes.io/hostname"
containers:
- name: eventstore
image: eventstore/eventstore:release-4.1.1-hotfix1
env:
- name: EVENTSTORE_CLUSTER_SIZE
value: "3"
- name: EVENTSTORE_DISCOVER_VIA_DNS
value: "true"
- name: EVENTSTORE_CLUSTER_DNS
value: "eventstore-cluster"
- name: EVENTSTORE_EXT_IP
valueFrom:
fieldRef:
fieldPath: status.podIP
ports:
- containerPort: 2113
name: eventstore-web
- containerPort: 1113
name: eventstore-tcp
- containerPort: 2112
name: gossip
volumeMounts:
- name: eventstore-cluster-data
mountPath: /var/lib/eventstore
livenessProbe:
httpGet:
path: /
port: 2113
initialDelaySeconds: 30
periodSeconds: 15
readinessProbe:
httpGet:
path: /
port: 2113
initialDelaySeconds: 5
periodSeconds: 5
volumeClaimTemplates:
- metadata:
name: eventstore-cluster-data
spec:
accessModes: [ "ReadWriteOnce" ]
storageClassName: "managed-premium-retain"
resources:
requests:
storage: 20Gi
When I run the command:
kubectl apply -f .\statefulSet.yml
The following error is shown:
The StatefulSet "eventstore-cluster" is invalid: spec: Forbidden: updates to statefulset spec for fields other than 'replicas', 'ordinals', 'template', 'updateStrategy', 'persistentVolumeClaimRetentionPolicy' and 'minReadySeconds' are forbidden
Oh no.. after a failed deployment of the statefulset
, it turns out when I was running the command:
kubectl apply -f .\statefulSet.yml
The error was being shown as the statefulset was already there.
Running the following command showed all running stateful sets:
kubectl get statefulsets
NAME READY AGE eventstore-cluster 0/3 6h1m
Finally, running the command to delete the broken statefulset fixed the issue for me:
kubectl delete statefulsets eventstore-cluster