You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@skywalking.apache.org by ha...@apache.org on 2019/11/02 00:01:47 UTC

[skywalking] branch istio-ci updated: [WIP]Scripts which deploy Istio + OAP + ES to a standard k8s cluster (#3718)

This is an automated email from the ASF dual-hosted git repository.

hanahmily pushed a commit to branch istio-ci
in repository https://gitbox.apache.org/repos/asf/skywalking.git


The following commit(s) were added to refs/heads/istio-ci by this push:
     new 36f8122  [WIP]Scripts which deploy Istio + OAP + ES to a standard k8s cluster (#3718)
36f8122 is described below

commit 36f81221147fd29e0b00c58154e9f6ca98dd0f14
Author: innerpeacez <in...@gmail.com>
AuthorDate: Sat Nov 2 08:01:32 2019 +0800

    [WIP]Scripts which deploy Istio + OAP + ES to a standard k8s cluster (#3718)
    
    * for #3669
    
    * Add Apache 2.0 header
    
    * Fixed some irrational
    
    * create istio-deploy.sh
    
    * modify notes
    
    * istio version and namespace to parameterize
    
    * Keep template files and tested successfully
    
    * add sw istio adapter
    
    * add a new key for isito adapter
    
    * notes.txt
    
    * add mixer template
    
    * add sw deploy script
    
    * bookinfo and cleanup scripts
    
    * add timeout and set -e
    
    * modify cleanup and request timeout of demo
    
    * End blank line
---
 install/README.md                                  |   7 ++
 install/deploy/all_cleanup.sh                      |  21 +++++
 install/deploy/demo-deploy.sh                      |  45 +++++++++
 install/deploy/istio-deploy.sh                     | 104 +++++++++++++++++++++
 install/deploy/skywalking-deploy.sh                |  56 +++++++++++
 install/kubernetes/helm/skywalking/Chart.yaml      |   2 +-
 install/kubernetes/helm/skywalking/README.md       |   1 +
 .../kubernetes/helm/skywalking/templates/NOTES.txt |   7 ++
 .../templates/istio-adapter/adapter.yaml           |  27 ++++++
 .../templates/istio-adapter/handler.yaml           |  26 ++++++
 .../templates/istio-adapter/instance.yaml          |  42 +++++++++
 .../skywalking/templates/istio-adapter/rule.yaml   |  28 ++++++
 install/kubernetes/helm/skywalking/values.yaml     |   3 +
 13 files changed, 368 insertions(+), 1 deletion(-)

diff --git a/install/README.md b/install/README.md
new file mode 100644
index 0000000..f8d3af0
--- /dev/null
+++ b/install/README.md
@@ -0,0 +1,7 @@
+These scripts are for istio , skywalking , ES to a kubernetes cluster.
+
+#### Prerequisites
+
+ - kubernetes 1.9.6+
+ - helm 3
+ - kubectl
\ No newline at end of file
diff --git a/install/deploy/all_cleanup.sh b/install/deploy/all_cleanup.sh
new file mode 100644
index 0000000..f8ae446
--- /dev/null
+++ b/install/deploy/all_cleanup.sh
@@ -0,0 +1,21 @@
+#!/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.
+
+set -e
+# cleanup files
+
+rm -fr istio/
diff --git a/install/deploy/demo-deploy.sh b/install/deploy/demo-deploy.sh
new file mode 100644
index 0000000..de63ba7
--- /dev/null
+++ b/install/deploy/demo-deploy.sh
@@ -0,0 +1,45 @@
+#!/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.
+
+set -e
+
+# The script for bookinfo Application to deploy
+BOOKINFO_VERSION="1.3"
+kubectl label namespace default istio-injection=enabled
+kubectl apply -f https://raw.githubusercontent.com/istio/istio/release-${BOOKINFO_VERSION}/samples/bookinfo/platform/kube/bookinfo.yaml
+
+# check status
+kubectl get deploy  | grep -E 'details|productpage|ratings|reviews' | awk '{print "deployment/"$1}' | while read deploy
+do
+  kubectl rollout status ${deploy}  --timeout 3m
+done
+
+# request
+start=$(date "+%M")
+while true
+do
+  REQUEST_STATUS=$(kubectl exec -it $(kubectl get pod -l app=ratings -o jsonpath='{.items[0].metadata.name}') -c ratings -- curl -m 10 productpage:9080/productpage | grep -o "<title>.*</title>" | wc -l)
+  if [ $REQUEST_STATUS == 1 ]; then
+      break
+  fi
+  end=$(date "+%M")
+  time=$(($end - $start))
+  if [ $time -ge 3 ]; then
+      echo "Request timeout"
+      break
+  fi
+done
diff --git a/install/deploy/istio-deploy.sh b/install/deploy/istio-deploy.sh
new file mode 100644
index 0000000..effc955
--- /dev/null
+++ b/install/deploy/istio-deploy.sh
@@ -0,0 +1,104 @@
+#!/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.
+
+set -e
+
+# Add istio official repo
+add_repo(){
+  VERSION=$1
+  REPO="https://storage.googleapis.com/istio-release/releases/${VERSION}/charts/"
+  helm repo add istio $REPO
+
+  STATUS_CMD=`echo $?`
+  CHECK_REPO_CMD=`helm repo list | grep $REPO | wc -l`
+  echo "$STATUS_CMD"
+  echo "$CHECK_REPO_CMD"
+  while [[ $STATUS_CMD != 0 && $CHECK_REPO_CMD -ge 1 ]]
+  do
+    sleep 5
+    helm repo add istio $REPO
+
+    STATUS_CMD=`echo $?`
+    CHECK_REPO_CMD=`helm repo list | grep $REPO | wc -l`
+  done
+}
+
+# Create istio-system namespace
+create_namespace() {
+  NAMESPACE=$1
+  kubectl create ns ${NAMESPACE}
+
+  STATUS_CMD=`echo $?`
+  while [[ $STATUS_CMD != 0 ]]
+  do
+    sleep 5
+    kubectl create ns ${NAMESPACE}
+    STATUS_CMD=`echo $?`
+  done
+}
+
+# Create CRD need for istio
+create_crd() {
+  NAMESPACE=$1
+  helm install istio-init istio/istio-init -n ${NAMESPACE}
+  CRD_COUNT=`kubectl get crds | grep 'istio.i' | wc -l`
+
+  while [[ ${CRD_COUNT} != 23 ]]
+  do
+    sleep 5
+    CRD_COUNT=`kubectl get crds | grep 'istio.io' | wc -l`
+  done
+
+  echo 'Istio crd create successful'
+}
+
+# Deploy istio related components
+deploy_istio() {
+  NAMESPACE=$1
+  VERSION=$2
+  helm pull istio/istio && tar zxvf istio-${VERSION}.tgz && rm istio-${VERSION}.tgz
+  helm install istio istio -n ${NAMESPACE}
+
+  check() {
+     kubectl -n ${NAMESPACE}  get deploy | grep istio | awk '{print "deployment/"$1}' | while read line ;
+     do
+       kubectl rollout status $line -n ${NAMESPACE} --timeout 3m
+     done
+  }
+  check
+
+  echo "Istio is deployed successful"
+}
+
+add_mixer_template() {
+  VERSION=$1
+  kubectl apply -f https://raw.githubusercontent.com/istio/istio/$VERSION/mixer/template/metric/template.yaml
+}
+
+main(){
+  ISTIO_VERSION="1.3.3"
+  ISTIO_NAMESPACE="istio-system"
+  add_repo $ISTIO_VERSION
+  if [[ `kubectl get ns | grep $ISTIO_NAMESPACE | wc -l ` == 0 && `kubectl get ns $ISTIO_NAMESPACE | grep -v NAME | wc -l` == 0 ]] ;then
+    create_namespace $ISTIO_NAMESPACE
+  fi
+  create_crd $ISTIO_NAMESPACE
+  deploy_istio $ISTIO_NAMESPACE $ISTIO_VERSION
+  add_mixer_template $ISTIO_VERSION
+}
+
+main
diff --git a/install/deploy/skywalking-deploy.sh b/install/deploy/skywalking-deploy.sh
new file mode 100644
index 0000000..6c82ba4
--- /dev/null
+++ b/install/deploy/skywalking-deploy.sh
@@ -0,0 +1,56 @@
+#!/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.
+
+set -e
+
+CHART_PATH="../kubernetes/helm"
+DPELOY_NAMESPACE="istio-system"
+NEED_CHECK_PREFIX="deployment/skywalking-skywalking-"
+ALS_ENABLED=true
+MIXER_ENABLED=true
+
+cd ${CHART_PATH}
+
+and_stable_repo(){
+  STABLE_REPO="https://kubernetes-charts.storage.googleapis.com/"
+  helm repo add stable $STABLE_REPO
+
+  STATUS_CMD=`echo $?`
+  CHECK_REPO_CMD=`helm repo list | grep $STABLE_REPO | wc -l`
+  echo "$STATUS_CMD"
+  echo "$CHECK_REPO_CMD"
+  while [[ $STATUS_CMD != 0 && $CHECK_REPO_CMD -ge 1 ]]
+  do
+    sleep 5
+    helm repo add stable $STABLE_REPO
+
+    STATUS_CMD=`echo $?`
+    CHECK_REPO_CMD=`helm repo list | grep $STABLE_REPO | wc -l`
+  done
+}
+
+and_stable_repo
+
+helm dep up skywalking
+
+helm -n $DPELOY_NAMESPACE install skywalking skywalking --set oap.istio.adapter.enabled=$MIXER_ENABLED --set oap.envoy.als.enabled=$ALS_ENABLED
+
+for component in $NEED_CHECK_PREFIX"oap" $NEED_CHECK_PREFIX"ui" ; do
+  kubectl -n istio-system rollout status $component --timeout 3m
+done
+
+echo "SkyWalking deployed successfully"
diff --git a/install/kubernetes/helm/skywalking/Chart.yaml b/install/kubernetes/helm/skywalking/Chart.yaml
index ca103d2..b4aff3c 100644
--- a/install/kubernetes/helm/skywalking/Chart.yaml
+++ b/install/kubernetes/helm/skywalking/Chart.yaml
@@ -30,6 +30,6 @@ maintainers:
 
 dependencies:
   - name: elasticsearch
-    version: ~1.28.2
+    version: ~1.32.0
     repository: https://kubernetes-charts.storage.googleapis.com/
     condition: elasticsearch.enabled
\ No newline at end of file
diff --git a/install/kubernetes/helm/skywalking/README.md b/install/kubernetes/helm/skywalking/README.md
index 8fa9435..95bfd24 100644
--- a/install/kubernetes/helm/skywalking/README.md
+++ b/install/kubernetes/helm/skywalking/README.md
@@ -74,6 +74,7 @@ The following table lists the configurable parameters of the Skywalking chart an
 | `oap.tolerations`                     | OAP tolerations                                                    | `[]`                                |
 | `oap.resources`                       | OAP node resources requests & limits                               | `{} - cpu limit must be an integer` |
 | `oap.envoy.als.enabled`               | Open envoy als                                                     | `false`                             |
+| `oap.istio.adapter.enabled`           | Open istio adapter                                                 | `false`                             |
 | `oap.env`                             | OAP environment variables                                          | `[]`                                |
 | `ui.name`                             | Web UI deployment name                                             | `ui`                                |
 | `ui.replicas`                         | Web UI k8s deployment replicas                                     | `1`                                 |
diff --git a/install/kubernetes/helm/skywalking/templates/NOTES.txt b/install/kubernetes/helm/skywalking/templates/NOTES.txt
index 1438d44..8d93db7 100644
--- a/install/kubernetes/helm/skywalking/templates/NOTES.txt
+++ b/install/kubernetes/helm/skywalking/templates/NOTES.txt
@@ -15,6 +15,13 @@ See the License for the specific language governing permissions and
 limitations under the License.
 */}}
 
+
+Thank you for installing {{ .Chart.Name }}.
+
+Your release is named {{ .Release.Name }}.
+
+Learn more, please visit https://skywalking.apache.org/
+
 Get the UI URL by running these commands:
 {{- if .Values.ui.ingress.enabled }}
 {{- range .Values.ui.ingress.hosts }}
diff --git a/install/kubernetes/helm/skywalking/templates/istio-adapter/adapter.yaml b/install/kubernetes/helm/skywalking/templates/istio-adapter/adapter.yaml
new file mode 100644
index 0000000..4a74d25
--- /dev/null
+++ b/install/kubernetes/helm/skywalking/templates/istio-adapter/adapter.yaml
@@ -0,0 +1,27 @@
+# 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.
+
+{{- if .Values.oap.istio.adapter.enabled }}
+apiVersion: "config.istio.io/v1alpha2"
+kind: adapter
+metadata:
+  name: skywalking-adapter
+spec:
+  description:
+  session_based: false
+  templates:
+    - metric
+{{- end}}
diff --git a/install/kubernetes/helm/skywalking/templates/istio-adapter/handler.yaml b/install/kubernetes/helm/skywalking/templates/istio-adapter/handler.yaml
new file mode 100644
index 0000000..3ce913a
--- /dev/null
+++ b/install/kubernetes/helm/skywalking/templates/istio-adapter/handler.yaml
@@ -0,0 +1,26 @@
+# 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.
+
+{{- if .Values.oap.istio.adapter.enabled }}
+apiVersion: "config.istio.io/v1alpha2"
+kind: handler
+metadata:
+  name: skywalking-handler
+spec:
+  adapter: skywalking-adapter
+  connection:
+    address: {{ template "skywalking.oap.fullname" . }}"."{{ .Release.Namespace }}".svc.cluster.local:11800"
+{{- end }}
\ No newline at end of file
diff --git a/install/kubernetes/helm/skywalking/templates/istio-adapter/instance.yaml b/install/kubernetes/helm/skywalking/templates/istio-adapter/instance.yaml
new file mode 100644
index 0000000..11a5f8c
--- /dev/null
+++ b/install/kubernetes/helm/skywalking/templates/istio-adapter/instance.yaml
@@ -0,0 +1,42 @@
+# 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.
+
+# instance for template metric
+{{- if .Values.oap.istio.adapter.enabled }}
+apiVersion: "config.istio.io/v1alpha2"
+kind: instance
+metadata:
+  name: skywalking-metric
+spec:
+  template: metric
+  params:
+    value: request.size | 0
+    dimensions:
+      sourceService: source.workload.name | ""
+      sourceNamespace: source.workload.namespace | ""
+      sourceUID: source.uid | ""
+      destinationService: destination.workload.name | ""
+      destinationNamespace: destination.workload.namespace | ""
+      destinationUID: destination.uid | ""
+      requestMethod: request.method | ""
+      requestPath: request.path | ""
+      requestScheme: request.scheme | ""
+      requestTime: request.time
+      responseTime: response.time
+      responseCode: response.code | 200
+      reporter: conditional((context.reporter.kind | "inbound") == "outbound", "source", "destination")
+      apiProtocol: api.protocol | ""
+{{- end }}
\ No newline at end of file
diff --git a/install/kubernetes/helm/skywalking/templates/istio-adapter/rule.yaml b/install/kubernetes/helm/skywalking/templates/istio-adapter/rule.yaml
new file mode 100644
index 0000000..5949dc2
--- /dev/null
+++ b/install/kubernetes/helm/skywalking/templates/istio-adapter/rule.yaml
@@ -0,0 +1,28 @@
+# 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.
+
+# rule to dispatch to handler sw
+{{- if .Values.oap.istio.adapter.enabled }}
+apiVersion: "config.istio.io/v1alpha2"
+kind: rule
+metadata:
+  name: swmetric-rule
+spec:
+  actions:
+    - handler: skywalking-handler.istio-system
+      instances:
+        - skywalking-metric
+{{- end }}
\ No newline at end of file
diff --git a/install/kubernetes/helm/skywalking/values.yaml b/install/kubernetes/helm/skywalking/values.yaml
index f97fdb9..8201c37 100644
--- a/install/kubernetes/helm/skywalking/values.yaml
+++ b/install/kubernetes/helm/skywalking/values.yaml
@@ -50,6 +50,9 @@ oap:
     als:
       enabled: false
       # more envoy ALS ,please refer to https://github.com/apache/skywalking/blob/master/docs/en/setup/envoy/als_setting.md#observe-service-mesh-through-als
+  istio:
+    adapter:
+      enabled: false
   env:
     # more env, please refer to https://hub.docker.com/r/apache/skywalking-oap-server
     # or https://github.com/apache/skywalking-docker/blob/master/6/6.4/oap/README.md#sw_telemetry