You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@skywalking.apache.org by wu...@apache.org on 2020/03/23 15:14:40 UTC

[skywalking-kubernetes] branch master updated: Chart Release Deploy CI (#42)

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

wusheng pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/skywalking-kubernetes.git


The following commit(s) were added to refs/heads/master by this push:
     new 3bcc983  Chart Release Deploy CI (#42)
3bcc983 is described below

commit 3bcc98303611a1e3e9ee70c4a0724cee1b38db6f
Author: innerpeacez <in...@gmail.com>
AuthorDate: Mon Mar 23 23:14:33 2020 +0800

    Chart Release Deploy CI (#42)
    
    * chart deploy ci
    
    * rename
    
    * fix
    
    * fix
    
    * fix
    
    * fix
    
    * fix
    
    * fix
    
    * fix
    
    * fix
    
    * fix
    
    * fix
    
    * fix
    
    * fix
    
    * fix
    
    * fix
    
    * fix
    
    * rm useless things
    
    * fix
    
    * fix
    
    * fix
    
    * fix
    
    * fix
    
    Co-authored-by: 吴晟 Wu Sheng <wu...@foxmail.com>
---
 .github/workflows/chart-deploy-ci.yaml |  26 ++++++++
 test/scripts/clean.sh                  |  28 ++++++++
 test/scripts/minikube.sh               | 114 +++++++++++++++++++++++++++++++++
 test/scripts/pre.sh                    |  83 ++++++++++++++++++++++++
 test/scripts/skywalking-deploy.sh      | 105 ++++++++++++++++++++++++++++++
 5 files changed, 356 insertions(+)

diff --git a/.github/workflows/chart-deploy-ci.yaml b/.github/workflows/chart-deploy-ci.yaml
index cc60f8e..e909c76 100644
--- a/.github/workflows/chart-deploy-ci.yaml
+++ b/.github/workflows/chart-deploy-ci.yaml
@@ -24,3 +24,29 @@ on:
     tags:
       - 'v*'
 
+env:
+  SCRIPTS_DIR: ./test/scripts
+  LOG_DIR: /tmp/skywalking
+jobs:
+  build:
+    runs-on: ubuntu-16.04
+    steps:
+      - uses: actions/checkout@v2
+      - name: Prepare enviroment
+        run: |
+          bash ${SCRIPTS_DIR}/pre.sh
+          mkdir -p ${LOG_DIR}
+      - name: Start minikube
+        run: bash ${SCRIPTS_DIR}/minikube.sh start > ${LOG_DIR}/minikube-start-log.txt 2>&1 &
+      - name: Wating minikube ready
+        run: bash ${SCRIPTS_DIR}/minikube.sh wait
+      - name: Setup tunnel
+        run: minikube tunnel --log_dir=${LOG_DIR} &
+      - name: SW And ES install
+        run: bash ${SCRIPTS_DIR}/skywalking-deploy.sh
+      - uses: actions/upload-artifact@v1.0.0
+        if: always()
+        with:
+          name: logs
+          path: /tmp/skywalking
+
diff --git a/test/scripts/clean.sh b/test/scripts/clean.sh
new file mode 100755
index 0000000..9de476b
--- /dev/null
+++ b/test/scripts/clean.sh
@@ -0,0 +1,28 @@
+#!/usr/bin/env 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
+
+CONTAINER_NAME=$1
+[[ "${CONTAINER_NAME}" == "" ]] && exit 1
+
+docker ps | grep -e ${CONTAINER_NAME} | awk '{print $1}' | xargs docker stop
+docker ps -a | grep -e ${CONTAINER_NAME} | awk '{print $1}' | xargs docker rm
diff --git a/test/scripts/minikube.sh b/test/scripts/minikube.sh
new file mode 100755
index 0000000..73daf67
--- /dev/null
+++ b/test/scripts/minikube.sh
@@ -0,0 +1,114 @@
+#!/usr/bin/env 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 -x
+
+K8S_VER=$2
+if [[ "${K8S_VER}" == "" ]]; then
+    K8S_VER="k8s-v1.15.4"
+fi
+
+function waitMinikube() {
+  set +e
+  kubectl cluster-info
+  # This for loop waits until kubectl can access the api server that Minikube has created.
+  for _ in {1..24}; do # Timeout for 240 seconds.
+    kubectl get po --all-namespaces
+    if [ $? -ne 1 ]; then
+      break
+    fi
+    sleep 10
+  done
+  if ! kubectl get all --all-namespaces; then
+    echo "Kubernetes failed to start"
+    ps ax
+    netstat -an
+    docker images
+    cat /var/lib/localkube/localkube.err
+    printf '\n\n\n'
+    kubectl cluster-info dump
+    exit 1
+  fi
+
+  echo "Minikube is running"
+
+  for _ in {1..6}; do # Timeout for 60 seconds.
+    echo "$(sudo -E minikube ip) minikube.local" | sudo tee -a /etc/hosts
+    ip=$(cat /etc/hosts | grep minikube.local | cut -d' ' -f1 | xargs)
+    if [ -n "$ip" ]; then
+      break
+    fi
+    sleep 10
+  done
+
+  ip=$(cat /etc/hosts | grep minikube.local | cut -d' ' -f1 | xargs)
+  if [ -n "$ip" ]; then
+    echo "minikube.local is mapped to $ip"
+  else
+    exit 1
+  fi
+}
+
+# startMinikubeNone starts real kubernetes minikube with none driver. This requires `sudo`.
+function startMinikubeNone() {
+  export MINIKUBE_WANTUPDATENOTIFICATION=false
+  export MINIKUBE_WANTREPORTERRORPROMPT=false
+  export MINIKUBE_HOME=$HOME
+  export CHANGE_MINIKUBE_NONE_USER=true
+
+  # Troubleshoot problem with Docker build on some CircleCI machines.
+  if [ -f /proc/sys/net/ipv4/ip_forward ]; then
+    echo "IP forwarding setting: $(cat /proc/sys/net/ipv4/ip_forward)"
+    echo "My hostname is:"
+    hostname
+    echo "My distro is:"
+    cat /etc/*-release
+    echo "Contents of /etc/sysctl.d/"
+    ls -l /etc/sysctl.d/ || true
+    echo "Contents of /etc/sysctl.conf"
+    grep ip_forward /etc/sysctl.conf
+    echo "Config files setting ip_forward"
+    find /etc/sysctl.d/ -type f -exec grep ip_forward \{\} \; -print
+    if [ "$(cat /proc/sys/net/ipv4/ip_forward)" -eq 0 ]; then
+      whoami
+      echo "Cannot build images without IPv4 forwarding, attempting to turn on forwarding"
+      sudo sysctl -w net.ipv4.ip_forward=1
+      if [ "$(cat /proc/sys/net/ipv4/ip_forward)" -eq 0 ]; then
+        echo "Cannot build images without IPv4 forwarding"
+        exit 1
+      fi
+    fi
+  fi
+
+  sudo -E minikube config set WantUpdateNotification false
+  sudo -E minikube config set WantReportErrorPrompt false
+  sudo -E minikube start --kubernetes-version=${K8S_VER#k8s-} --driver=none
+}
+
+function stopMinikube() {
+  sudo minikube stop
+}
+
+case "$1" in
+  start) startMinikubeNone ;;
+  stop) stopMinikube ;;
+  wait) waitMinikube ;;
+esac
diff --git a/test/scripts/pre.sh b/test/scripts/pre.sh
new file mode 100755
index 0000000..d9f48d8
--- /dev/null
+++ b/test/scripts/pre.sh
@@ -0,0 +1,83 @@
+#!/usr/bin/env 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 -ex
+
+HELMVERSION=$1
+if [[ "${HELMVERSION}" == "" ]]; then
+    HELMVERSION="helm-v3.0.0"
+fi
+
+MINIKUBEVERESION=$2
+if [[ "${MINIKUBEVERESION}" == "" ]]; then
+    MINIKUBEVERESION="minikube-v1.8.0"
+fi
+
+K8SVERSION=$3
+if [[ "${K8SVERSION}" == "" ]]; then
+    K8SVERSION="k8s-v1.15.4"
+fi
+
+# Remove strict host checking. The rest of the file is already populated by the 'add_ssh_keys' step.
+mkdir -p ~/.ssh
+echo -e "\tStrictHostKeyChecking no" >> ~/.ssh/config
+echo -e "\tControlMaster auto" >> ~/.ssh/config
+echo -e "\tControlPersist 3600" >> ~/.ssh/config
+echo -e "\tControlPath ~/.ssh/%r@%h:%p" >> ~/.ssh/config
+
+# Create directory for logs.
+mkdir -p ~/logs
+
+# create directory for e2e artifacts.
+mkdir -p ~/skywalking/test/e2e/artifacts
+
+curl -sSL https://get.helm.sh/${HELMVERSION}-linux-amd64.tar.gz | \
+    sudo tar xz -C /usr/local/bin --strip-components=1 linux-amd64/helm
+
+sudo mkdir -p /usr/local/bin
+curl -sSL "https://storage.googleapis.com/minikube/releases/${MINIKUBEVERESION#minikube-}/minikube-linux-amd64" -o /tmp/minikube
+chmod +x /tmp/minikube
+sudo mv /tmp/minikube /usr/local/bin/minikube
+
+curl -sSL "https://storage.googleapis.com/kubernetes-release/release/${K8SVERSION#k8s-}/bin/linux/amd64/kubectl" -o /tmp/kubectl
+chmod +x /tmp/kubectl
+sudo mv /tmp/kubectl /usr/local/bin/kubectl
+
+sudo apt-get remove -y --purge man-db
+sudo apt-get update
+sudo apt-get install -y \
+    --no-install-recommends --allow-downgrades --allow-remove-essential --allow-change-held-packages \
+    xvfb libgtk-3-0 libnotify4 libgconf-2-4 libnss3 libxss1 libasound2 \
+    apt-transport-https \
+    ca-certificates \
+    curl \
+    gnupg-agent \
+    software-properties-common \
+    openjdk-8-jdk-headless
+curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
+sudo apt-key fingerprint 0EBFCD88
+sudo add-apt-repository \
+   "deb [arch=amd64] https://download.docker.com/linux/ubuntu \
+   $(lsb_release -cs) \
+   stable"
+sudo apt-get update
+sudo apt-cache madison docker-ce
+sudo apt-get install -y docker-ce=5:19.03.8~3-0~ubuntu-xenial docker-ce-cli=5:19.03.8~3-0~ubuntu-xenial containerd.io
diff --git a/test/scripts/skywalking-deploy.sh b/test/scripts/skywalking-deploy.sh
new file mode 100644
index 0000000..11fe990
--- /dev/null
+++ b/test/scripts/skywalking-deploy.sh
@@ -0,0 +1,105 @@
+#!/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
+
+CURRENT_DIR="$(cd "$(dirname $0)"; pwd)"
+
+CHART_PATH="$CURRENT_DIR/../../chart"
+SKYWALKING_ES7_NAMESPACE="skywaling-es7"
+SKYWALKING_ES6_NAMESPACE="skywaling-es6"
+
+ELASTIC_REPO="https://helm.elastic.co/"
+
+cd ${CHART_PATH}
+
+function and_elastic_repo(){
+  ELASTIC_REPO=$1
+  helm repo add elastic ${ELASTIC_REPO}
+
+  STATUS_CMD=`echo $?`
+  CHECK_REPO_CMD=`helm repo list | grep ${ELASTIC_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 elastic ${ELASTIC_REPO}
+
+    STATUS_CMD=`echo $?`
+    CHECK_REPO_CMD=`helm repo list | grep ${ELASTIC_REPO} | wc -l`
+  done
+}
+
+function 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
+}
+
+and_elastic_repo ${ELASTIC_REPO}
+create_namespace ${SKYWALKING_ES6_NAMESPACE}
+create_namespace ${SKYWALKING_ES7_NAMESPACE}
+
+helm repo up
+helm dep up skywalking
+helm lint skywalking
+
+sudo sysctl -w vm.max_map_count=262144
+sudo sysctl -w vm.drop_caches=1
+sudo sysctl -w vm.drop_caches=3
+
+echo "Skywalking ES6 Deploy"
+helm -n $SKYWALKING_ES6_NAMESPACE install skywalking skywalking \
+        --values ./skywalking/values-es6.yaml \
+        --set oap.replicas=1 --set elasticsearch.replicas=1 \
+        --set elasticsearch.minimumMasterNodes=1
+
+echo "Skywalking ES7 Deploy"
+helm -n $SKYWALKING_ES7_NAMESPACE install skywalking skywalking \
+        --set oap.replicas=1 --set elasticsearch.replicas=1
+
+function wait_component_available() {
+  COMPONENT=$1
+  NAMESPACE=$2
+  CONDITIONS=$3
+  kubectl -n ${NAMESPACE} wait ${COMPONENT} --for condition=${CONDITIONS} --timeout=600s
+}
+
+function get_component_name() {
+  NAME=$1
+  NAMESPACE=$2
+  COMPONENT_TYPE=$3
+  name=${COMPONENT_TYPE}/`kubectl get ${COMPONENT_TYPE} -n ${NAMESPACE} | grep ${NAME} | awk '{print $1}'`
+  echo ${name}
+}
+
+SW_ES6_DEPLOY_NAME=`get_component_name oap ${SKYWALKING_ES6_NAMESPACE} deploy`
+SW_ES7_DEPLOY_NAME=`get_component_name oap ${SKYWALKING_ES7_NAMESPACE} deploy`
+
+# wait oap available
+wait_component_available ${SW_ES6_DEPLOY_NAME} ${SKYWALKING_ES6_NAMESPACE} available
+wait_component_available ${SW_ES7_DEPLOY_NAME} ${SKYWALKING_ES7_NAMESPACE} available
+
+echo "SkyWalking deployed successfully"