Kubernetes error: "unable to recognize "curiakube.yaml": no matches for kind "Deployment" in version "apps/v1beta1""

Kubernetes error: "unable to recognize "curiakube.yaml": no matches for kind "Deployment" in version "apps/v1beta1""

I have written in previous posts How I have moved my Ghost blog to Azure Kubernetes and How to update a Kubernetes cluster.

Because of some maintenance, I have deleted the deployment of the Kubernetes pod, and when trying to reapply it, I got the following error:

damiano@Azure:~$ kubectl apply -f curiakube.yaml
persistentvolume/pv-curiakube configured
persistentvolumeclaim/pvc-curiakube unchanged
service/curiakube unchanged
ingress.extensions/curiakube-ingress configured
error: unable to recognize "curiakube.yaml": no matches for kind "Deployment" in version "apps/v1beta1"

Honestly, this didn't make me happy. I know that I need to continuously update the Kubernetes cluster for security reasons, but if Kubernetes is not able to maintaining compatibility with itself, it means that it requires continuous maintenance and even simple operations are at risk, i.e. what works today, could not work in the future.

Anyway, what I have done has been to update the curiakube.yaml file as follow:

apiVersion: v1
kind: PersistentVolume
metadata:
  name: pv-curiakube
spec:
  capacity:
    storage: 5Ti
  accessModes:
    - ReadWriteOnce
  storageClassName: azurefile
  azureFile:
    secretName: secret-pv-curiakube
    shareName: contentfiles
    readOnly: false
  mountOptions:
  - dir_mode=0777
  - file_mode=0777
  - uid=1000
  - gid=1000
  - mfsymlinks
  - nobrl
  - cache=none
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: pvc-curiakube
spec:
  accessModes:
    - ReadWriteOnce
  storageClassName: azurefile
  resources:
    requests:
      storage: 5Ti
---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: curiakube
spec:
  replicas: 1
  selector:
    matchLabels:
      app: curiakube
  strategy:
    rollingUpdate:
      maxSurge: 1
      maxUnavailable: 1
  minReadySeconds: 5
  template:
    metadata:
      labels:
        app: curiakube
    spec:
      terminationGracePeriodSeconds: 31
      nodeSelector:
        "beta.kubernetes.io/os": linux
      containers:
      - name: curiame
        image: curiakubeacr.azurecr.io/ghost:3-alpine-ai
        imagePullPolicy: Always
        ports:
        - containerPort: 2368
        resources:
          requests:
            cpu: 100m
            memory: 128Mi
          limits:
            cpu: 250m
            memory: 256Mi
        volumeMounts:
          - name: content
            mountPath: /var/lib/ghost/content/
          - name: tmp
            mountPath: /tmp
        env:
        - name: privacy__useUpdateCheck
          value: "false"
        - name: APPINSIGHTS_INSTRUMENTATIONKEY
          value: "InstrumentationKey="
        - name: APPLICATIONINSIGHTS_ROLE_NAME
          value: "ghost"
        - name: APPLICATIONINSIGHTS_ROLE_INSTANCE
          value: "curiame"
        - name: NODE_ENV
          value: "production"
        - name: url
          value: "https://curia.me"
        securityContext:
          readOnlyRootFilesystem: true
          runAsUser: 1000
          runAsGroup: 1000
      volumes:
      - name: content
        persistentVolumeClaim:
          claimName: pvc-curiakube
      - emptyDir: {}
        name: tmp
---
apiVersion: v1
kind: Service
metadata:
  name: curiakube
spec:
  type: ClusterIP
  ports:
  - port: 80
    targetPort: 2368
  selector:
    app: curiakube
---
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  name: curiakube-ingress
  annotations:
    kubernetes.io/ingress.class: nginx
spec:
  rules:
    - host: curia.me
      http:
        paths:
          - backend:
              serviceName: curiakube
              servicePort: 80
            path: /

Reapplying it with:

kubectl apply -f curiakube.yaml

I got the following positive output:

damiano@Azure:~$ kubectl apply -f curiakube.yaml
persistentvolume/pv-curiakube configured
persistentvolumeclaim/pvc-curiakube unchanged
deployment.apps/curiakube configured
service/curiakube unchanged
ingress.extensions/curiakube-ingress unchanged