Search code examples
azurekubernetesazure-aksazure-webapps

How to kick off Linux script in AKS from Web App (AZURE) on-demand


Given that I have a 24x7 AKS Cluster on AZURE, for which afaik Kubernetes cannot stop/pause a pod and then resume it standardly,

  • with, in my case, a small Container in a Pod, and for that Pod it can be sidelined via --replicas=0,

    • then, how can I, on-demand, best kick off a LINIX script packaged in that Pod/Container which may be not running,

      • from an AZURE Web App?

I thought using ssh should work, after first upscaling the pod to 1 replica. Is this correct?

I am curious if there are simple http calls in AZURE to do this. I see CLI and Powershell to start/stop AKS cluster, but that is different of course.


Solution

  • You can interact remotely with AKS by different methods. The key here is to use the control plane API to deploy your kubernetes resource programmatically (https://kubernetes.io/docs/concepts/overview/kubernetes-api/) .

    In order to do that, you should use client libraries that enable that kind of access. Many examples can be found here for different programming languages: https://github.com/kubernetes-client

    ssh is not really recommended since that is sort of a god access to the cluster and its usage is not meant for your purpose.