This is an automated email from the ASF dual-hosted git repository.
jooks pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/shenyu.git
The following commit(s) were added to refs/heads/master by this push:
new ac555ae7a [ISSUE #3513] [Part 2] init k8s integration test workflow
about "shenyu-examples-http" (#3989)
ac555ae7a is described below
commit ac555ae7a5ab73043b475bc7e40041d9c79950a2
Author: Jiageng <[email protected]>
AuthorDate: Sun Sep 25 11:32:16 2022 +0800
[ISSUE #3513] [Part 2] init k8s integration test workflow about
"shenyu-examples-http" (#3989)
* feat: add k8s manifest (pass healthcheck)
* add: k8s integration test workflow for examples-http
* update: add gateway -> http checker, use k8s manifest instead of helm
charts
* update: add failure judge
* refact: script => k8s/script
---
.github/workflows/k8s-examples-http.yml | 89 +++++++++++++++++++++
.../shenyu-examples-http/k8s/script/healthcheck.sh | 48 ++++++++++++
.../shenyu-examples-http/k8s/script/services.list | 19 +++++
.../shenyu-examples-http/k8s/shenyu-deployment.yml | 82 +++++++++++++++++++
.../k8s/shenyu-examples-http-deployment.yml | 91 ++++++++++++++++++++++
.../k8s/shenyu-examples-http-service.yml | 62 +++++++++++++++
.../shenyu-examples-http/k8s/shenyu-service.yml | 52 +++++++++++++
7 files changed, 443 insertions(+)
diff --git a/.github/workflows/k8s-examples-http.yml
b/.github/workflows/k8s-examples-http.yml
new file mode 100644
index 000000000..cf3961aa3
--- /dev/null
+++ b/.github/workflows/k8s-examples-http.yml
@@ -0,0 +1,89 @@
+# 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.
+
+name: k8s-examples-http
+
+on:
+ pull_request:
+ push:
+ branches:
+ - master
+
+jobs:
+ k8s-examples-http:
+ runs-on: ubuntu-latest
+ if: (github.repository == 'apache/shenyu')
+ steps:
+ -
+ uses: actions/checkout@v2
+ with:
+ submodules: true
+ -
+ uses: dorny/paths-filter@v2
+ id: filter
+ with:
+ filters: '.github/filters.yml'
+ list-files: json
+ -
+ name: Install k8s
+ if: steps.filter.outputs.changed == 'true'
+ run: |
+ curl -sfL https://get.k3s.io | K3S_KUBECONFIG_MODE=777 sh -
+ cat /etc/rancher/k3s/k3s.yaml
+ mkdir -p ~/.kube
+ cp /etc/rancher/k3s/k3s.yaml ~/.kube/config
+ -
+ name: Cache Maven Repos
+ if: steps.filter.outputs.changed == 'true'
+ uses: actions/cache@v2
+ with:
+ path: ~/.m2/repository
+ key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
+ restore-keys: |
+ ${{ runner.os }}-maven-
+ -
+ uses: actions/setup-java@v1
+ if: steps.filter.outputs.changed == 'true'
+ with:
+ java-version: 8
+ -
+ name: Build with Maven
+ if: steps.filter.outputs.changed == 'true'
+ run: ./mvnw -B clean install -Prelease,docker
-Dmaven.javadoc.skip=true -Dmaven.test.skip=true
+ -
+ name: Build examples
+ if: steps.filter.outputs.changed == 'true'
+ run: ./mvnw -B clean install -Pexample -Dmaven.javadoc.skip=true
-Dmaven.test.skip=true -f ./shenyu-examples/pom.xml
+ -
+ name: Build k8s Cluster
+ if: steps.filter.outputs.changed == 'true'
+ run: |
+ docker save apache/shenyu-admin:latest
apache/shenyu-bootstrap:latest shenyu-examples-http:latest | sudo k3s ctr
images import -
+ kubectl apply -f
./shenyu-examples/shenyu-examples-http/k8s/shenyu-deployment.yml
+ kubectl apply -f
./shenyu-examples/shenyu-examples-http/k8s/shenyu-service.yml
+ kubectl apply -f
./shenyu-examples/shenyu-examples-http/k8s/shenyu-examples-http-deployment.yml
+ kubectl apply -f
./shenyu-examples/shenyu-examples-http/k8s/shenyu-examples-http-service.yml
+ -
+ name: Wait for k8s Cluster Start up
+ if: steps.filter.outputs.changed == 'true'
+ run: |
+ bash ./shenyu-examples/shenyu-examples-http/k8s/script/healthcheck.sh
+ -
+ name: Cluster Test after Healthcheck
+ if: steps.filter.outputs.changed == 'true'
+ run: |
+ kubectl get all
+ kubectl get events --all-namespaces
+ kubectl logs -l all=shenyu-examples-http
diff --git a/shenyu-examples/shenyu-examples-http/k8s/script/healthcheck.sh
b/shenyu-examples/shenyu-examples-http/k8s/script/healthcheck.sh
new file mode 100644
index 000000000..19d6eaf9c
--- /dev/null
+++ b/shenyu-examples/shenyu-examples-http/k8s/script/healthcheck.sh
@@ -0,0 +1,48 @@
+#!/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.
+#
+
+PRGDIR=`dirname "$0"`
+for service in `grep -v -E "^$|^#" ${PRGDIR}/services.list`
+do
+ for loop in `seq 1 30`
+ do
+ status=`curl -o /dev/null -s -w %{http_code} $service`
+ echo -e "curl $service response $status"
+
+ if [ $status -eq 200 ]; then
+ break
+ fi
+
+ sleep 2
+ done
+done
+
+sleep 5
+
+status=`curl -s -o /dev/null -w "%{http_code}" -X POST -H
"Content-Type:application/json" http://localhost:31195/http/order/save --data
'{"name":"test", "id": 123}'`
+
+sleep 3
+
+if [ $status -eq 200 ]; then
+ echo -e "Success to send request: $status"
+ echo -e "\n-------------------"
+ exit 0
+fi
+echo -e "Failed to send request from shenyu-bootstrap to http example: $status"
+echo -e "\n-------------------"
+exit 1
diff --git a/shenyu-examples/shenyu-examples-http/k8s/script/services.list
b/shenyu-examples/shenyu-examples-http/k8s/script/services.list
new file mode 100644
index 000000000..fb77cd36a
--- /dev/null
+++ b/shenyu-examples/shenyu-examples-http/k8s/script/services.list
@@ -0,0 +1,19 @@
+# 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.
+
+http://localhost:31095/actuator/health
+http://localhost:31195/actuator/health
+http://localhost:31189/test/path/123?name=tom
diff --git a/shenyu-examples/shenyu-examples-http/k8s/shenyu-deployment.yml
b/shenyu-examples/shenyu-examples-http/k8s/shenyu-deployment.yml
new file mode 100644
index 000000000..89dbd9950
--- /dev/null
+++ b/shenyu-examples/shenyu-examples-http/k8s/shenyu-deployment.yml
@@ -0,0 +1,82 @@
+# 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: apps/v1
+kind: Deployment
+metadata:
+ name: shenyu-admin
+ labels:
+ app: shenyu-admin
+ all: shenyu-examples-http
+spec:
+ replicas: 1
+ selector:
+ matchLabels:
+ app: shenyu-admin
+ all: shenyu-examples-http
+ template:
+ metadata:
+ labels:
+ app: shenyu-admin
+ all: shenyu-examples-http
+ spec:
+ containers:
+ - name: shenyu-admin
+ image: apache/shenyu-admin:latest
+ resources: {}
+ env:
+ - name: SPRING_PROFILES_ACTIVE
+ value: h2
+ - name: shenyu.database.init_script
+ value: sql-script/h2/schema.sql
+ ports:
+ - containerPort: 9095
+ imagePullPolicy: IfNotPresent
+ restartPolicy: Always
+status: {}
+
+---
+apiVersion: apps/v1
+kind: Deployment
+metadata:
+ name: shenyu-bootstrap
+ labels:
+ app: shenyu-bootstrap
+ all: shenyu-examples-http
+spec:
+ replicas: 1
+ selector:
+ matchLabels:
+ app: shenyu-bootstrap
+ all: shenyu-examples-http
+ template:
+ metadata:
+ labels:
+ app: shenyu-bootstrap
+ all: shenyu-examples-http
+ spec:
+ containers:
+ - name: shenyu-bootstrap
+ image: apache/shenyu-bootstrap:latest
+ resources: {}
+ env:
+ - name: shenyu.sync.websocket.urls
+ value: ws://shenyu-admin:9095/websocket
+ ports:
+ - containerPort: 9195
+ imagePullPolicy: IfNotPresent
+ restartPolicy: Always
+status: {}
\ No newline at end of file
diff --git
a/shenyu-examples/shenyu-examples-http/k8s/shenyu-examples-http-deployment.yml
b/shenyu-examples/shenyu-examples-http/k8s/shenyu-examples-http-deployment.yml
new file mode 100644
index 000000000..0ac19766e
--- /dev/null
+++
b/shenyu-examples/shenyu-examples-http/k8s/shenyu-examples-http-deployment.yml
@@ -0,0 +1,91 @@
+# 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: apps/v1
+kind: Deployment
+metadata:
+ name: shenyu-examples-http-deployment
+ labels:
+ app: shenyu-examples-http
+ all: shenyu-examples-http
+spec:
+ replicas: 1
+ selector:
+ matchLabels:
+ app: shenyu-examples-http
+ all: shenyu-examples-http
+ strategy: {}
+ template:
+ metadata:
+ labels:
+ app: shenyu-examples-http
+ all: shenyu-examples-http
+ spec:
+ containers:
+ - image: shenyu-examples-http
+ name: shenyu-examples-http
+ livenessProbe:
+ exec:
+ command:
+ - wget -q -O - http://localhost:8011/actuator/health | grep UP
|| exit 1
+ initialDelaySeconds: 10
+ failureThreshold: 3
+ timeoutSeconds: 2
+ env:
+ - name: shenyu.register.serverLists
+ value: http://shenyu-admin:9095
+ ports:
+ - containerPort: 8189
+ imagePullPolicy: IfNotPresent
+ restartPolicy: Always
+status: {}
+
+---
+apiVersion: apps/v1
+kind: Deployment
+metadata:
+ labels:
+ app: shenyu-zk
+ all: shenyu-examples-http
+ name: shenyu-zk
+spec:
+ replicas: 1
+ selector:
+ matchLabels:
+ app: shenyu-zk
+ all: shenyu-examples-http
+ strategy: {}
+ template:
+ metadata:
+ labels:
+ app: shenyu-zk
+ all: shenyu-examples-http
+ spec:
+ containers:
+ - image: zookeeper:3.5
+ name: shenyu-zk
+ resources: {}
+ ports:
+ - containerPort: 2181
+ name: client
+ - containerPort: 2888
+ name: server
+ - containerPort: 3888
+ name: leader-election
+ - containerPort: 8080
+ name: website
+ restartPolicy: Always
+status: {}
diff --git
a/shenyu-examples/shenyu-examples-http/k8s/shenyu-examples-http-service.yml
b/shenyu-examples/shenyu-examples-http/k8s/shenyu-examples-http-service.yml
new file mode 100644
index 000000000..a0dca62e4
--- /dev/null
+++ b/shenyu-examples/shenyu-examples-http/k8s/shenyu-examples-http-service.yml
@@ -0,0 +1,62 @@
+# 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: shenyu-examples-http-service
+ labels:
+ app: shenyu-examples-http
+ all: shenyu-examples-http
+spec:
+ selector:
+ app: shenyu-examples-http
+ all: shenyu-examples-http
+ type: NodePort
+ ports:
+ - name: "8189"
+ port: 8189
+ targetPort: 8189
+ nodePort: 31189
+status:
+ loadBalancer: {}
+
+---
+apiVersion: v1
+kind: Service
+metadata:
+ name: shenyu-zk
+ labels:
+ app: shenyu-zk
+ all: shenyu-examples-http
+spec:
+ type: NodePort
+ selector:
+ app: shenyu-zk
+ all: shenyu-examples-http
+ ports:
+ - name: "client"
+ port: 2181
+ targetPort: 2181
+ - name: "server"
+ port: 2888
+ targetPort: 2888
+ - name: "election"
+ port: 3888
+ targetPort: 3888
+ - name: "website"
+ port: 8080
+ targetPort: 8080
diff --git a/shenyu-examples/shenyu-examples-http/k8s/shenyu-service.yml
b/shenyu-examples/shenyu-examples-http/k8s/shenyu-service.yml
new file mode 100644
index 000000000..7d288acca
--- /dev/null
+++ b/shenyu-examples/shenyu-examples-http/k8s/shenyu-service.yml
@@ -0,0 +1,52 @@
+# 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: shenyu-admin
+ labels:
+ app: shenyu-admin
+ all: shenyu-examples-http
+spec:
+ type: NodePort
+ selector:
+ app: shenyu-admin
+ all: shenyu-examples-http
+ ports:
+ - name: "9095"
+ port: 9095
+ targetPort: 9095
+ nodePort: 31095
+
+---
+apiVersion: v1
+kind: Service
+metadata:
+ name: shenyu-bootstrap
+ labels:
+ app: shenyu-bootstrap
+ all: shenyu-examples-http
+spec:
+ type: NodePort
+ selector:
+ app: shenyu-bootstrap
+ all: shenyu-examples-http
+ ports:
+ - name: "9195"
+ port: 9195
+ targetPort: 9195
+ nodePort: 31195
\ No newline at end of file