Skip to content

Commit

Permalink
Refactor quick install to reuse e2e scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
Arief Rahmansyah committed Sep 7, 2023
1 parent 51d1a9a commit 584aec3
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 197 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/merlin.yml
Original file line number Diff line number Diff line change
Expand Up @@ -399,7 +399,7 @@ jobs:
--k3s-arg '--kubelet-arg=eviction-minimum-reclaim=imagefs.available=1%,nodefs.available=1%@agent:*'
- name: Setup cluster
working-directory: merlin/scripts/e2e
run: ./setup-cluster.sh merlin-cluster ${{ env.INGRESS_HOST }}
run: ./setup-cluster.sh merlin-cluster
- name: Download API Docker Artifact
uses: actions/download-artifact@v2
with:
Expand Down
18 changes: 9 additions & 9 deletions docs/dev-guide/deploying-merlin/local_development.md
Original file line number Diff line number Diff line change
@@ -1,26 +1,26 @@
# Local Development

In this guide, we will deploy Merlin on a local Minikube cluster.
In this guide, we will deploy Merlin on a local K3d cluster.

## Prerequesites

1. Kubernetes
1. In this guide, we will use Minikube with LoadBalancer enabled
1. In this guide, we will use k3d with LoadBalancer enabled
2. Kubernetes CLI (kubectl)
3. Helm

## Provision Minikube cluster
## Provision k3d cluster

First, you need to have Minikube installed on your machine. To install it, please follow this [documentation](https://minikube.sigs.k8s.io/docs/start/). You also need to have a [driver](https://minikube.sigs.k8s.io/docs/drivers/) to run Minikube cluster. This guide uses VirtualBox driver.
First, you need to have k3d installed on your machine. To install it, please follow this [documentation](https://k3d.io/).

Next, create a new Minikube cluster with Kubernetes v1.26.3:
Next, create a new k3d cluster:

```bash
export CLUSTER_NAME=dev
minikube start --cpus=4 --memory=8192 --kubernetes-version=v1.26.3 --driver=docker
export CLUSTER_NAME=merlin-cluster
export K3S_VERSION=v1.26.7-k3s1
k3d cluster create $CLUSTER_NAME --image rancher/k3s:$K3S_VERSION --k3s-arg '--disable=traefik,metrics-server@server:*' --port 80:80@loadbalancer
```

Lastly, we need to enable Minikube's LoadBalancer services by running `minikube tunnel` in another terminal.

## Install Merlin

You can run [`quick_install.sh`](../../../scripts/quick_install.sh) to install Merlin and it's components:
Expand Down
6 changes: 5 additions & 1 deletion scripts/e2e/setup-and-run-e2e.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
#!/bin/sh

export K3D_CLUSTER=merlin-cluster
export K3S_VERSION=v1.26.7-k3s1
export INGRESS_HOST=127.0.0.1.nip.io
export LOCAL_REGISTRY_PORT=12345
export LOCAL_REGISTRY=dev.localhost
Expand All @@ -10,7 +13,8 @@ export MERLIN_CHART_VERSION=0.11.1

# Create k3d cluster and managed registry
k3d registry create $LOCAL_REGISTRY --port $LOCAL_REGISTRY_PORT
k3d cluster create $K3D_CLUSTER --image rancher/k3s:v1.25.9-k3s1 --k3s-arg '--disable=traefik,metrics-server@server:*' --port 80:80@loadbalancer
k3d cluster create $K3D_CLUSTER --image rancher/k3s:$K3S_VERSION --k3s-arg '--disable=traefik,metrics-server@server:*' --port 80:80@loadbalancer

# Install all dependencies
./setup-cluster.sh $K3D_CLUSTER $INGRESS_HOST

Expand Down
8 changes: 6 additions & 2 deletions scripts/e2e/setup-cluster.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,11 @@ set -o nounset

# Prerequisites:
# - cluster have been created using k3d
# - cluster have enabled load balancer

CLUSTER_NAME=$1
INGRESS_HOST=$2

ISTIO_VERSION=1.18.2
# queue proxy version in config/knative/overlay.yaml should also be modified to upgrade knative
KNATIVE_VERSION=1.10.2
KNATIVE_NET_ISTIO_VERSION=1.10.1
CERT_MANAGER_VERSION=1.12.2
Expand Down Expand Up @@ -78,6 +77,10 @@ install_istio() {
echo "::endgroup::"
}

set_ingress_host() {
export INGRESS_HOST="$(kubectl -n istio-system get service istio-ingressgateway -o jsonpath='{.status.loadBalancer.ingress[0].ip}').nip.io"
}

install_knative() {
echo "::group::Knative Deployment"

Expand Down Expand Up @@ -151,6 +154,7 @@ patch_coredns() {

add_helm_repo
install_istio
set_ingress_host
install_knative
install_minio
install_cert_manager
Expand Down
195 changes: 11 additions & 184 deletions scripts/quick_install.sh
Original file line number Diff line number Diff line change
@@ -1,191 +1,18 @@
#!/bin/sh
set -x

export CLUSTER_NAME=dev
# Prerequisites:
# - cluster have been created using k3d
# - cluster have enabled load balancer

export ISTIO_VERSION=1.18.2
export KNATIVE_VERSION=v1.10.2
export KNATIVE_NET_ISTIO_VERSION=v1.10.1
export CERT_MANAGER_VERSION=v1.12.2
export MINIO_VERSION=3.6.3
export KSERVE_VERSION=v0.11.0
export CLUSTER_NAME=merlin-cluster

export OAUTH_CLIENT_ID=""
export MLP_CHART_VERSION=0.6.1
export MERLIN_CHART_VERSION=0.11.7
export MERLIN_VERSION=0.31.1

# Install Istio
curl --location https://istio.io/downloadIstio | sh -

cat << EOF > ./istio-config.yaml
apiVersion: install.istio.io/v1alpha1
kind: IstioOperator
spec:
profile: default
meshConfig:
accessLogFile: /dev/stdout
enableTracing: true
components:
egressGateways:
- name: istio-egressgateway
enabled: true
values:
global:
proxy:
autoInject: disabled
gateways:
istio-ingressgateway:
runAsRoot: true
components:
ingressGateways:
- name: istio-ingressgateway
enabled: true
k8s:
resources:
requests:
cpu: 20m
memory: 64Mi
limits:
memory: 128Mi
- name: cluster-local-gateway
enabled: true
label:
istio: cluster-local-gateway
app: cluster-local-gateway
k8s:
resources:
requests:
cpu: 20m
memory: 64Mi
limits:
memory: 128Mi
service:
type: ClusterIP
ports:
- port: 15020
name: status-port
- port: 80
name: http2
- port: 443
name: https
EOF
istio-${ISTIO_VERSION}/bin/istioctl manifest apply -f istio-config.yaml

## Install Knative
kubectl apply --filename=https://github.com/knative/serving/releases/download/knative-${KNATIVE_VERSION}/serving-crds.yaml
kubectl apply --filename=https://github.com/knative/serving/releases/download/knative-${KNATIVE_VERSION}/serving-core.yaml
cd e2e; ./setup-cluster.sh $CLUSTER_NAME

export INGRESS_HOST=$(kubectl -n istio-system get service istio-ingressgateway -o jsonpath='{.status.loadBalancer.ingress[0].ip}')
cat <<EOF > ./patch-config-domain.json
{
"data": {
"${INGRESS_HOST}.nip.io": ""
}
}
EOF
kubectl patch configmap/config-domain --namespace=knative-serving --type=merge --patch="$(cat patch-config-domain.json)"

# Install Knative Net Istio
kubectl apply --filename=https://github.com/knative-sandbox/net-istio/releases/download/knative-${KNATIVE_NET_ISTIO_VERSION}/release.yaml

# Install Cert Manager
kubectl apply --filename=https://github.com/jetstack/cert-manager/releases/download/${CERT_MANAGER_VERSION}/cert-manager.yaml
kubectl wait deployment.apps/cert-manager-webhook --namespace=cert-manager --for=condition=available --timeout=600s
sleep 15

# Install Minio
cat <<EOF > minio-values.yaml
replicas: 4
resources:
requests:
cpu: 25m
memory: 64Mi
limits: ~
accessKey: YOURACCESSKEY
secretKey: YOURSECRETKEY
rootUser: YOURACCESSKEY
rootPassword: YOURSECRETKEY
ingress:
enabled: true
annotations:
kubernetes.io/ingress.class: istio
path: /
hosts:
- minio.minio.${INGRESS_HOST}.nip.io
consoleIngress:
enabled: false
buckets:
- name: mlflow
policy: none
purge: false
versioning: false
EOF

kubectl create namespace minio
helm repo add minio https://charts.min.io/
helm install minio minio/minio --version=${MINIO_VERSION} --namespace=minio --values=minio-values.yaml --wait --timeout=600s

Install Kserve
kubectl apply --filename=https://github.com/kserve/kserve/releases/download/${KSERVE_VERSION}/kserve.yaml
kubectl apply --filename=https://github.com/kserve/kserve/releases/download/${KSERVE_VERSION}/kserve-runtimes.yaml

cat <<EOF > ./patch-config-inferenceservice.json
{
"data": {
"ingress": "{\n \"ingressGateway\" : \"knative-serving/knative-ingress-gateway\",\n \"ingressService\" : \"istio-ingressgateway.istio-system.svc.cluster.local\",\n \"localGateway\" : \"knative-serving/knative-local-gateway\",\n \"localGatewayService\" : \"knative-local-gateway.istio-system.svc.cluster.local\",\n \"ingressDomain\" : \"${INGRESS_HOST}.nip.io\",\n \"ingressClassName\" : \"istio\",\n \"domainTemplate\": \"{{ .Name }}.{{ .Namespace }}.{{ .IngressDomain }}\",\n \"urlScheme\": \"http\",\n \"disableIstioVirtualHost\": false\n}"
"logger": "{\n \"image\" : \"kserve/agent:${KSERVE_VERSION}\",\n \"memoryRequest\": \"100Mi\",\n \"memoryLimit\": \"1Gi\",\n \"cpuRequest\": \"25m\",\n \"cpuLimit\": \"1\",\n \"defaultUrl\": \"http:\/\/default-broker\"\n}",
"storageInitializer": "{\n \"image\" : \"ghcr.io/ariefrahmansyah/kfserving-storage-init:latest\",\n \"memoryRequest\": \"100Mi\",\n \"memoryLimit\": \"1Gi\",\n \"cpuRequest\": \"25m\",\n \"cpuLimit\": \"1\"\n}"
}
}
EOF
kubectl patch configmap/inferenceservice-config --namespace=kserve --type=merge --patch="$(cat patch-config-inferenceservice.json)"

# Install MLP and Merlin

create new helm value file containing cluster credentials
cat <<EOF | yq e -P - > k8s_config.yaml
{
"k8s_config": {
"name": "dev",
"cluster": {
"server": "https://kubernetes.default.svc.cluster.local:443",
"certificate-authority-data": "$(awk '{printf "%s\n", $0}' ~/.minikube/ca.crt | base64)"
},
"user": {
"client-certificate-data": "$(awk '{printf "%s\n", $0}' ~/.minikube/profiles/minikube/client.crt | base64)",
"client-key-data": "$(awk '{printf "%s\n", $0}' ~/.minikube/profiles/minikube/client.key | base64)"
}
}
}
EOF

output=$(yq '.k8s_config' k8s_config.yaml)
output="$output" yq ".environmentConfigs[0] *= load(\"k8s_config.yaml\") | .imageBuilder.k8sConfig |= env(output)" -i "values-local.yaml"

helm repo add caraml https://caraml-dev.github.io/helm-charts
export DOCKER_REGISTRY=ghcr.io/caraml-dev
export VERSION=0.33.0
export GIT_REF=v0.33.0
export MERLIN_CHART_VERSION=0.11.7
export OAUTH_CLIENT_ID=""

helm upgrade --install --create-namespace merlin caraml/merlin --namespace=caraml --values=./values-local.yaml \
--version ${MERLIN_CHART_VERSION} \
--set deployment.image.tag=${MERLIN_VERSION} \
--set ui.oauthClientID=${OAUTH_CLIENT_ID} \
--set config.MlpAPIConfig.APIHost=http://mlp.caraml.${INGRESS_HOST}.nip.io \
--set ingress.enabled=true \
--set ingress.class=istio \
--set ingress.host=merlin.caraml.${INGRESS_HOST}.nip.io \
--set mlflow.ingress.enabled=true \
--set mlflow.ingress.class=istio \
--set mlflow.ingress.host=merlin-mlflow.caraml.${INGRESS_HOST}.nip.io \
--set mlp.deployment.apiHost=http://mlp.caraml.${INGRESS_HOST}.nip.io/v1 \
--set mlp.deployment.mlflowTrackingUrl=http://merlin-mlflow.caraml.${INGRESS_HOST}.nip.io \
--set mlp.ingress.host=mlp.caraml.${INGRESS_HOST}.nip.io \
--set minio.enabled=false \
--set kserve.enabled=false \
--timeout=5m \
--wait
cd e2e; ./deploy-merlin.sh $INGRESS_HOST $DOCKER_REGISTRY $VERSION $GIT_REF $MERLIN_CHART_VERSION $OAUTH_CLIENT_ID

0 comments on commit 584aec3

Please sign in to comment.