Skip to content

Commit

Permalink
Merge pull request #119 from mlinfra-io/117-feature-setup-minikube
Browse files Browse the repository at this point in the history
setup minikube
  • Loading branch information
aliabbasjaffri authored Oct 12, 2024
2 parents 2bd2c6f + 7d23547 commit 03e0d3d
Show file tree
Hide file tree
Showing 49 changed files with 605 additions and 32 deletions.
15 changes: 15 additions & 0 deletions docs/code/local/minikube.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
`minikube` deploys MLOps `stack` on top of [minikube cluster](https://minikube.sigs.k8s.io/) on your machine. Please ensure that docker is installed and running on your machine, along with the latest version of minikube.


#### Complete

===+ "Simple Deployment Configuration"
```yaml
--8<-- "docs/examples/local/minikube.yaml"
```
=== "Advanced Deployment Configuration"
```yaml
--8<-- "docs/examples/local/minikube-advanced.yaml"
```

- Once the stacks have been deployed, there is one last step that allows the deployed stacks to be accessed on your local machine. You need to open a new terminal window and find the minikube profile that you're using `minikube profile list` and run `minikube tunnel --profile='<minikube-profile>'` to allow the services to be accessible on the local instance.
17 changes: 17 additions & 0 deletions examples/local/minikube-advanced.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
name: local-minikube-k8s
provider:
name: local
deployment:
type: minikube
config:
kubernetes:
nodes: 3
stack:
- data_versioning:
name: lakefs
- experiment_tracking:
name: mlflow
- orchestrator:
name: prefect
- vector_database:
name: milvus
14 changes: 14 additions & 0 deletions examples/local/minikube.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
name: local-minikube-k8s
provider:
name: local
deployment:
type: minikube
stack:
- data_versioning:
name: lakefs
- experiment_tracking:
name: mlflow
- orchestrator:
name: prefect
- vector_database:
name: milvus
1 change: 1 addition & 0 deletions mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ nav:
- Examples:
- Local:
- kind: code/local/kind.md
- minikube: code/local/minikube.md
- AWS:
- cloud_vm: code/aws/cloud_vm.md
- kubernetes: code/aws/kubernetes.md
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module "lakefs_helmchart" {
source = "../../../../../local/kind/helm_chart"
source = "../../../../../local/helm_chart"

name = "lakefs"
namespace = "lakefs"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,19 @@ locals {
name = "postgresql.auth.password"
value = "${random_password.mlflow_password.result}"
type = "auto"
}, {
name = "postgresql.volumePermissions.enabled"
value = "true"
type = "auto"
}, {
name = "minio.volumePermissions.enabled"
value = "true"
type = "auto"
}]
}

module "mlflow_helmchart" {
source = "../../../../../local/kind/helm_chart"
source = "../../../../../local/helm_chart"

name = "mlflow"
namespace = "mlflow"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ locals {
value = "true"
type = "auto"
}, {
name = "postgresql.volumePermissions.enabled"
value = "true"
type = "auto"
}, {
name = "ingress.enabled"
value = "true"
type = "auto"
Expand All @@ -19,7 +23,7 @@ locals {
}

module "prefect_server_helmchart" {
source = "../../../../../local/kind/helm_chart"
source = "../../../../../local/helm_chart"

name = "prefect-server"
namespace = var.namespace
Expand Down Expand Up @@ -57,7 +61,7 @@ locals {
}

module "prefect_worker_helmchart" {
source = "../../../../../local/kind/helm_chart"
source = "../../../../../local/helm_chart"

name = "prefect-worker"
namespace = var.namespace
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ locals {
type = "auto"
}, {
name = "ingress.rules[0].host"
value = var.milvus_endpoint
value = "milvus.localhost"
type = "auto"
}, {
name = "ingress.rules[0].path"
Expand All @@ -41,13 +41,21 @@ locals {
type = "auto"
}, {
name = "attu.ingress.hosts[0]"
value = "milvus-attu.localhost"
value = var.milvus_endpoint
type = "auto"
}, {
name = "etcd.volumePermissions.enabled"
value = "true"
type = "auto"
}, {
name = "minio.securityContext.enabled"
value = "false"
type = "auto"
}]
}

module "milvus_helmchart" {
source = "../../../../../cloud/aws/helm_chart"
source = "../../../../../local/helm_chart"
name = "milvus"
namespace = "milvus"
create_namespace = true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ resource "kind_cluster" "local_kind_cluster" {

resource "time_sleep" "cluster_creation" {
depends_on = [kind_cluster.local_kind_cluster]
create_duration = "30s"
create_duration = "15s"
}

resource "null_resource" "ingress_controller_manifest" {
Expand All @@ -45,3 +45,8 @@ resource "null_resource" "ingress_controller_manifest" {

depends_on = [time_sleep.cluster_creation]
}

resource "time_sleep" "ingress_controller_creation" {
depends_on = [null_resource.ingress_controller_manifest]
create_duration = "30s"
}
22 changes: 22 additions & 0 deletions src/mlinfra/modules/local/minikube/k8s/k8s.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
inputs:
- name: cluster_name
user_facing: true
description: "Name of the Minikube cluster"
default: "minikube-cluster"
- name: k8s_version
user_facing: true
description: "Minikube Cluster version"
default: "1.30.0"
- name: driver
user_facing: true
description: "Driver for the Minikube cluster"
default: "docker"
- name: nodes
user_facing: true
description: "Number of nodes in the Minikube cluster"
default: 1
- name: add_ons
user_facing: true
description: "Add-ons to enable in the Minikube cluster"
default: []
outputs:
11 changes: 11 additions & 0 deletions src/mlinfra/modules/local/minikube/k8s/tf_module/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
module "minikube" {
source = "./minikube_cluster"

driver = var.driver
cluster_name = var.cluster_name
k8s_version = var.k8s_version
nodes = var.nodes
add_ons = var.add_ons
wait_for_addons = var.wait_for_addons
wait_time = var.wait_time
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
resource "minikube_cluster" "cluster" {
driver = var.driver
cluster_name = var.cluster_name
kubernetes_version = var.k8s_version
nodes = var.nodes
wait = var.wait_for_addons

addons = var.add_ons
}

resource "time_sleep" "cluster_creation" {
create_duration = "${var.wait_time}s"
depends_on = [minikube_cluster.cluster]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
output "endpoint" {
value = minikube_cluster.cluster.host
description = "The endpoint of the Minikube cluster"
}

output "client_certificate" {
value = minikube_cluster.cluster.client_certificate
description = "The client certificate for accessing the Minikube cluster"
sensitive = true
}

output "cluster_ca_certificate" {
value = minikube_cluster.cluster.cluster_ca_certificate
description = "The CA certificate for the Minikube cluster"
sensitive = true
}

output "client_key" {
value = minikube_cluster.cluster.client_key
description = "The client key for accessing the Minikube cluster"
sensitive = true
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
variable "driver" {
type = string
description = "The driver to be used for the Minikube cluster"
default = "docker"
}

variable "cluster_name" {
type = string
description = "Name of the local minikube cluster"
default = "minikube-cluster"
}

variable "k8s_version" {
type = string
description = "Defines kubernetes version for the minikube cluster"
default = "1.30"
}

variable "nodes" {
type = number
description = "Number of nodes to be created for the cluster"
default = 1
}

variable "add_ons" {
type = list(string)
description = "List of add-ons to be enabled for the Minikube cluster"
default = [
"default-storageclass",
"storage-provisioner",
"ingress"
]
}

variable "wait_for_addons" {
type = list(string)
default = [
"apiserver",
"system_pods",
"apps_running"
]
}

variable "wait_time" {
type = number
default = 20
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# This needs to be added explicitly to all modules
# relying on a non-hashicorp provider. See:
# https://discuss.hashicorp.com/t/using-a-non-hashicorp-provider-in-a-module/21841
terraform {
required_version = ">= 1.8.0"
required_providers {
minikube = {
source = "scott-the-programmer/minikube"
version = "~> 0.4"
}
kubernetes = {
source = "hashicorp/kubernetes"
version = "~> 2.0"
}
}
}
22 changes: 22 additions & 0 deletions src/mlinfra/modules/local/minikube/k8s/tf_module/outputs.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
output "endpoint" {
value = module.minikube.endpoint
description = "The endpoint of the Minikube cluster"
}

output "client_certificate" {
value = module.minikube.client_certificate
description = "The client certificate for accessing the Minikube cluster"
sensitive = true
}

output "cluster_ca_certificate" {
value = module.minikube.cluster_ca_certificate
description = "The CA certificate for the Minikube cluster"
sensitive = true
}

output "client_key" {
value = module.minikube.client_key
description = "The client key for accessing the Minikube cluster"
sensitive = true
}
47 changes: 47 additions & 0 deletions src/mlinfra/modules/local/minikube/k8s/tf_module/variables.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
variable "driver" {
type = string
description = "The driver to be used for the Minikube cluster"
default = "docker"
}

variable "cluster_name" {
type = string
description = "Name of the local minikube cluster"
default = "minikube-cluster"
}

variable "k8s_version" {
type = string
description = "Defines kubernetes version for the minikube cluster"
default = "1.30"
}

variable "nodes" {
type = number
description = "Number of nodes to be created for the cluster"
default = 1
}

variable "add_ons" {
type = list(string)
description = "List of add-ons to be enabled for the Minikube cluster"
default = [
"default-storageclass",
"storage-provisioner",
"ingress"
]
}

variable "wait_for_addons" {
type = list(string)
default = [
"apiserver",
"system_pods",
"apps_running"
]
}

variable "wait_time" {
type = number
default = 20
}
16 changes: 16 additions & 0 deletions src/mlinfra/modules/local/minikube/k8s/tf_module/versions.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# This needs to be added explicitly to all modules
# relying on a non-hashicorp provider. See:
# https://discuss.hashicorp.com/t/using-a-non-hashicorp-provider-in-a-module/21841
terraform {
required_version = ">= 1.8.0"
required_providers {
minikube = {
source = "scott-the-programmer/minikube"
version = "~> 0.4"
}
kubernetes = {
source = "hashicorp/kubernetes"
version = "~> 2.0"
}
}
}
5 changes: 5 additions & 0 deletions src/mlinfra/modules/local/minikube/provider.tf.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"provider": {
"minikube": {}
}
}
Loading

0 comments on commit 03e0d3d

Please sign in to comment.