Source code for airflow.providers.apache.flink.operators.flink_kubernetes
## Licensed to the Apache Software Foundation (ASF) under one# or more contributor license agreements. See the NOTICE file# distributed with this work for additional information# regarding copyright ownership. The ASF licenses this file# to you under the Apache License, Version 2.0 (the# "License"); you may not use this file except in compliance# with the License. You may obtain a copy of the License at## http://www.apache.org/licenses/LICENSE-2.0## Unless required by applicable law or agreed to in writing,# software distributed under the License is distributed on an# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY# KIND, either express or implied. See the License for the# specific language governing permissions and limitations# under the License.from__future__importannotationsfromfunctoolsimportcached_propertyfromtypingimportTYPE_CHECKING,Sequencefromairflow.modelsimportBaseOperatorfromairflow.providers.cncf.kubernetes.hooks.kubernetesimportKubernetesHookifTYPE_CHECKING:fromkubernetes.clientimportCoreV1Apifromairflow.utils.contextimportContext
[docs]classFlinkKubernetesOperator(BaseOperator):""" Creates flinkDeployment object in kubernetes cluster. .. seealso:: For more information on how to use this operator, take a look at the guide: :ref:`howto/operator:FlinkKubernetesOperator` .. seealso:: For more detail about Flink Deployment Object have a look at the reference: https://nightlies.apache.org/flink/flink-kubernetes-operator-docs-main/docs/custom-resource/reference/#flinkdeployment :param application_file: Defines Kubernetes 'custom_resource_definition' of 'flinkDeployment' as either a path to a '.yaml' file, '.json' file, YAML string or JSON string. :param namespace: kubernetes namespace to put flinkDeployment :param kubernetes_conn_id: The :ref:`kubernetes connection id <howto/connection:kubernetes>` for the to Kubernetes cluster. :param api_group: kubernetes api group of flinkDeployment :param api_version: kubernetes api version of flinkDeployment :param in_cluster: run kubernetes client with in_cluster configuration. :param cluster_context: context that points to kubernetes cluster. Ignored when in_cluster is True. If None, current-context is used. :param config_file: The path to the Kubernetes config file. (templated) If not specified, default value is ``~/.kube/config`` """
[docs]defexecute(self,context:Context):self.log.info("Creating flinkApplication with Context: %s and op_context: %s",self.cluster_context,context)self.hook.custom_object_client.list_cluster_custom_object(group=self.api_group,version=self.api_version,plural=self.plural)self.log.info("body=self.application_file: %s",self.application_file)response=self.hook.create_custom_object(group=self.api_group,version=self.api_version,plural=self.plural,body=self.application_file,namespace=self.namespace,)returnresponse