[jira] [Commented] (AIRFLOW-3282) Implement a Azure Kubernetes Service Operator
[ https://issues.apache.org/jira/browse/AIRFLOW-3282?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16712037#comment-16712037 ] ASF GitHub Bot commented on AIRFLOW-3282: - apraovjr opened a new pull request #4290: [AIRFLOW-3282] Azure Kubernetes Service Operator URL: https://github.com/apache/incubator-airflow/pull/4290 Add an operator to spin up azure kubernetes service. Azure Kubernetes Service is use to deploy a managed kubernetes cluster in Azure. Operator supports creating different AKS cluster.It checks whether there is already existing cluster if not creates one. ### Jira - [ ] My PR addresses the following [Airflow Jira](https://issues.apache.org/jira/browse/AIRFLOW/) issues and references them in the PR title. For example, "\[AIRFLOW-XXX\] My Airflow PR" - https://issues.apache.org/jira/browse/AIRFLOW-3282 - In case you are fixing a typo in the documentation you can prepend your commit with \[AIRFLOW-XXX\], code changes always need a Jira issue. ### Description - [ ] Here are some details about my PR, including screenshots of any UI changes: ### Tests - [ ] My PR adds the following unit tests __OR__ does not need testing for this extremely good reason: ### Commits - [ ] My commits all reference Jira issues in their subject lines, and I have squashed multiple commits if they address the same issue. In addition, my commits follow the guidelines from "[How to write a good git commit message](http://chris.beams.io/posts/git-commit/)": 1. Subject is separated from body by a blank line 1. Subject is limited to 50 characters (not including Jira issue reference) 1. Subject does not end with a period 1. Subject uses the imperative mood ("add", not "adding") 1. Body wraps at 72 characters 1. Body explains "what" and "why", not "how" ### Documentation - [ ] In case of new functionality, my PR adds documentation that describes how to use it. - When adding new operators/hooks/sensors, the autoclass documentation generation needs to be added. - All the public functions and the classes in the PR contain docstrings that explain what it does ### Code Quality - [ ] Passes `flake8` This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org > Implement a Azure Kubernetes Service Operator > - > > Key: AIRFLOW-3282 > URL: https://issues.apache.org/jira/browse/AIRFLOW-3282 > Project: Apache Airflow > Issue Type: New Feature >Reporter: Aparna >Assignee: Aparna >Priority: Major > > Add AKS Operator -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Commented] (AIRFLOW-3282) Implement a Azure Kubernetes Service Operator
[ https://issues.apache.org/jira/browse/AIRFLOW-3282?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16711845#comment-16711845 ] ASF GitHub Bot commented on AIRFLOW-3282: - apraovjr closed pull request #4288: [AIRFLOW-3282] Implement an Azure Kubernetes Service Operator URL: https://github.com/apache/incubator-airflow/pull/4288 This is a PR merged from a forked repository. As GitHub hides the original diff on merge, it is displayed below for the sake of provenance: As this is a foreign pull request (from a fork), the diff is supplied below (as it won't show otherwise due to GitHub magic): diff --git a/airflow/contrib/example_dags/example_azure_kubernetes_container_operator.py b/airflow/contrib/example_dags/example_azure_kubernetes_container_operator.py new file mode 100644 index 00..79fa5c5c16 --- /dev/null +++ b/airflow/contrib/example_dags/example_azure_kubernetes_container_operator.py @@ -0,0 +1,52 @@ +# -*- coding: utf-8 -*- +# +# 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 airflow import DAG +from airflow.contrib.operators.aks_operator import AzureKubernetesOperator +from datetime import datetime, timedelta + +seven_days_ago = datetime.combine(datetime.today() - timedelta(7), + datetime.min.time()) +default_args = { +'owner': 'airflow', +'depends_on_past': False, +'start_date': seven_days_ago, +'email': ['em...@microsoft.com'], +'email_on_failure': False, +'email_on_retry': False, +'retries': 1, +'retry_delay': timedelta(minutes=5), +} + +dag = DAG( +dag_id='aks_container', +default_args=default_args, +schedule_interval=None, +) + +start_aks_container = AzureKubernetesOperator( +task_id="start_aks_container", +ci_conn_id='azure_kubernetes_default', +resource_group="apraotest1", +name="akres1", +ssh_key_value=None, +dns_name_prefix=None, +location="eastus", +tags=None, +dag=dag) diff --git a/airflow/contrib/hooks/azure_kubernetes_hook.py b/airflow/contrib/hooks/azure_kubernetes_hook.py new file mode 100644 index 00..dfd9200f64 --- /dev/null +++ b/airflow/contrib/hooks/azure_kubernetes_hook.py @@ -0,0 +1,75 @@ +# -*- coding: utf-8 -*- +# +# Licensed 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. +# + +import os + +from airflow.hooks.base_hook import BaseHook +from airflow.exceptions import AirflowException + +from azure.common.credentials import ServicePrincipalCredentials +from azure.mgmt.containerservice import ContainerServiceClient +from azure.mgmt.resource import ResourceManagementClient +from airflow.contrib.utils.aks_utils import load_json + + +class AzureKubernetesServiceHook(BaseHook): + +def __init__(self, conn_id=None): +self.conn_id = conn_id +self.connection = self.get_conn() +self.configData = None +self.credentials = None +self.subscription_id = None +self.clientId = None +self.clientSecret = None + +def get_conn(self): +if self.conn_id: +conn = self.get_connection(self.conn_id) +key_path = conn.extra_dejson.get('key_path', False) +if key_path: +if key_path.endswith('.json'): +self.log.info('Getting connection using a JSON key file.') + +self.configData = load_json(self, key_path) +else: +raise AirflowException('Unrecognised extension for key file.') + +if os.environ.get('AZURE_AUTH_LOCATION'): +key_path = os.environ.get('AZURE_AUTH_LOCATION') +if key_path.endswith('.json'): +self.log.info('Getting
[jira] [Commented] (AIRFLOW-3282) Implement a Azure Kubernetes Service Operator
[ https://issues.apache.org/jira/browse/AIRFLOW-3282?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16711853#comment-16711853 ] ASF GitHub Bot commented on AIRFLOW-3282: - apraovjr closed pull request #4288: [AIRFLOW-3282] Implement an Azure Kubernetes Service Operator URL: https://github.com/apache/incubator-airflow/pull/4288 This is a PR merged from a forked repository. As GitHub hides the original diff on merge, it is displayed below for the sake of provenance: As this is a foreign pull request (from a fork), the diff is supplied below (as it won't show otherwise due to GitHub magic): diff --git a/airflow/contrib/example_dags/example_azure_kubernetes_container_operator.py b/airflow/contrib/example_dags/example_azure_kubernetes_container_operator.py new file mode 100644 index 00..79fa5c5c16 --- /dev/null +++ b/airflow/contrib/example_dags/example_azure_kubernetes_container_operator.py @@ -0,0 +1,52 @@ +# -*- coding: utf-8 -*- +# +# 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 airflow import DAG +from airflow.contrib.operators.aks_operator import AzureKubernetesOperator +from datetime import datetime, timedelta + +seven_days_ago = datetime.combine(datetime.today() - timedelta(7), + datetime.min.time()) +default_args = { +'owner': 'airflow', +'depends_on_past': False, +'start_date': seven_days_ago, +'email': ['em...@microsoft.com'], +'email_on_failure': False, +'email_on_retry': False, +'retries': 1, +'retry_delay': timedelta(minutes=5), +} + +dag = DAG( +dag_id='aks_container', +default_args=default_args, +schedule_interval=None, +) + +start_aks_container = AzureKubernetesOperator( +task_id="start_aks_container", +ci_conn_id='azure_kubernetes_default', +resource_group="apraotest1", +name="akres1", +ssh_key_value=None, +dns_name_prefix=None, +location="eastus", +tags=None, +dag=dag) diff --git a/airflow/contrib/hooks/azure_kubernetes_hook.py b/airflow/contrib/hooks/azure_kubernetes_hook.py new file mode 100644 index 00..dfd9200f64 --- /dev/null +++ b/airflow/contrib/hooks/azure_kubernetes_hook.py @@ -0,0 +1,75 @@ +# -*- coding: utf-8 -*- +# +# Licensed 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. +# + +import os + +from airflow.hooks.base_hook import BaseHook +from airflow.exceptions import AirflowException + +from azure.common.credentials import ServicePrincipalCredentials +from azure.mgmt.containerservice import ContainerServiceClient +from azure.mgmt.resource import ResourceManagementClient +from airflow.contrib.utils.aks_utils import load_json + + +class AzureKubernetesServiceHook(BaseHook): + +def __init__(self, conn_id=None): +self.conn_id = conn_id +self.connection = self.get_conn() +self.configData = None +self.credentials = None +self.subscription_id = None +self.clientId = None +self.clientSecret = None + +def get_conn(self): +if self.conn_id: +conn = self.get_connection(self.conn_id) +key_path = conn.extra_dejson.get('key_path', False) +if key_path: +if key_path.endswith('.json'): +self.log.info('Getting connection using a JSON key file.') + +self.configData = load_json(self, key_path) +else: +raise AirflowException('Unrecognised extension for key file.') + +if os.environ.get('AZURE_AUTH_LOCATION'): +key_path = os.environ.get('AZURE_AUTH_LOCATION') +if key_path.endswith('.json'): +self.log.info('Getting
[jira] [Commented] (AIRFLOW-3282) Implement a Azure Kubernetes Service Operator
[ https://issues.apache.org/jira/browse/AIRFLOW-3282?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16711851#comment-16711851 ] ASF GitHub Bot commented on AIRFLOW-3282: - apraovjr opened a new pull request #4288: [AIRFLOW-3282] Implement an Azure Kubernetes Service Operator URL: https://github.com/apache/incubator-airflow/pull/4288 Add an operator to spin up azure kubernetes service. Azure Kubernetes Service is use to deploy a managed kubernetes cluster in Azure. Operator supports creating different AKS cluster.It checks whether there is already existing cluster if not creates one. ### Jira - [x] My PR addresses the following [Airflow Jira](https://issues.apache.org/jira/browse/AIRFLOW/) issues and references them in the PR title. For example, "\[AIRFLOW-XXX\] My Airflow PR" - https://issues.apache.org/jira/browse/AIRFLOW-3282 - In case you are fixing a typo in the documentation you can prepend your commit with \[AIRFLOW-XXX\], code changes always need a Jira issue. ### Description - [x] Here are some details about my PR, including screenshots of any UI changes: ### Tests - [x] My PR adds the following unit tests __OR__ does not need testing for this extremely good reason: ### Commits - [x] My commits all reference Jira issues in their subject lines, and I have squashed multiple commits if they address the same issue. In addition, my commits follow the guidelines from "[How to write a good git commit message](http://chris.beams.io/posts/git-commit/)": 1. Subject is separated from body by a blank line 1. Subject is limited to 50 characters (not including Jira issue reference) 1. Subject does not end with a period 1. Subject uses the imperative mood ("add", not "adding") 1. Body wraps at 72 characters 1. Body explains "what" and "why", not "how" ### Documentation - [x] In case of new functionality, my PR adds documentation that describes how to use it. - When adding new operators/hooks/sensors, the autoclass documentation generation needs to be added. - All the public functions and the classes in the PR contain docstrings that explain what it does ### Code Quality - [x] Passes `flake8` This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org > Implement a Azure Kubernetes Service Operator > - > > Key: AIRFLOW-3282 > URL: https://issues.apache.org/jira/browse/AIRFLOW-3282 > Project: Apache Airflow > Issue Type: New Feature >Reporter: Aparna >Assignee: Aparna >Priority: Major > > Add AKS Operator -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Commented] (AIRFLOW-3282) Implement a Azure Kubernetes Service Operator
[ https://issues.apache.org/jira/browse/AIRFLOW-3282?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16711840#comment-16711840 ] ASF GitHub Bot commented on AIRFLOW-3282: - apraovjr opened a new pull request #4288: [AIRFLOW-3282] Implement an Azure Kubernetes Service Operator URL: https://github.com/apache/incubator-airflow/pull/4288 Add an operator to spin up azure kubernetes service. Azure Kubernetes Service is use to deploy a managed kubernetes cluster in Azure. Operator supports creating different AKS cluster.It checks whether there is already existing cluster if not creates one. ### Jira - [ ] My PR addresses the following [Airflow Jira](https://issues.apache.org/jira/browse/AIRFLOW/) issues and references them in the PR title. For example, "\[AIRFLOW-XXX\] My Airflow PR" - https://issues.apache.org/jira/browse/AIRFLOW-3282 - In case you are fixing a typo in the documentation you can prepend your commit with \[AIRFLOW-XXX\], code changes always need a Jira issue. ### Description - [ ] Here are some details about my PR, including screenshots of any UI changes: ### Tests - [ ] My PR adds the following unit tests __OR__ does not need testing for this extremely good reason: ### Commits - [ ] My commits all reference Jira issues in their subject lines, and I have squashed multiple commits if they address the same issue. In addition, my commits follow the guidelines from "[How to write a good git commit message](http://chris.beams.io/posts/git-commit/)": 1. Subject is separated from body by a blank line 1. Subject is limited to 50 characters (not including Jira issue reference) 1. Subject does not end with a period 1. Subject uses the imperative mood ("add", not "adding") 1. Body wraps at 72 characters 1. Body explains "what" and "why", not "how" ### Documentation - [ ] In case of new functionality, my PR adds documentation that describes how to use it. - When adding new operators/hooks/sensors, the autoclass documentation generation needs to be added. - All the public functions and the classes in the PR contain docstrings that explain what it does ### Code Quality - [ ] Passes `flake8` This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org > Implement a Azure Kubernetes Service Operator > - > > Key: AIRFLOW-3282 > URL: https://issues.apache.org/jira/browse/AIRFLOW-3282 > Project: Apache Airflow > Issue Type: New Feature >Reporter: Aparna >Assignee: Aparna >Priority: Major > > Add AKS Operator -- This message was sent by Atlassian JIRA (v7.6.3#76005)