If you have a flask app, you can use the Kubernetes python api to create Kubernetes pods or jobs. They have an example of creating a deployment here based on a yaml file that exists, but you also could define the yaml within your code or use their api spec. Their Deployment example is below, but again you would probably want to use Pods or Jobs.
from os import path
import yaml
from kubernetes import client, config
def main():
# Configs can be set in Configuration class directly or using helper
# utility. If no argument provided, the config will be loaded from
# default location.
config.load_kube_config()
with open(path.join(path.dirname(__file__), "nginx-deployment.yaml")) as f:
dep = yaml.safe_load(f)
k8s_apps_v1 = client.AppsV1Api()
resp = k8s_apps_v1.create_namespaced_deployment(
body=dep, namespace="default")
print("Deployment created. status='%s'" % resp.metadata.name)
if __name__ == '__main__':
main()