├── .gitignore ├── LICENSE ├── Makefile ├── README.md ├── components └── kubeflow-profile │ ├── .gitignore │ ├── deploy.sh │ ├── hub-component.yaml │ ├── namespace.yaml.template │ ├── profile.yaml.template │ └── undeploy.sh ├── docs └── QUICK_START.md ├── etc ├── eks-cluster.yaml ├── kubeflow_components.png └── quick-start.sh ├── hub.yaml └── params.yaml /.gitignore: -------------------------------------------------------------------------------- 1 | .env 2 | *.bubble 3 | *.env 4 | *.kubeconfig 5 | *.state 6 | *.elaborate 7 | .kubeconfig.eksctl.lock 8 | *.bak 9 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "[]" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright [yyyy] [name of copyright owner] 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | .DEFAULT_GOAL := deploy 2 | 3 | export NAME ?= ml 4 | export DOMAIN_NAME ?= dev.cloud-account-name.superhub.io 5 | 6 | STATE_BUCKET ?= agilestacks.cloud-account-name.superhub.io 7 | STATE_REGION ?= us-east-2 8 | 9 | # CLI mode parameters compatibility 10 | export HUB_STACK_NAME := $(NAME) 11 | export HUB_DOMAIN_NAME := $(DOMAIN_NAME) 12 | export HUB_STATE_BUCKET := $(STATE_BUCKET) 13 | export HUB_STATE_REGION := $(STATE_REGION) 14 | 15 | STACK_NAME ?= ml 16 | 17 | STORAGE_KIND ?= s3 18 | STATE_CONTAINER ?= agilestacks 19 | 20 | STATE_PATH := $(DOMAIN_NAME)/hub/$(STACK_NAME)-$(NAME)/hub 21 | ELABORATE_FILE_FS := hub.yaml.elaborate 22 | ifeq (az,$(STORAGE_KIND)) 23 | ELABORATE_FILE_CLOUD := $(STORAGE_KIND)://$(STATE_BUCKET)/$(STATE_CONTAINER)/$(STATE_PATH).elaborate 24 | else 25 | ELABORATE_FILE_CLOUD := $(STORAGE_KIND)://$(STATE_BUCKET)/$(STATE_PATH).elaborate 26 | endif 27 | ELABORATE_FILES := $(ELABORATE_FILE_FS),$(ELABORATE_FILE_CLOUD) 28 | 29 | STATE_FILE_FS := hub.yaml.state 30 | ifeq (az,$(STORAGE_KIND)) 31 | STATE_FILE_CLOUD := $(STORAGE_KIND)://$(STATE_BUCKET)/$(STATE_CONTAINER)/$(STATE_PATH).state 32 | else 33 | STATE_FILE_CLOUD := $(STORAGE_KIND)://$(STATE_BUCKET)/$(STATE_PATH).state 34 | endif 35 | STATE_FILES := $(STATE_FILE_FS),$(STATE_FILE_CLOUD) 36 | 37 | TEMPLATE_PARAMS ?= params/template.yaml 38 | STACK_PARAMS ?= params/$(DOMAIN_NAME).yaml 39 | 40 | PLATFORM_PROVIDES += aws-marketplace 41 | PLATFORM_STATE_FILES ?= 42 | 43 | COMPONENT := 44 | VERB := 45 | 46 | RESTORE_BUNDLE_FILE ?= restore-bundles/$(DOMAIN_NAME).yaml 47 | RESTORE_PARAMS_FILE ?= restore-params.yaml 48 | 49 | HUB_OPTS ?= 50 | 51 | hub ?= hub -d 52 | aws ?= aws --region $(STATE_REGION) 53 | gsutil ?= gsutil 54 | az ?= az 55 | 56 | space := 57 | space += 58 | comma := , 59 | 60 | ifdef HUB_TOKEN 61 | ifdef HUB_ENVIRONMENT 62 | ifdef HUB_STACK_INSTANCE 63 | HUB_LIFECYCLE_OPTS ?= --hub-environment "$(HUB_ENVIRONMENT)" --hub-stack-instance "$(HUB_STACK_INSTANCE)" \ 64 | --hub-sync --hub-sync-skip-parameters-and-oplog 65 | endif 66 | endif 67 | endif 68 | 69 | ifeq (,$(wildcard $(RESTORE_BUNDLE_FILE))) 70 | $(RESTORE_PARAMS_FILE): 71 | @echo --- > $(RESTORE_PARAMS_FILE) 72 | else 73 | $(RESTORE_PARAMS_FILE): $(RESTORE_BUNDLE_FILE) 74 | $(hub) backup unbundle $(RESTORE_BUNDLE_FILE) -o $(RESTORE_PARAMS_FILE) 75 | endif 76 | 77 | $(ELABORATE_FILE_FS): hub.yaml $(TEMPLATE_PARAMS) $(STACK_PARAMS) $(RESTORE_PARAMS_FILE) params.yaml pull 78 | $(hub) elaborate \ 79 | hub.yaml params.yaml $(TEMPLATE_PARAMS) $(STACK_PARAMS) $(RESTORE_PARAMS_FILE) \ 80 | $(if $(PLATFORM_PROVIDES),-p $(subst $(space),$(comma),$(PLATFORM_PROVIDES)),) \ 81 | $(if $(PLATFORM_STATE_FILES),-s $(PLATFORM_STATE_FILES),) \ 82 | $(HUB_OPTS) \ 83 | -o $(ELABORATE_FILES) 84 | 85 | elaborate: 86 | -rm -f $(ELABORATE_FILE_FS) 87 | $(MAKE) $(ELABORATE_FILE_FS) 88 | .PHONY: elaborate 89 | 90 | pull: 91 | $(hub) pull hub.yaml 92 | .PHONY: pull 93 | 94 | explain: 95 | $(hub) explain $(ELABORATE_FILES) $(STATE_FILES) $(HUB_OPTS) --color -r | less -R 96 | .PHONY: explain 97 | 98 | ifneq ($(PLATFORM_STATE_FILES),) 99 | kubeconfig: 100 | $(hub) kubeconfig --switch-kube-context $(HUB_OPTS) $(PLATFORM_STATE_FILES) 101 | .PHONY: kubeconfig 102 | endif 103 | 104 | COMPONENT_LIST := $(if $(COMPONENT),-c $(COMPONENT),) 105 | 106 | deploy: $(ELABORATE_FILE_FS) 107 | $(hub) deploy $(ELABORATE_FILES) -s $(STATE_FILES) $(HUB_LIFECYCLE_OPTS) $(HUB_OPTS) \ 108 | $(COMPONENT_LIST) 109 | .PHONY: deploy 110 | 111 | undeploy: $(ELABORATE_FILE_FS) 112 | $(hub) --force undeploy $(ELABORATE_FILES) -s $(STATE_FILES) $(HUB_LIFECYCLE_OPTS) $(HUB_OPTS) \ 113 | $(COMPONENT_LIST) 114 | .PHONY: undeploy 115 | 116 | sync: 117 | $(hub) api instance sync $(if $(PLATFORM_STATE_FILES),$(NAME)@,)$(DOMAIN_NAME) \ 118 | -s $(STATE_FILES) $(HUB_OPTS) 119 | .PHONY: sync 120 | 121 | ifneq ($(COMPONENT),) 122 | invoke: $(ELABORATE_FILE_FS) 123 | $(eval , := ,) 124 | $(eval WORDS := $(subst $(,), ,$(COMPONENT))) 125 | @$(foreach c,$(WORDS), \ 126 | $(hub) invoke $(c) $(VERB) -m $(ELABORATE_FILES) -s $(STATE_FILES) $(HUB_OPTS);) 127 | .PHONY: invoke 128 | endif 129 | 130 | backup: $(ELABORATE_FILE_FS) 131 | $(hub) backup create --json $(ELABORATE_FILES) -s $(STATE_FILES) -o "$(BACKUP_BUNDLE_FILE)" -c "$(COMPONENTS)" 132 | @echo '--- backup bundle' 133 | @zcat $(BACKUP_BUNDLE_FILE) 134 | @echo 135 | .PHONY: backup 136 | 137 | remove_s3_state: 138 | -$(aws) s3 rm $(STATE_FILE_CLOUD) 139 | .PHONY: remove_s3_state 140 | 141 | remove_gs_state: 142 | -$(gsutil) rm $(STATE_FILE_CLOUD) 143 | .PHONY: remove_gs_state 144 | 145 | remove_az_state: 146 | -$(az) storage blob delete --account-name $(STATE_BUCKET) --container-name $(STATE_CONTAINER) --name $(STATE_PATH) 147 | .PHONY: remove_az_state 148 | 149 | clean: remove_$(STORAGE_KIND)_state 150 | @rm -f hub.yaml.state hub.yaml.elaborate 151 | .PHONY: clean 152 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # ML Stack on EKS 2 | 3 | ML Stack is designed to simplify the deployment of [Kubeflow](https://github.com/kubeflow) and additional components on AWS EKS. It supports the full lifecycle of machine learning projects: data preparation, model development, training, serving, and monitoring. ML Stack is providing essential tools to improve productivity of data scientists, while making it easy for operations to deploy and scale machine learning applications in production. 4 | 5 | ## ML Stack Components 6 | 7 | ML Stack provides an open-source machine learning platform that supports the full lifecycle of an ML application — from data preparation and model training to model deployment in production. With Kubernetes under the hood, it’s a powerful toolset that can make Data Scientists and Data Engineers life easier. ML Stacks is based on [Kubeflow](https://github.com/kubeflow) and additional components: external DNS, SSL certificate manager, Istio service mesh, S3 flex storage driver. 8 | ![Components](/etc/kubeflow_components.png) 9 | 10 | ## Installation 11 | 12 | This repository provides a customizable GitOps stack template, which allows to deploy the entire Kubeflow platform with a few simple commands. It allows to simplify, automate, and standardize Kubeflow deployments. GitOps is defined as a way of managing cloud infrastructure and applications, using Git repository to hold declarative definition of infrastructure. You can use the following steps to deploy Kubeflow on an existing EKS cluster, or create a new EKS cluster for Kubeflow. 13 | 14 | 1. Intall Hub CLI 15 | 16 | Hub CLI is an open source GitOps tool for automating deployment of customizable stacks created with Terraform, CloudFormation, Helm, and other infrastructure as code. 17 | To install Hub CLI on your workstation please follow the steps documented [here](https://superhub.io) 18 | 19 | 2. Create an EKS cluster 20 | 21 | If you have an existing EKS cluster, then use the following example command to configure EKS cluster context: 22 | ```bash 23 | $ aws eks --region us-west-2 update-kubeconfig --name cluster-name 24 | ``` 25 | 26 | The following command will create a new EKS cluster with a custom name: 27 | 28 | ```bash 29 | $ export STACK_NAME="my-cluster" 30 | $ cat etc/eks-cluster.yaml | sed -e "s/happy-cluster/$STACK_NAME/g" | eksctl create cluster -f - 31 | ``` 32 | 33 | 3. Attach sufficient IAM security policies 34 | 35 | By default, the cluster is provisioned with a minimum set of permissions required to perform most common tasks. If you need to add more AWS permissions for the cluster, you can attach additional IAM policies. Use the following command as an example for adding standard IAM policies to your cluster: 36 | 37 | ``` 38 | $ hub ext eks policy attach \ 39 | --cluster "$STACK_NAME" \ 40 | --policy "AmazonS3FullAccess" \ 41 | --aws-region us-west-2 42 | 43 | ``` 44 | 45 | 4. Configure environment for deploying Kubeflow in the current directory: 46 | 47 | ```bash 48 | $ hub configure -f https://raw.githubusercontent.com/agilestacks/stack-ml-eks/master/hub.yaml 49 | ``` 50 | 51 | This command will use your current kubeconfig context (defined by `eksctl`), generate the necessary configuration and store it in an environment file (`.env` points to current active configuration) 52 | 53 | * Generate a unique domain name (valid for 72 hours unless refreshed with `hub configure` command) 54 | * Domain name refresh key (a token that authorizes DNS domain name refresh) 55 | * Definition of AWS configuration (S3 bucket to store deployment state) 56 | 57 | The obtained DNS subdomain (of `bubble.superhub.io`) is valid for 72 hours. To renew the DNS lease, please re-run `hub configure -r aws --dns-update` every other day. Contact `support@agilestacks.com` for non-expiring DNS domain. 58 | 59 | ML Stack will configure a user/password authentication. During `hub configure` step you will be asked to define a user name and password. Your password will be stored in `.env` file and should not be committed to the git repository. If you want to change the password later, you can modify this value in `.env` file directly. If you prefer to use a randomly generated password, then leave the value empty when prompted to enter a password. 60 | 61 | 5. Deploy the stack 62 | 63 | ```bash 64 | $ hub stack deploy 65 | ``` 66 | 67 | ## Access the Kubeflow user interface (UI) 68 | You can find the URL of deployed Kubeflow Dashboard using the `hub show` command with parameter `component.kubeflow.url`: 69 | ```bash 70 | $ hub show -q '.parameters.component.kubeflow.url' 71 | "https://kubeflow.grandiose-teobaldo-556.bubble.superhub.io/" 72 | ``` 73 | Note: `hub show` will return values of all stack parameters. 74 | 75 | ## Verify Kubeflow Deployment 76 | 77 | Congratulations, you have just deployed Kubeflow! To make sure that all Kubeflow services are running as expected, you can use the following Kubeflow example: [MNIST Example](https://github.com/kubeflow/examples/tree/master/mnist) 78 | 79 | 1. Launch a Jupyter notebook 80 | 81 | The tutorial has been tested using the Jupyter Tensorflow 1.15 image. 82 | 83 | Launch a terminal in Jupyter and clone the kubeflow examples repo: 84 | 85 | ``` 86 | git clone https://github.com/kubeflow/examples.git git_kubeflow-examples 87 | ``` 88 | 89 | 2. Open the notebook mnist/mnist_aws.ipynb 90 | 91 | 3. Follow the notebook to train and deploy MNIST model on Kubeflow 92 | 93 | 94 | ## Additional Options 95 | 96 | ### Redeploy one or more components 97 | 98 | Redeploy one or more compomnents. The following commands will redeploy two stack components: `istio` and `prometheus` 99 | 100 | ```bash 101 | $ hub stack undeploy -c istio,prometheus 102 | $ hub stack deploy -c istio,prometheus 103 | ``` 104 | 105 | ### Deploy all components starting from the pre-deployed component 106 | 107 | Deploy the specified component and all subsequent components in the stack runlist. 108 | 109 | ```bash 110 | $ hub stack deploy -o istio 111 | ``` 112 | 113 | ## Tear Down 114 | 115 | If you have used a default name to setup your cluster then you can use the following command to undeploy the entire stack: 116 | 117 | ```bash 118 | $ hub stack undeploy 119 | $ hub ext eks policy detach --cluster $STACK_NAME --all 120 | $ eksctl delete cluster -f etc/eks-cluster.yaml 121 | ``` 122 | 123 | Otherwise, use the following command if the stack name was configured with variable `STACK_NAME`: 124 | 125 | ```bash 126 | $ eksctl delete cluster --name="$STACK_NAME" 127 | ``` 128 | -------------------------------------------------------------------------------- /components/kubeflow-profile/.gitignore: -------------------------------------------------------------------------------- 1 | /profile.yaml 2 | /namespace.yaml 3 | -------------------------------------------------------------------------------- /components/kubeflow-profile/deploy.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | KUBECTL="kubectl --context=$HUB_DOMAIN_NAME" 4 | 5 | $KUBECTL get -f profile.yaml 2>/dev/null \ 6 | || $KUBECTL apply -f profile.yaml 7 | 8 | $KUBECTL get namespace "$PROFILE" 2>/dev/null \ 9 | || $KUBECTL apply --validate=false -f namespace.yaml 10 | -------------------------------------------------------------------------------- /components/kubeflow-profile/hub-component.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | version: 1 3 | kind: component 4 | meta: 5 | name: kubeflow-profile 6 | title: Kubeflow Namespace 7 | brief: Machine learning 8 | description: Creates a namespace (user profile) for a kubeflow user 9 | category: AI and Machine Learning 10 | version: 1.0.2 11 | maturity: alpha 12 | licence: Apache 2.0 13 | source: 14 | dir: ../../components/kubeflow-v1.0 15 | 16 | requires: 17 | - kubernetes 18 | 19 | parameters: 20 | - name: dns.domain 21 | env: HUB_DOMAIN_NAME 22 | - name: component.dex.passwordDb.email 23 | empty: allow 24 | - name: component.kubeflow 25 | parameters: 26 | - name: profile.name 27 | value: workspace 28 | env: PROFILE 29 | - name: profile.owner.username 30 | value: ${component.dex.passwordDb.email} 31 | - name: namespace 32 | value: kubeflow 33 | 34 | outputs: [] 35 | 36 | templates: 37 | files: 38 | - "*.template" 39 | -------------------------------------------------------------------------------- /components/kubeflow-profile/namespace.yaml.template: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: Namespace 3 | metadata: 4 | name: ${component.kubeflow.profile.name} 5 | annotations: 6 | owner: ${component.kubeflow.profile.owner.username} 7 | labels: 8 | istio-injection: enabled 9 | katib-metricscollector-injection: enabled 10 | serving.kubeflow.org/inferenceservice: enabled 11 | ownerReferences: 12 | - apiVersion: "kubeflow.org/v1" 13 | blockOwnerDeletion: true 14 | controller: true 15 | kind: Profile 16 | name: ${component.kubeflow.profile.name} 17 | -------------------------------------------------------------------------------- /components/kubeflow-profile/profile.yaml.template: -------------------------------------------------------------------------------- 1 | apiVersion: kubeflow.org/v1 2 | kind: Profile 3 | metadata: 4 | name: ${component.kubeflow.profile.name} 5 | finalizers: 6 | - profile-finalizez 7 | spec: 8 | owner: 9 | kind: User 10 | name: ${component.kubeflow.profile.owner.username} 11 | resourceQuotaSpec: {} 12 | -------------------------------------------------------------------------------- /components/kubeflow-profile/undeploy.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash -e 2 | 3 | KUBECTL="kubectl --context=$HUB_DOMAIN_NAME" 4 | KUBECTL_DELETE="$KUBECTL -n "$PROFILE" delete --all" 5 | UNWANTED="namespace events endpoints bindings " 6 | UNWANTED="localsubjectaccessreviews.authorization.k8s.io $UNWANTED" 7 | # profiles is a cluster level resource 8 | # UNWANTED="profiles.kubeflow.org $UNWANTED" 9 | 10 | echo "Cleaning up dangling resources in $PROFILE namespace..." 11 | 12 | if test -z "$(which parallel)"; then 13 | echo "Warning: parallel cannot be found" 14 | echo "parallel will make clean up faster" 15 | else 16 | KUBECTL_DELETE="parallel -j 15 $KUBECTL_DELETE" 17 | fi 18 | 19 | for R in $($KUBECTL api-resources --namespaced=true -o name); do 20 | if grep -q "$R" <<< "$UNWANTED"; then 21 | continue 22 | fi 23 | echo "Deleting $R..." 24 | $KUBECTL_DELETE "$R" 25 | done 26 | 27 | if $KUBECTL get "profiles.kubeflow.org" "$PROFILE" > /dev/null 2>&1; then 28 | $KUBECTL get "profiles.kubeflow.org" "$PROFILE" -o json \ 29 | | jq '. | del(.metadata.finalizers) | del(.spec.finalizers)' \ 30 | | $KUBECTL replace -f - 31 | $KUBECTL delete -f "profile.yaml" 32 | fi 33 | 34 | $KUBECTL get namespace "$PROFILE" > /dev/null 2>&1 && exit 35 | $KUBECTL get namespace "$PROFILE" -o json \ 36 | | jq '. | del(.spec.finalizers)' \ 37 | | $KUBECTL replace --raw "/api/v1/namespaces/$PROFILE/finalize" -f - ; \ 38 | 39 | $KUBECTL delete namespace "$PROFILE" 40 | -------------------------------------------------------------------------------- /docs/QUICK_START.md: -------------------------------------------------------------------------------- 1 | # Quick Start Script 2 | 3 | In this brief document you will all the commands required to provision a Kubernetes cluster, deploy Kubeflow using a simple `hub stack deploy` command, and when you are done you can delete cloud resources 4 | 5 | ### Example script to deploy a custom stack from Git 6 | ``` 7 | mkdir -p mystack 8 | cd mystack 9 | ``` 10 | ### Download config file for EKS cluster 11 | ``` 12 | wget https://raw.githubusercontent.com/agilestacks/stack-ml-eks/master/etc/eks-cluster.yaml 13 | ``` 14 | ### Set EKS cluster name 15 | ``` 16 | export STACK_NAME="kf1" 17 | ``` 18 | ### Create EKS cluster in the current AWS account 19 | ``` 20 | cat eks-cluster.yaml | sed -e "s/happy-cluster/$STACK_NAME/g" | eksctl create cluster -f - 21 | ``` 22 | #### Configure environment for deploying Kubeflow stack and download all required files to the current directory 23 | ``` 24 | hub configure -f "https://raw.githubusercontent.com/agilestacks/stack-ml-eks/master/hub.yaml" 25 | ``` 26 | #### Deploy Kubeflow stack to the EKS cluster 27 | ``` 28 | hub stack deploy 29 | ``` 30 | ### Optional undeploy step - uncomment the following line to delete EKS cluster and cleanup AWS resources 31 | ``` 32 | cat eks-cluster.yaml | sed -e "s/happy-cluster/$STACK_NAME/g" | eksctl delete cluster -f - 33 | ``` 34 | -------------------------------------------------------------------------------- /etc/eks-cluster.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: eksctl.io/v1alpha5 2 | kind: ClusterConfig 3 | 4 | metadata: 5 | name: happy-cluster 6 | region: us-west-2 7 | version: "1.16" 8 | 9 | availabilityZones: 10 | - us-west-2a 11 | - us-west-2b 12 | - us-west-2c 13 | 14 | nodeGroups: 15 | - name: workers 16 | minSize: 3 17 | maxSize: 5 18 | instancesDistribution: 19 | instanceTypes: 20 | - m5.xlarge 21 | - r4.xlarge 22 | - r3.xlarge 23 | - t3.xlarge 24 | - t2.xlarge 25 | maxPrice: 1.0 26 | spotInstancePools: 2 27 | onDemandBaseCapacity: 0 28 | onDemandPercentageAboveBaseCapacity: 0 29 | volumeSize: 100 30 | volumeType: gp2 31 | ssh: 32 | allow: false 33 | # to override public key 34 | # publicKeyPath: ~/.ssh/id_rsa.pub 35 | tags: 36 | k8s.io/cluster-autoscaler/enabled: "true" 37 | k8s.io/cluster-autoscaler/happy-cluster: "owned" 38 | iam: 39 | # User notebook policy 40 | # This is often needed by data scientists 41 | # Who stores data in s3 and need quite powerful access 42 | # And pushes intermediate containers for distributed training to ECR 43 | attachPolicyARNs: 44 | - arn:aws:iam::aws:policy/AmazonEKSWorkerNodePolicy 45 | - arn:aws:iam::aws:policy/AmazonEKS_CNI_Policy 46 | # TODO: better if user will run: 47 | # hub ext eks policy attach -p AmazonS3FullAccess 48 | # hub ext eks policy attach -p AmazonEC2ContainerRegistryFullAccess 49 | - arn:aws:iam::aws:policy/AmazonS3FullAccess 50 | - arn:aws:iam::aws:policy/AmazonEC2ContainerRegistryFullAccess 51 | withAddonPolicies: 52 | albIngress: true 53 | autoScaler: true 54 | cloudWatch: true 55 | certManager: true 56 | externalDNS: true 57 | # ebs: true 58 | 59 | iam: 60 | withOIDC: true 61 | serviceAccounts: 62 | - metadata: 63 | name: happy-cluster 64 | namespace: kube-system 65 | labels: {aws-usage: "cluster-ops"} 66 | attachPolicy: # inline policy can be defined along with `attachPolicyARNs` 67 | Version: "2012-10-17" 68 | Statement: 69 | - Effect: Allow 70 | Action: 71 | - "autoscaling:DescribeAutoScalingGroups" 72 | - "autoscaling:DescribeAutoScalingInstances" 73 | - "autoscaling:DescribeLaunchConfigurations" 74 | - "autoscaling:DescribeTags" 75 | - "autoscaling:SetDesiredCapacity" 76 | - "autoscaling:TerminateInstanceInAutoScalingGroup" 77 | # for external-dns 78 | - "route53:ChangeResourceRecordSets" 79 | - "route53:ListHostedZones" 80 | - "route53:ListResourceRecordSets" 81 | # read-write to s3 (hub or terraform state) 82 | - "s3:ListBucket" 83 | - "s3:*Object" 84 | # Reserved for future OIDC integration 85 | # - "sts:AssumeRoleWithWebIdentity" 86 | Resource: '*' 87 | 88 | cloudWatch: 89 | clusterLogging: 90 | enableTypes: [audit, authenticator, controllerManager] 91 | -------------------------------------------------------------------------------- /etc/kubeflow_components.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/agilestacks/stack-ml-eks/d6051650423f8db0f3f61d13303998af1a688d59/etc/kubeflow_components.png -------------------------------------------------------------------------------- /etc/quick-start.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # Example script to deploy a custom stack from Git 3 | mkdir -p mystack 4 | cd mystack 5 | # Download config file for EKS cluster 6 | wget https://raw.githubusercontent.com/agilestacks/stack-ml-eks/master/etc/eks-cluster.yaml 7 | # Set EKS cluster name 8 | export STACK_NAME="kf1" 9 | # Create EKS cluster in the current AWS account 10 | cat eks-cluster.yaml | sed -e "s/happy-cluster/$STACK_NAME/g" | eksctl create cluster -f - 11 | # Configure environment for deploying Kubeflow stack and download all required files to the current directory 12 | hub configure -f "https://raw.githubusercontent.com/agilestacks/stack-ml-eks/master/hub.yaml" 13 | # Deploy Kubeflow stack to the EKS cluster 14 | hub stack deploy 15 | # Optional undeploy step - uncomment the following line to delete EKS cluster and cleanup AWS resources 16 | # cat eks-cluster.yaml | sed -e "s/happy-cluster/$STACK_NAME/g" | eksctl delete cluster -f - 17 | -------------------------------------------------------------------------------- /hub.yaml: -------------------------------------------------------------------------------- 1 | version: 1 2 | kind: stack 3 | meta: 4 | name: Machine Learning stack 5 | brief: Stack that contains Kubeflow and ready to work for Data Scientist 6 | 7 | components: 8 | - name: tiller 9 | source: 10 | dir: components/tiller 11 | git: 12 | remote: 'https://github.com/agilestacks/components.git' 13 | ref: master 14 | subDir: tiller 15 | - name: storage-class 16 | source: 17 | dir: components/storage-class 18 | git: 19 | remote: 'https://github.com/agilestacks/components.git' 20 | ref: master 21 | subDir: storage-class 22 | - name: external-dns 23 | source: 24 | dir: components/external-dns 25 | git: 26 | remote: 'https://github.com/agilestacks/components.git' 27 | ref: master 28 | subDir: external-dns 29 | - name: cert-manager 30 | source: 31 | dir: components/cert-manager 32 | git: 33 | remote: 'https://github.com/agilestacks/components.git' 34 | ref: master 35 | subDir: cert-manager 36 | - name: traefik2 37 | source: 38 | dir: components/traefik2 39 | git: 40 | remote: 'https://github.com/agilestacks/components.git' 41 | ref: master 42 | subDir: traefik2 43 | - name: tls-host-controller 44 | source: 45 | dir: components/tls-host-controller 46 | git: 47 | remote: 'https://github.com/agilestacks/tls-host-controller.git' 48 | ref: master 49 | - name: kube-dashboard 50 | source: 51 | dir: components/kube-dashboard2 52 | git: 53 | remote: 'https://github.com/agilestacks/components.git' 54 | ref: master 55 | subDir: kube-dashboard2 56 | - name: dex 57 | source: 58 | dir: components/dex 59 | git: 60 | remote: 'https://github.com/agilestacks/components.git' 61 | ref: master 62 | subDir: dex 63 | - name: prometheus 64 | source: 65 | dir: components/prometheus-operator 66 | git: 67 | remote: 'https://github.com/agilestacks/components.git' 68 | ref: master 69 | subDir: prometheus-operator 70 | - name: istio 71 | source: 72 | dir: components/istio 73 | git: 74 | remote: 'https://github.com/agilestacks/components.git' 75 | ref: master 76 | subDir: istio 77 | - name: mysql 78 | source: 79 | dir: components/mysql 80 | git: 81 | remote: 'https://github.com/agilestacks/components.git' 82 | ref: master 83 | subDir: mysql 84 | - name: minio 85 | source: 86 | dir: components/minio 87 | git: 88 | remote: 'https://github.com/agilestacks/components.git' 89 | ref: master 90 | subDir: minio 91 | - name: kubeflow-ingressgateway 92 | source: 93 | dir: components/istio-ingressgateway 94 | git: 95 | remote: 'https://github.com/agilestacks/components.git' 96 | ref: master 97 | subDir: istio-ingressgateway 98 | - name: s3-flex-driver 99 | source: 100 | dir: components/s3fs 101 | git: 102 | remote: 'https://github.com/agilestacks/applications.git' 103 | ref: master 104 | subDir: components/s3fs 105 | - name: kubeflow 106 | source: 107 | dir: components/kubeflow-v1.0 108 | git: 109 | remote: 'https://github.com/agilestacks/components.git' 110 | ref: master 111 | subDir: kubeflow-v1.0 112 | # - name: kubeflow-profile 113 | # source: 114 | # dir: components/kubeflow-profile 115 | # git: 116 | # remote: 'https://github.com/agilestacks/stack-ml-eks.git' 117 | # subDir: 'components/kubeflow-profile' 118 | # - name: s3-flex-pvc 119 | # source: 120 | # dir: components/s3fs/pvc 121 | 122 | extensions: 123 | include: 124 | - params.yaml 125 | configure: 126 | - components 127 | - aws 128 | - kubernetes 129 | - env 130 | deploy: 131 | before: 132 | - aws-metering 133 | - kubernetes 134 | after: 135 | - inventory-configmap 136 | parameters: 137 | - name: aws-metering.productCode 138 | value: 3aqp8v3w33r757jvba9lxjc0e 139 | 140 | requires: 141 | - aws 142 | - kubernetes 143 | lifecycle: 144 | verbs: 145 | - deploy 146 | - undeploy 147 | order: 148 | - tiller 149 | - storage-class 150 | - external-dns 151 | - cert-manager 152 | - traefik2 153 | - tls-host-controller 154 | - dex 155 | - kube-dashboard 156 | - prometheus 157 | - istio 158 | - kubeflow-ingressgateway 159 | - mysql 160 | - minio 161 | - kubeflow 162 | # - kubeflow-profile 163 | - s3-flex-driver 164 | # - s3-flex-pvc 165 | mandatory: 166 | - tiller 167 | - external-dns 168 | - traefik2 169 | - dex 170 | - istio 171 | - mysql 172 | - minio 173 | - kubeflow 174 | - kube-dashboard 175 | -------------------------------------------------------------------------------- /params.yaml: -------------------------------------------------------------------------------- 1 | parameters: 2 | - name: cloud 3 | brief: Cloud 4 | kind: user 5 | parameters: 6 | - name: kind 7 | value: aws 8 | - name: region 9 | fromEnv: AWS_REGION 10 | - name: dns 11 | brief: DNS 12 | kind: user 13 | parameters: 14 | - name: domain 15 | brief: Fully qualified domain name of the stack (FQDN) 16 | fromEnv: HUB_DOMAIN_NAME 17 | - name: name 18 | brief: Stack name (first part of stack FQDN) 19 | fromEnv: HUB_STACK_NAME 20 | # - name: baseDomain 21 | # brief: DNS base domain 22 | # fromEnv: BASE_DOMAIN 23 | # default: devops.delivery 24 | - name: component.storage-class.name 25 | value: default 26 | - name: terraform.bucket 27 | brief: Terraform state location 28 | parameters: 29 | - name: name 30 | brief: Name of the bucket to store deployment state 31 | fromEnv: HUB_STATE_BUCKET 32 | - name: region 33 | brief: Region of the bucket to store deployment state 34 | fromEnv: HUB_STATE_REGION 35 | - name: component.ingress 36 | parameters: 37 | - name: dashboard 38 | value: 'true' 39 | - name: ssoUrlPrefix 40 | value: apps 41 | - name: urlPrefix 42 | value: app 43 | - name: component.istio 44 | parameters: 45 | - name: version.release 46 | value: 1.3.8 47 | - name: prometheus.enabled 48 | # this parameter is deprecated 49 | # it will be removed in the future 50 | value: "true" 51 | 52 | - name: ingressGateway 53 | value: ingressgateway 54 | component: istio 55 | - name: ingressGateway 56 | value: kubeflow-ingressgateway 57 | component: kubeflow-ingressgateway 58 | - name: ingressGateway 59 | value: kubeflow-ingressgateway 60 | component: kubeflow 61 | 62 | - name: component.kubeflow 63 | parameters: 64 | - name: name 65 | value: kubeflow 66 | - name: namespace 67 | value: ${component.kubeflow.name} 68 | - name: profile.name 69 | value: workspace 70 | - name: profile.owner.username 71 | value: ${component.dex.passwordDb.email} 72 | - name: component.minio 73 | kind: user 74 | parameters: 75 | - name: name 76 | value: buckets 77 | - name: namespace 78 | value: ${component.kubeflow.name}-data 79 | - name: accessKey 80 | brief: Minio Access Key ID (at least 5 symbols) 81 | fromEnv: COMPONENT_MINIO_ACCESS_KEY 82 | - name: secretKey 83 | brief: Minio Secret Key ID (at least 8 symbols) 84 | fromEnv: COMPONENT_MINIO_SECRET_KEY 85 | - name: region 86 | value: ${cloud.region} 87 | - name: default.bucket.name 88 | value: ${component.kubeflow.name}-pipelines 89 | 90 | # consumed by kubeflow 91 | - name: component.bucket 92 | component: kubeflow 93 | parameters: 94 | - name: accessKey 95 | value: ${component.minio.accessKey} 96 | - name: secretKey 97 | value: ${component.minio.secretKey} 98 | - name: name 99 | value: ${component.minio.default.bucket.name} 100 | 101 | - name: component.mysql 102 | kind: user 103 | parameters: 104 | - name: namespace 105 | value: ${component.kubeflow.name}-data 106 | - name: databasee 107 | value: mlpipeline 108 | - name: rootPassword 109 | brief: MySQL root password 110 | fromEnv: COMPONENT_MYSQL_ROOT_PASSWORD 111 | - name: user 112 | brief: MySQL user name 113 | fromEnv: COMPONENT_MYSQL_USER 114 | default: mysql 115 | - name: password 116 | brief: MySQL user password 117 | fromEnv: COMPONENT_MYSQL_PASSWORD 118 | - name: volumeSize 119 | value: 8Gi 120 | 121 | - name: component.mysql.user 122 | component: kubeflow 123 | value: root 124 | - name: component.mysql.password 125 | component: kubeflow 126 | value: ${component.mysql.rootPassword} 127 | # value: 7b4cc3facd9f408baf685d068c850bd8 128 | 129 | - name: component.bucket.endpoint 130 | component: kubeflow 131 | value: http://${component.minio.name}.${component.minio.namespace}.svc.cluster.local:9000 132 | - name: component.bucket.endpoint 133 | component: s3-flex-pvc 134 | value: http://${component.minio.name}.${component.minio.namespace}.svc.cluster.local:9000 135 | 136 | - name: component.kubernetes-dashboard 137 | parameters: 138 | - name: rbac.kind 139 | value: read-only 140 | # value: admin 141 | 142 | - name: component.prometheus 143 | parameters: 144 | - name: prometheus.volumeSize 145 | value: 12Gi 146 | - name: prometheus.retention 147 | value: 4h 148 | 149 | - name: component.external-dns.interval 150 | value: 3m 151 | - name: component.s3flex 152 | parameters: 153 | - name: driver.namespace 154 | value: ${component.kubeflow.name}-data 155 | - name: pvc.namespace 156 | value: workspace 157 | # value: ${component.kubeflow.namespace} 158 | 159 | - name: component.dex 160 | parameters: 161 | - name: issuer 162 | value: https://auth.${dns.domain} 163 | - name: namespace 164 | value: kube-system 165 | - name: passwordDb.email 166 | brief: Admin user email (to login with Dex) 167 | fromEnv: COMPONENT_DEX_PASSWORD_DB_EMAIL 168 | default: support@agilestacks.com 169 | empty: allow 170 | - name: passwordDb.password 171 | brief: Admin user password (to login with Dex) 172 | fromEnv: COMPONENT_DEX_PASSWORD_DB_PASSWORD 173 | empty: allow 174 | 175 | outputs: 176 | - name: component.kubeflow.url 177 | brief: Kubeflow Central Dashboard 178 | - name: component.minio.url 179 | brief: Minio Endpoint 180 | - name: component.istio.kiali.url 181 | brief: Istio Kiali 182 | - name: component.prometheus.url 183 | brief: Prometheus Dashboard 184 | - name: component.ingress.dashboard.url 185 | brief: Traefik Dashboard 186 | - name: component.kubernetes-dashboard.url 187 | brief: Kubernetes Dashboard 188 | --------------------------------------------------------------------------------