Virtual Kubelet with AKS

10/22/2018

I followed the doc here When I tried to create a virtual service for Windows, I get error: The Deployment "nanoserver-iis" is invalid: spec.template.metadata.labels: Invalid value: map[string]string{"app":"nanoserver-iis"}: selector does not match template labels

kubectl get nodes

`NAME                                               STATUS    ROLES     AGE       
VERSION
aks-agentpool-27326293-0                           Ready     agent     15m       
v1.11.3
virtual-kubelet-aci-connector-windows-westeurope   Ready     agent     9s        
v1.11.2`

virtual-kubelet-windows.yaml

apiVersion: apps/v1 kind: Deployment metadata: name: nanoserver-iis spec: replicas: 1 selector: matchLabels: app: aci-helloworld template: metadata: labels: app: nanoserver-iis spec: containers: - name: nanoserver-iis image: microsoft/iis:nanoserver ports: - containerPort: 80 nodeSelector: kubernetes.io/hostname: virtual-kubelet-aci-connector-windows-westeurope tolerations: - key: virtual-kubelet.io/provider operator: Equal value: azure effect: NoSchedule

-- Benzhi Pan
azure-aks
docker
kubernetes

1 Answer

10/22/2018

Try updating the deployment definition with the following. There is an inconsistency in the YAML definition where labels don't match. Labels in the matchLabeles field and labels in the metadata field need to match. In the deployment definition, they are set to different values aci-helloworld and nanoserver-iis respectively.

apiVersion: apps/v1
kind: Deployment
metadata:
  name: nanoserver-iis
spec:
  replicas: 1
  selector:
    matchLabels:
      app: nanoserver-iis
  template:
  metadata:
    labels:
      app: nanoserver-iis
  spec:
    containers:
    - name: nanoserver-iis
      image: microsoft/iis:nanoserver
      ports:
    - containerPort: 80
    nodeSelector:
      kubernetes.io/hostname: virtual-kubelet-aci-connector-windows-westeurope
    tolerations:
    - key: virtual-kubelet.io/provider
      operator: Equal
      value: azure
      effect: NoSchedule
-- Razi
Source: StackOverflow