aks-engine icon indicating copy to clipboard operation
aks-engine copied to clipboard

Windows pod creation always fails with Pod sandbox changed - Failed create pod sandbox

Open Gothic-X opened this issue 7 years ago • 13 comments

Is this a request for help?:


Is this an ISSUE or FEATURE REQUEST? (choose one):

Issue

What version of aks-engine?:

Version: v0.28.1 GitCommit: efc9dcfd GitTreeState: clean

Kubernetes version: v1.9.11

What happened:

Our containerized application suddenly stopped working and now all pods on windows nodes are stuck in a restart cycle of:

Normal SandboxChanged 5m (x2207 over 4h) kubelet, 3401k8s012 Pod sandbox changed, it will be killed and re-created.

Warning FailedCreatePodSandBox 20s (x2230 over 4h) kubelet, 3401k8s012 Failed create pod sandbox.

What you expected to happen:

I have deleted all deployments and services, rebooted all Windows nodes and the Linux master and attempted to reapply all deployments and services, but all pods are stuck in the error cycle above

How to reproduce it (as minimally and precisely as possible):

I don't know the exact steps as it occurred suddenly. However this has now happened in two separate aks-engine deployments in the last 4 days.

Anything else we need to know:

It's a mixed cluster of Windows and Linux nodes. This only effects pods running on Windows nodes; however it impacts all pods on Windows nodes.

The cluster looks like:

PS:> kubectl get nodes -o wide NAME STATUS ROLES AGE VERSION EXTERNAL-IP OS-IMAGE KERNEL-VERSION CONTAINER-RUNTIME 3401k8s010 Ready agent 7d v1.9.11 Windows Server Datacenter 10.0.17763.253 docker://18.9.0 3401k8s011 Ready agent 7d v1.9.11 Windows Server Datacenter 10.0.17763.253 docker://18.9.0 3401k8s012 Ready agent 7d v1.9.11 Windows Server Datacenter 10.0.17763.253 docker://18.9.0 3401k8s013 Ready agent 7d v1.9.11 Windows Server Datacenter 10.0.17763.253 docker://18.9.0 3401k8s014 Ready agent 7d v1.9.11 Windows Server Datacenter 10.0.17763.253 docker://18.9.0 k8s-linuxpool1-34014015-0 Ready agent 7d v1.9.11 Ubuntu 16.04.5 LTS 4.15.0-1035-azure docker://3.0.1 k8s-master-34014015-0 Ready master 7d v1.9.11 Ubuntu 16.04.5 LTS 4.15.0-1036-azure docker://3.0.1

Deployed with aks-version v0.28.1

PS:> aks-engine version Version: v0.28.1 GitCommit: efc9dcfd GitTreeState: clean

Gothic-X avatar Jan 21 '19 20:01 Gothic-X

👋 Thanks for opening your first issue here! If you're reporting a 🐞 bug, please make sure you include steps to reproduce it.

welcome[bot] avatar Jan 21 '19 20:01 welcome[bot]

Attached are screenshots that show the issue

kubectl get pods allwindowspodsstuckincontainercreating

kubectl describe pod podsandboxchanged

Gothic-X avatar Jan 21 '19 20:01 Gothic-X

You can try this workaround to save your Windows node, https://github.com/Azure/acs-engine/issues/4331.

Use azure-cni 1.0.16 in new cluster to prevent it happen again, https://github.com/Azure/azure-container-networking/issues/287.

zhiweiv avatar Jan 22 '19 00:01 zhiweiv

Here is the expanded steps I ran to address this issue

Repeat the following steps for each Windows node within the Kubernetes cluster Note: Only do this after you deleted or cordoned any pods running on any of the Windows node

  1. Attach a public IP address to the Windows node Steps: How to add a public IP address to a VM: https://www.mismosystems.com/2017/12/26/add-static-public-ip-address-to-an-existing-azure-vm/

  2. RDP to the Windows node (Note: Credentials in apimodel.json)

  3. Run the following steps inside the command window:

    a) Powershell b) cd
    c) Stop-Service Kubelet -Force d) Invoke-WebRequest -Uri https://github.com/Azure/azure-container-networking/releases/download/v1.0.16/azure-vnet-cni-windows-amd64-v1.0.16.zip -OutFile c:\azure-vnet-cni-windows-amd64-v1.0.16.zip e) Expand-Archive c:\azure-vnet-cni-windows-amd64-v1.0.16.zip f) cd c:\azure-vnet-cni-windows-amd64-v1.0.16 g) copy * c:\k\azurecni\bin
    h) copy 10-azure.conflist c:\k\azurecni\netconf
    i) cd c:\k j) del azure-vnet*.lock k) del azure-vnet*.json l) Start-Service Kubelet

  4. Terminate the RDP session

  5. Detach the public IP address from the Windows node

  6. Reboot VM

Gothic-X avatar Jan 23 '19 22:01 Gothic-X

I'm seeing the same behavior in aks-engine v0.29.1, kubernetes 1.13, docker 1809, with a simple private windows cluster on a custom vnet. Inserting 1.0.16 didn't seem to make a difference.

I can't launch any pods on the below without getting the sandbox changed error. If I launch a container directly on the host with docker run, it works fine, but standing it up inside a deployment causes endless crashes.

  "apiVersion": "vlabs",
  "properties": {
    "orchestratorProfile": {
      "orchestratorType": "Kubernetes",
      "orchestratorRelease": "1.13",
      "kubernetesConfig": {
        "azureCNIURLLinux": "https://github.com/Azure/azure-container-networking/releases/download/v1.0.16/azure-vnet-cni-linux-amd64-v1.0.16.tgz",
        "azureCNIURLWindows": "https://github.com/Azure/azure-container-networking/releases/download/v1.0.16/azure-vnet-cni-windows-amd64-v1.0.16.zip",
        "privateCluster": {
          "enabled": true
        },
        "kubeletConfig" : {
             "--feature-gates": "HyperVContainer=true"
        },
        "enableRbac": true,
        "apiServerConfig": {
          "--kubelet-preferred-address-types": "InternalIP,ExternalIP",
          "--feature-gates": "HyperVContainer=true"
        },
        "addons": [
          {
            "name": "tiller",
            "enabled": false
          },
          {
            "name": "kubernetes-dashboard",
            "enabled": false
          }
        ]
      }
    },
    "masterProfile": {
      "count": 1,
      "ipAddressCount": 1,
      "dnsPrefix": "k8s-windows-dev",
      "vnetSubnetId": "master-subnet",
      "agentVnetSubnetId": "agent-subnet",
      "firstConsecutiveStaticIP": "10.x.x.x",
      "vmSize": "Standard_D2_v2"
    },
    "agentPoolProfiles": [
      {
        "name": "agentpool1",
        "ipAddressCount": 8,
        "count": 2,
        "vnetSubnetId": "agent-subnet",
        "vmSize": "Standard_D2_v2",
        "availabilityProfile": "AvailabilitySet",
        "osType": "Windows",
        "osDiskSizeGB": 128,
        "extensions": [
            {
                "name": "winrm"
            }
        ]
      }
    ],
    "linuxProfile": {
      "adminUsername": "admin",
      "ssh": {
        "publicKeys": [
          {
            "keyData": "keydata"
          }
        ]
      }
    },
    "windowsProfile": {
      "adminUsername": "admin",
      "adminPassword": "whatever",
      "windowsDockerVersion": "18.09.0"
    },
    "servicePrincipalProfile": {
      "clientId": "id",
      "secret": "secret"
    }
  }
}```

jswattjr avatar Jan 23 '19 23:01 jswattjr

@jswattjr somes issues you can take a look, https://github.com/Azure/aks-engine/issues/210 https://github.com/Azure/azure-container-networking/issues/289 https://github.com/Azure/azure-container-networking/issues/292

you can also check logs under c:\k in Windows nodes to see what happened.

zhiweiv avatar Jan 24 '19 01:01 zhiweiv

@zhiweiv

Not sure any of those issues are related. I am setting the MasterSubnet on deployment, so that shouldn't be the problem.

Errors from the logs are: Azure-vnet.log: "2019/01/24 16:19:15 handleConsecutiveAdd failed with error There was an operation attempted on a degraded object."

Windows Event log (docker): "failure in a Windows system call: The requested virtual machine or container operation is not valid in the current state"

azure-vnet-ipam.log shows the plugin restarting continually, not sure if that's normal or not. Same behavior on 1.0.15 and 1.0.16.

I think the error only occurs with a custom vnet, maybe I should open a different issue/bug?

jswattjr avatar Jan 24 '19 17:01 jswattjr

Custom vnet works in our environment, your template looks a bit different with mine, you can take a look on my template, and build a new cluster to see if it works.

{
	"apiVersion": "vlabs",
	"properties": {
		"orchestratorProfile": {
			"orchestratorType": "Kubernetes",
			"orchestratorRelease": "1.13",
			"kubernetesConfig": {
				"privateCluster": {
					"enabled": true
				}
			}
		},
		"masterProfile": {
			"count": 1,
			"dnsPrefix": "",
			"vmSize": "Standard_B2s",
			"vnetSubnetId": "/subscriptions/subId/resourceGroups/vnet/providers/Microsoft.Network/virtualNetworks/k8s/subnets/default",
			"firstConsecutiveStaticIP": "10.2.255.239",
			"vnetCidr": "10.2.0.0/16"
		},
		"agentPoolProfiles": [{
			"name": "linuxpool1",
			"count": 1,
			"vmSize": "Standard_B1ms",
			"osType": "Linux",
			"availabilityProfile": "AvailabilitySet",
			"vnetSubnetId": "/subscriptions/subId/resourceGroups/vnet/providers/Microsoft.Network/virtualNetworks/k8s/subnets/default"
		},
		{
			"name": "windowspool1",
			"count": 1,
			"vmSize": "Standard_B2s",
			"osType": "Windows",
			"availabilityProfile": "AvailabilitySet",
			"vnetSubnetId": "/subscriptions/subId/resourceGroups/vnet/providers/Microsoft.Network/virtualNetworks/k8s/subnets/default"
		}],
		"windowsProfile": {
			"adminUsername": "",
			"adminPassword": ""
		},
		"linuxProfile": {
			"adminUsername": "",
			"ssh": {
				"publicKeys": [{
					"keyData": ""
				}]
			}
		},
		"servicePrincipalProfile": {
			"clientId": "",
			"secret": ""
		}
	}
}

zhiweiv avatar Jan 25 '19 01:01 zhiweiv

Add below section to azuredeploy.parameters.json before deploying

"masterSubnet": {
    "value": "10.2.0.0/16"
 },

zhiweiv avatar Jan 25 '19 02:01 zhiweiv

@zhiweiv I believe it is working now, my sample deployment came up without the error. I was providing masterSubnet as the subnet ID instead of the subnet CIDR, and also was not specifying vnetCIDR in the master profile.

Thanks for your help.

jswattjr avatar Jan 25 '19 19:01 jswattjr

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] avatar Mar 26 '19 20:03 stale[bot]

@Gothic-X Can you comment on the k8s version, the Windows server version, and Azure CNI version your clusters exhibiting this symptom are running?

Thanks!

jackfrancis avatar Apr 22 '19 21:04 jackfrancis

This issue has manifested itself again.

What version of aks-engine?: Version: v0.33.6 GitCommit: 8d7b080e4 GitTreeState: clean

Kubernetes version: v1.9.11

CNI version: "azureCNIURLLinux": "https://github.com/Azure/azure-container-networking/releases/download/v1.0.20/azure-vnet-cni-linux-amd64-v1.0.20.tgz", "azureCNIURLWindows": "https://github.com/Azure/azure-container-networking/releases/download/v1.0.20/azure-vnet-cni-windows-amd64-v1.0.20.zip"

What happened: Approximately 20% of our pods running on windows nodes within a Kubernetes cluster deployed with aks-engine are stuck in a restart cycle of:

Normal SandboxChanged 5m (x2207 over 4h) kubelet, 3401k8s012 Pod sandbox changed, it will be killed and re-created.
Warning FailedCreatePodSandBox 20s (x2230 over 4h) kubelet, 3401k8s012 Failed create pod sandbox.

Observed with the pod warnings, is that several of the Windows nodes flip between Ready and NotReady; although this issue has also been observed with all Windows nodes having a status of Ready.

Comments: I should note that the cluster ran successfully with no pod restarts for approximately 7hours, then the pod failures begain.

Output from some key commands:

kubectl get node -o wide

OUTPUT:
NAME                        STATUS    ROLES     AGE       VERSION   EXTERNAL-IP   OS-IMAGE                    KERNEL-VERSION      CONTAINER-RUNTIME
2060k8s010                  Ready     agent     1m        v1.9.11   <none>        Windows Server Datacenter   10.0.17763.437      docker://18.9.2
2060k8s011                  NotReady  agent     1m        v1.9.11   <none>        Windows Server Datacenter   10.0.17763.437      docker://18.9.2
2060k8s012                  NotReady  agent     1m        v1.9.11   <none>        Windows Server Datacenter   10.0.17763.437      docker://18.9.2
2060k8s013                  Ready     agent     1m        v1.9.11   <none>        Windows Server Datacenter   10.0.17763.437      docker://18.9.2
2060k8s014                  Ready     agent     1m        v1.9.11   <none>        Windows Server Datacenter   10.0.17763.437      docker://18.9.2
2060k8s015                  NotReady  agent     1m        v1.9.11   <none>        Windows Server Datacenter   10.0.17763.437      docker://18.9.2
2060k8s016                  Ready     agent     1m        v1.9.11   <none>        Windows Server Datacenter   10.0.17763.437      docker://18.9.2
2060k8s017                  Ready     agent     2m        v1.9.11   <none>        Windows Server Datacenter   10.0.17763.437      docker://18.9.2
k8s-linuxpool1-20607229-0   Ready     agent     5m        v1.9.11   <none>        Ubuntu 16.04.6 LTS          4.15.0-1040-azure   docker://3.0.4
k8s-master-20607229-0       Ready     master    5m        v1.9.11   <none>        Ubuntu 16.04.6 LTS          4.15.0-1040-azure   docker://3.0.4

The events from one of the impacted pods are as follows:

Events:

  Type     Reason                  Age                 From                 Message
  ----     ------                  ----                ----                 -------
  Warning  FailedCreatePodSandBox  15m (x126 over 8h)  kubelet, 2060k8s012  Failed create pod sandbox.
  Normal   SandboxChanged          7s (x129 over 8h)   kubelet, 2060k8s012  Pod sandbox changed, it will be killed and re-created.

Gothic-X avatar Apr 23 '19 00:04 Gothic-X