简体   繁体   English

如何获取配置文件以从集群外部访问 minikube 以创建 pod、删除 pod 等

[英]How can I get configfile to access minikube from outside cluster to create pods, delete pods, etc

I am trying to setup Airflow to use an external k8s cluster, in local it is minikube, as executor.我正在尝试设置 Airflow 以使用外部 k8s 集群,在本地它是 minikube,作为执行程序。 To do that I need to point Airflow to a kubernetes configfile that contains the necessary information to alow external resources to request and schedule resources on the cluster, but for minikube I am not able to get, generate or know how to write that file, can anyone point me to some help?为此,我需要将 Airflow 指向一个 kubernetes 配置文件,其中包含允许外部资源请求和调度集群上资源的必要信息,但对于 minikube,我无法获取、生成或知道如何编写该文件,可以有人给我指点帮助吗? 0 comments 0 条评论

If you are running Airflow inside a K8S cluster (minikube or remote cluster), you don't need a configfile to access K8S API.如果您在 K8S 集群(minikube 或远程集群)内运行 Airflow,则无需配置文件即可访问configfile API。 You can configure the kubernetes connection to use the in_cluster option:您可以配置 kubernetes 连接以使用 in_cluster 选项:

AIRFLOW_CONN_KUBERNETES_DEFAULT=kubernetes://?extra__kubernetes__in_cluster=True&conn_id=kubernetes_default

If your are running Airflow in docker or directly in you host, and you want to access minikube to test KubernetesPodOperator , you can provide the config file by setting the config AIRFLOW__KUBERNETES__CONFIG_FILE .如果您在 docker 或直接在您的主机中运行 Airflow,并且您想访问 minikube 以测试KubernetesPodOperator ,您可以通过设置配置AIRFLOW__KUBERNETES__CONFIG_FILE来提供配置文件。
For the minikube config file, it's auto generated in ~/.kube/config but merged with the other config files, you can copy it to a new files, and remove the info of the other cluster and contexts (if you have other cluster).对于 minikube 配置文件,它是在~/.kube/config中自动生成的,但与其他配置文件合并,您可以将其复制到新文件,并删除其他集群和上下文的信息(如果您有其他集群) . If you don't find the minikube config, or you just want to regenerate a new one:如果您没有找到 minikube 配置,或者您只想重新生成一个新配置:

export KUBECONFIG=<path where you want to create it>
minikube start

Once minikube is up, you can find the config file in the folder you provided. minikube 启动后,您可以在您提供的文件夹中找到配置文件。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM