You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@linkis.apache.org by le...@apache.org on 2022/07/10 14:01:53 UTC
[incubator-linkis] branch dev-1.3.0 updated: [Feature] Add scripts and documents for helm chart development and testing (#2445)
This is an automated email from the ASF dual-hosted git repository.
legendtkl pushed a commit to branch dev-1.3.0
in repository https://gitbox.apache.org/repos/asf/incubator-linkis.git
The following commit(s) were added to refs/heads/dev-1.3.0 by this push:
new 78d98ca71 [Feature] Add scripts and documents for helm chart development and testing (#2445)
78d98ca71 is described below
commit 78d98ca71d7ae2d19e42dc2c36212439738ba584
Author: Aaron Lin <51...@users.noreply.github.com>
AuthorDate: Sun Jul 10 22:01:46 2022 +0800
[Feature] Add scripts and documents for helm chart development and testing (#2445)
* [Feature] add scripts and documents for test tools of helm charts
* Update mysql.yaml
Add a newline at the end of mysql.yaml
* refactor end line, fix conflict
* Add apache2 license annotations
* fix kubernetes version
* refactor end line
---
linkis-dist/helm/README.md | 100 +++++++++++++++++++++
linkis-dist/helm/scripts/create-test-kind.sh | 57 ++++++++++++
linkis-dist/helm/scripts/install-charts.sh | 31 +++++++
.../helm/scripts/resources/kind-cluster.yaml | 30 +++++++
linkis-dist/helm/scripts/resources/mysql.yaml | 57 ++++++++++++
5 files changed, 275 insertions(+)
diff --git a/linkis-dist/helm/README.md b/linkis-dist/helm/README.md
new file mode 100644
index 000000000..a2a7aad5f
--- /dev/null
+++ b/linkis-dist/helm/README.md
@@ -0,0 +1,100 @@
+Helm charts for Linkis
+==========
+
+[![License](https://img.shields.io/badge/license-Apache%202-4EB1BA.svg)](https://www.apache.org/licenses/LICENSE-2.0.html)
+
+# Pre-requisites
+* [Kubernetes](https://kubernetes.io/docs/setup/), minimum version v1.21.0+
+* [Helm](https://helm.sh/docs/intro/install/), minimum version v3.0.0+.
+
+# Installation
+
+```shell
+# Deploy Apache Linkis on kubernetes, kubernetes
+# namespace is 'linkis', helm release is 'linkis-demo'
+
+# Option 1, use build-in script
+$> ./scripts/install-charts.sh linkis linkis-demo
+
+# Option 2, use `helm` command line
+$> helm install --create-namespace -f ./charts/linkis/values.yaml --namespace linkis linkis-demo ./charts/linkis
+```
+
+# Uninstallation
+
+```shell
+$> helm delete --namespace linkis linkis-demo
+```
+
+# For developers
+
+We recommend using [KinD](https://kind.sigs.k8s.io/docs/user/quick-start/) for development and testing.
+KinD is a tool for running local Kubernetes clusters using Docker container as โKubernetes nodesโ.
+
+Follow the link below to install the KinD in your development environment.
+
+- [KinD Installation](https://kind.sigs.k8s.io/docs/user/quick-start/#installation)
+
+## Setup a local cluster for test
+Once after you have installed KinD, you can run the following command to setup a local kubernetes cluster and deploy an Apache Linkis cluster on it.
+
+```shell
+# It will deploy a MySQL instance in the KinD cluster,
+# then deploy an Apache Linkis cluster, which will use
+# the MySQL instances above
+$> sh ./scripts/create-test-kind.sh \
+ && sh ./scripts/install-charts.sh
+
+Creating cluster "test-helm" ...
+ โ Ensuring node image (kindest/node:v1.21.1) ๐ผ
+ โ Preparing nodes ๐ฆ
+ โ Writing configuration ๐
+ โ Starting control-plane ๐น๏ธ
+ โ Installing CNI ๐
+ โ Installing StorageClass ๐พ
+Set kubectl context to "kind-test-helm"
+You can now use your cluster with:
+
+kubectl cluster-info --context kind-test-helm
+
+Have a nice day! ๐
+Image: "linkis:1.3.0" with ID "sha256:917138e97807c3a2d7d7fe4607c1196e7c00406bb3b8f81a3b64e54a4d8fe074" not yet present on node "test-helm-control-plane", loading...
+Image: "mysql:5.7" with ID "sha256:efa50097efbdef5884e5ebaba4da5899e79609b78cd4fe91b365d5d9d3205188" not yet present on node "test-helm-control-plane", loading...
+namespace/mysql created
+service/mysql created
+deployment.apps/mysql created
+
+NAME: linkis-demo
+LAST DEPLOYED: Wed Jul 6 23:46:30 2022
+NAMESPACE: linkis
+STATUS: deployed
+REVISION: 1
+TEST SUITE: None
+NOTES:
+---
+Welcome to Apache Linkis (v1.3.0)!
+
+.___ .___ .______ .____/\ .___ .________
+| | : __|: \ : / \: __|| ___/
+| | | : || ||. ___/| : ||___ \
+| |/\ | || | || \ | || /
+| / \| ||___| || \| ||__:___/
+|______/|___| |___||___\ /|___| : v1.3.0
+ \/
+
+Linkis builds a layer of computation middleware between upper applications and underlying engines.
+Please visit https://linkis.apache.org/ for details.
+
+Enjoy!
+
+```
+
+## Destroy the local cluster
+```shell
+# Option 1: delete the helm release only
+$> helm delete --namespace linkis linkis-demo
+
+# Option 2: destroy the KinD cluster, no need to delete
+# the helm release first
+$> kind delete cluster --name test-helm
+```
diff --git a/linkis-dist/helm/scripts/create-test-kind.sh b/linkis-dist/helm/scripts/create-test-kind.sh
new file mode 100644
index 000000000..e0bdd9717
--- /dev/null
+++ b/linkis-dist/helm/scripts/create-test-kind.sh
@@ -0,0 +1,57 @@
+#!/bin/bash
+#
+# 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.
+#
+#
+
+WORK_DIR=`cd $(dirname $0); pwd -P`
+PROJECT_ROOT=${WORK_DIR}/../..
+RESOURCE_DIR=${WORK_DIR}/resources
+TMP_DIR=`mktemp -d -t kind-XXXXX`
+
+set -e
+
+KIND_CLUSTER_NAME=${KIND_CLUSTER_NAME:-test-helm}
+MYSQL_VERSION=${MYSQL_VERSION:-5.7}
+
+# evaluate project version
+PROJECT_VERSION=`cd ${PROJECT_ROOT} \
+ && MAVEN_OPTS="-Dorg.slf4j.simpleLogger.defaultLogLevel=WARN -Dorg.slf4j.simpleLogger.log.org.apache.maven.plugins.help=INFO" \
+ mvn help:evaluate -o -Dexpression=project.version | tail -1`
+echo "# Project version: ${PROJECT_VERSION}"
+
+# create kind cluster
+echo "# Creating KinD cluster ..."
+# create data dir for KinD cluster
+KIND_CLUSTER_HOST_PATH=${TMP_DIR}/data
+mkdir -p ${KIND_CLUSTER_HOST_PATH}
+# create kind cluster conf
+KIND_CLUSTER_CONF_TPL=${RESOURCE_DIR}/kind-cluster.yaml
+KIND_CLUSTER_CONF_FILE=${TMP_DIR}/kind-cluster.yaml
+KIND_CLUSTER_HOST_PATH=${KIND_CLUSTER_HOST_PATH} envsubst < ${KIND_CLUSTER_CONF_TPL} > ${KIND_CLUSTER_CONF_FILE}
+
+echo "- kind cluster config: ${KIND_CLUSTER_CONF_FILE}"
+cat ${KIND_CLUSTER_CONF_FILE}
+kind create cluster --name ${KIND_CLUSTER_NAME} --config ${KIND_CLUSTER_CONF_FILE}
+
+# load images
+echo "# Loading images into KinD cluster ..."
+kind load docker-image linkis:${PROJECT_VERSION} --name ${KIND_CLUSTER_NAME}
+kind load docker-image linkis-web:${PROJECT_VERSION} --name ${KIND_CLUSTER_NAME}
+kind load docker-image mysql:${MYSQL_VERSION} --name ${KIND_CLUSTER_NAME}
+
+# deploy mysql
+echo "# Deploying MySQL ..."
+kubectl create ns mysql
+kubectl apply -n mysql -f ${RESOURCE_DIR}/mysql.yaml
diff --git a/linkis-dist/helm/scripts/install-charts.sh b/linkis-dist/helm/scripts/install-charts.sh
new file mode 100644
index 000000000..465f89903
--- /dev/null
+++ b/linkis-dist/helm/scripts/install-charts.sh
@@ -0,0 +1,31 @@
+#!/bin/bash
+#
+# 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.
+#
+#
+
+WORK_DIR=`cd $(dirname $0); pwd -P`
+CHARTS_DIR_ROOT=${WORK_DIR}/../charts
+LINKIS_CHART_DIR=${CHARTS_DIR_ROOT}/linkis
+
+KUBE_NAMESPACE=${1:-linkis}
+HELM_RELEASE_NAME=${2:-linkis-demo}
+
+if [ "X${HELM_DEBUG}" == "Xtrue" ]; then
+ # template helm charts
+ helm template --namespace ${KUBE_NAMESPACE} -f ${LINKIS_CHART_DIR}/values.yaml ${HELM_RELEASE_NAME} ${LINKIS_CHART_DIR}
+else
+ # install helm charts
+ helm install --create-namespace --namespace ${KUBE_NAMESPACE} -f ${LINKIS_CHART_DIR}/values.yaml ${HELM_RELEASE_NAME} ${LINKIS_CHART_DIR}
+fi
diff --git a/linkis-dist/helm/scripts/resources/kind-cluster.yaml b/linkis-dist/helm/scripts/resources/kind-cluster.yaml
new file mode 100644
index 000000000..40ed70192
--- /dev/null
+++ b/linkis-dist/helm/scripts/resources/kind-cluster.yaml
@@ -0,0 +1,30 @@
+# 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.
+
+kind: Cluster
+apiVersion: kind.x-k8s.io/v1alpha4
+nodes:
+ - role: control-plane
+ extraMounts:
+ - hostPath: ${KIND_CLUSTER_HOST_PATH}
+ containerPath: /data
+ - role: worker
+ extraMounts:
+ - hostPath: ${KIND_CLUSTER_HOST_PATH}
+ containerPath: /data
+ - role: worker
+ extraMounts:
+ - hostPath: ${KIND_CLUSTER_HOST_PATH}
+ containerPath: /data
diff --git a/linkis-dist/helm/scripts/resources/mysql.yaml b/linkis-dist/helm/scripts/resources/mysql.yaml
new file mode 100644
index 000000000..ffc233376
--- /dev/null
+++ b/linkis-dist/helm/scripts/resources/mysql.yaml
@@ -0,0 +1,57 @@
+# 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.
+
+---
+apiVersion: v1
+kind: Service
+metadata:
+ name: mysql
+spec:
+ ports:
+ - port: 3306
+ selector:
+ app: mysql
+ clusterIP: None
+---
+apiVersion: apps/v1
+kind: Deployment
+metadata:
+ name: mysql
+spec:
+ selector:
+ matchLabels:
+ app: mysql
+ strategy:
+ type: Recreate
+ template:
+ metadata:
+ labels:
+ app: mysql
+ spec:
+ containers:
+ - name: mysql
+ image: mysql:5.7
+ env:
+ - name: MYSQL_ROOT_PASSWORD
+ value: "123456"
+ ports:
+ - containerPort: 3306
+ name: mysql
+ volumeMounts:
+ - name: data
+ mountPath: /var/lib/mysql
+ volumes:
+ - name: data
+ emptyDir: {}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@linkis.apache.org
For additional commands, e-mail: commits-help@linkis.apache.org