<p>I'm trying to delete a service I wrote &amp; deployed to Azure Kubernetes Service (along with required Dask components that accompany it), and when I run <code>kubectl delete -f my_manifest.yml</code>, my service gets stuck in the Terminating state. The console tells me that it was deleted, but the command hangs:</p>
<pre><code>&gt; kubectl delete -f my-manifest.yaml
service &quot;dask-scheduler&quot; deleted
deployment.apps &quot;dask-scheduler&quot; deleted
deployment.apps &quot;dask-worker&quot; deleted
service &quot;my-service&quot; deleted
deployment.apps &quot;my-deployment&quot; deleted
</code></pre>
<p>I have to <kbd>Ctrl</kbd>+<kbd>C</kbd> this command. When I check my services, Dask has been successfully deleted, but my custom service hasn't. If I try to manually delete it, it similarly hangs/fails:</p>
<pre><code>&gt; kubectl get services
NAME                TYPE           CLUSTER-IP   EXTERNAL-IP   PORT(S)                      AGE
kubernetes          ClusterIP      x.x.x.x      &lt;none&gt;        443/TCP                      18h
my-service          LoadBalancer   x.x.x.x      x.x.x.x       80:30786/TCP,443:31934/TCP   18h

&gt; kubectl delete service my-service
service &quot;my-service&quot; deleted
</code></pre>
<p><a href="https://stackoverflow.com/questions/62240272/deleting-namespace-was-stuck-at-terminating-state">This question</a> says to delete the pods first, but all my pods are deleted (<code>kubectl get pods</code> returns nothing). There's also <a href="https://github.com/kubernetes/kubernetes/issues/66110" rel="nofollow noreferrer">this closed K8s issue</a> that says <code>--wait=false</code> might fix foreground cascade deletion, but this doesn't work and doesn't seem to be the issue here anyway (as the pods themselves have already been deleted).</p>
<p>I assume that I can completely wipe out my AKS cluster and re-create, but that's an option of last resort here. I don't know whether it's relevant, but my service is using <a href="https://learn.microsoft.com/en-us/azure/aks/internal-lb#create-an-internal-load-balancer" rel="nofollow noreferrer">the <code>azure-load-balancer-internal: &quot;true&quot;</code> annotation</a> for the service, and I have a webapp deployed to my VNet that uses this service.</p>
<p>Is there any other way to force shutdown this service?</p>

<p>Thanks to @4c74356b41's suggestion of looking at <code>kubectl describe service my-service</code> (which I hadn't considered for some reason), I saw this warning:</p>
<blockquote>
<p>Code=&quot;LinkedAuthorizationFailed&quot; Message=&quot;The client 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx' with object id 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx' has permission to perform action 'Microsoft.Network/loadBalancers/write' on scope '/subscriptions/&lt;subscriptionId&gt;/resourceGroups/&lt;resourceGroup&gt;/providers/Microsoft.Network/loadBalancers/kubernetes-internal'; however, it does not have permission to perform action 'Microsoft.Network/virtualNetworks/subnets/join/action' on the linked scope(s) '/subscriptions/&lt;subscriptionId&gt;/resourceGroups/&lt;resourceGroup&gt;/providers/Microsoft.Network/virtualNetworks/&lt;vnet&gt;/subnets/&lt;subnet&gt;' or the linked scope(s) are invalid.</p>
</blockquote>
<p>(The client and object id GUIDs are the same value.)</p>
<p>This indicated that it's not exactly a Kubernetes issue, but moreso permissions within the Azure ecosystem. I looked through the portal and didn't find that GUID in any of my users, groups, or apps, so I'm not sure what it's referring to. However, I granted the <code>Owner</code> role to this client id, and after a few minutes, the service deleted.</p>
<pre><code>az role assignment create `
    --role Owner `
    --assignee xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
</code></pre>
