<p>in my dotnet app I need to monitor activities and if there is no activity withing 10 min I should kill the kubernete pod. killing the process will not do the job, is there anyway to kill/delete a pod within dotnet? </p>

<p>I assume you want to kill pods using code within the k8s cluster. 
Have a look at the <a href="https://github.com/kubernetes-client/csharp/" rel="nofollow noreferrer">kubernetes client</a> for dotnet core. You can use the cluster config from within the cluster you are running.</p>

<pre><code>// Load from the default kubeconfig on the machine.
var config = KubernetesClientConfiguration.BuildConfigFromConfigFile();
IKubernetes client = new Kubernetes(config);
var list = client.ListNamespacedPod("default");
</code></pre>

<p>After that, you can lists pods, services etc, and kill them if you want to.</p>

<p>However, <strong>keep in mind</strong> that in order to read the local cluster config, and access resources, you need to set up a service account with the correct rights to do so.</p>

<p>The example below has permissions to list services for example within the k8s cluster. Adjust to your scenario accordingly. Change 'services' to 'Pods' for example, and assign the right verbs for your logic.</p>

<pre><code>apiVersion: v1
kind: ServiceAccount
metadata:
  name: service-discovery-account

---

apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
  namespace: default
  name: service-discovery-service-reader
rules:
- apiGroups: [""]
  resources: ["services"]
  verbs: ["get", "watch", "list"]

---

apiVersion: rbac.authorization.k8s.io/v1beta1
kind: ClusterRoleBinding
metadata:
  name: service-discovery-service-reader
subjects:
  - kind: ServiceAccount
    # Reference to ServiceAccount kind's `metadata.name`
    name: service-discovery-account
    # Reference to ServiceAccount kind's `metadata.namespace`
    namespace: default
roleRef:
  kind: ClusterRole
  name: service-discovery-service-reader
  apiGroup: rbac.authorization.k8s.io
</code></pre>

<p>Don't forget to assign that service account to the deployment, responsible for monitoring other pods within the cluster:</p>

<pre><code>apiVersion: apps/v1
kind: Deployment
metadata:
  name: your-deployment-app
spec:
  selector:
    matchLabels:
      app: your-deployment-app
  template:
    metadata:
      labels:
        app: your-deployment-app
    spec:
      serviceAccountName: service-discovery-account
      containers:
</code></pre>
