kubernetes – Kubectl on AKS returned error error: the server doesn’t have a resource type “”

I setup a test deployment, deployed it just fine with kubectl apply -f testdeployment.yml

The yaml file was:

apiVersion: apps/v1
kind: Deployment
metadata:
  name: nginx
  labels:
    app: nginx
spec:
  replicas: 1
  selector:
    matchLabels:
      app: nginx
  template:
    metadata:
      labels:
        app: nginx
    spec:
      containers:
      - name: nginx
        image: nginx:1.14.2
        ports:
        - containerPort: 80
---
apiVersion: v1
kind: Service
metadata:
  name: nginx-service
  labels:
     app: nginx
spec:
  selector:
    app: nginx
  ports:
    - port: 80
      targetPort: 80
  type: LoadBalancer

I should be able to clean this all up with:
kubectl delete -f testdeployment.yml

But, much to my amazement, it returned the error: error: the server doesn’t have a resource type “”

I’m sure this is due to some weird thing in YAML, where there is a space, or lack of a space, or a blank line or something, but why can it parse it and apply it just fine, but then can’t reverse it??

The fact that I can apply this, and not un-apply it, implies there is a bug in AKS
I get the same error if I copy just the top part, or just the bottom part and save that in a file and attempt a delete -f testdeployment1.yml

Which implies that both of them have the same problem, or Kubernetes is just broken and I need to delete the entire service and recreate it… (I also noticed a spike on the VM, went from $4 charge for first day to $16 for 2nd day, which makes this $496/month to have one nginx server running, which, off the top of my head is a hard NO… I have $50/month credit on this account, so I can test with this for 3 days each month? (Included here because that could be a clue..)

(Oh, I had replicas as 2 when I ran this the first time, no other changes to the file)
Dropped it to 0 today in a hope to ‘delete’ this as much as possible

Read more here: Source link