Skip to content

Commit 43a7e84

Browse files
Support liveness in backend config in branch 0.21 (#772)
* Add liveness in backend config (#767) * Add liveness config in backendconfig * Add ci * Add pod field * Fix the error that backendconfig doesn't work when no env specified (#770) * Fix the error that backendconfig doesn't work when no env specified * fix ci * fix ci * Install gcompat in java runner images (#761) * Install gcompat in java runner images * Bump go to 1.22.4 * Fix oauth2 * Fix oauth2 settings * Disable legacy oauth2 params test case * Add testcase for google pubsub io * Set gsa credential * Set GSA credential * fix ci * print expected result
1 parent b7d924a commit 43a7e84

File tree

61 files changed

+3310
-205
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

61 files changed

+3310
-205
lines changed

.ci/clusters/global_backend_config.yaml

+6-1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,11 @@ kind: BackendConfig
33
metadata:
44
name: global-backend-config
55
spec:
6+
autoUpdate: true
67
env:
78
global1: globalvalue1
8-
shared1: fromglobal
9+
shared1: fromglobal
10+
pod:
11+
liveness:
12+
initialDelaySeconds: 10
13+
periodSeconds: 30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
apiVersion: compute.functionmesh.io/v1alpha1
2+
kind: BackendConfig
3+
metadata:
4+
name: global-backend-config
5+
spec:
6+
autoUpdate: true
7+
pod:
8+
liveness:
9+
initialDelaySeconds: 10
10+
periodSeconds: 30

.ci/clusters/values_skywalking_e2e_cluster_with_oauth.yaml

+8-8
Original file line numberDiff line numberDiff line change
@@ -135,12 +135,12 @@ auth:
135135
enabled: true
136136
provider: "oauth2"
137137
oauth2:
138-
issuerUrl: https://sts.windows.net/06a8a086-ae6e-45b5-a22e-ad90de23013e/
139-
issuerUrlParam: https://sts.windows.net/06a8a086-ae6e-45b5-a22e-ad90de23013e/v2.0
140-
audience: api://56c1bd14-3ba7-4804-b47b-d46de6dce33e
141-
audienceParam: api://56c1bd14-3ba7-4804-b47b-d46de6dce33e/.default
142-
brokerClientCredential: '{"client_id":"CLIENT_ID","client_secret":"CLIENT_SECRET","issuer_url":"https://sts.windows.net/06a8a086-ae6e-45b5-a22e-ad90de23013e/v2.0"}'
143-
subjectClaim: appid
144-
adminScope: appid
145-
adminScopeParam: api://56c1bd14-3ba7-4804-b47b-d46de6dce33e/.default
138+
issuerUrl: https://auth.sncloud-stg.dev/
139+
issuerUrlParam: https://auth.sncloud-stg.dev/
140+
audience: "urn:sn:pulsar:sndev:test"
141+
audienceParam: "urn:sn:pulsar:sndev:test"
142+
brokerClientCredential: '{"client_id":"CLIENT_ID","client_secret":"CLIENT_SECRET","issuer_url":"https://auth.sncloud-stg.dev/"}'
143+
subjectClaim: https://streamnative.io/username
144+
adminScope: https://streamnative.io/username
145+
adminScopeParam: ""
146146
authenticationProviders: io.streamnative.pulsar.broker.authentication.AuthenticationProviderOAuth

.ci/examples/connect/pubsub.nar

28 MB
Binary file not shown.

.ci/helm.sh

+24-1
Original file line numberDiff line numberDiff line change
@@ -598,7 +598,7 @@ function ci::verify_log_topic_with_auth() {
598598
}
599599

600600
function ci::verify_env() {
601-
pod="$1-function-0"
601+
pod=$1
602602
key=$2
603603
expect=$3
604604
result=$(kubectl exec -n ${NAMESPACE} ${pod} -- env | grep "${key}")
@@ -608,4 +608,27 @@ function ci::verify_env() {
608608
return 0
609609
fi
610610
return 1
611+
}
612+
613+
function ci::verify_liveness_probe() {
614+
pod=$1
615+
expected=$2
616+
result=$(kubectl get pod $pod -o jsonpath='{.spec.containers[*].livenessProbe}')
617+
echo "liveness probe is $result"
618+
if [[ "$result" != "$expected" ]]; then
619+
echo "failed"
620+
return 1
621+
fi
622+
echo "succeeded"
623+
}
624+
625+
function ci::verify_pod_log() {
626+
pod=$1
627+
log=$2
628+
sleep 30
629+
kubectl logs --tail=-1 $pod | grep "$log"
630+
while [[ $? -ne 0 ]]; do
631+
sleep 5
632+
kubectl logs --tail=-1 $pod | grep "$log"
633+
done
611634
}

.ci/tests/integration-oauth2/cases/batch-source/manifests.yaml

+4-6
Original file line numberDiff line numberDiff line change
@@ -37,16 +37,14 @@ spec:
3737
certSecretKey: ""
3838
authConfig:
3939
oauth2Config:
40-
audience: api://56c1bd14-3ba7-4804-b47b-d46de6dce33e/.default
41-
issuerUrl: https://sts.windows.net/06a8a086-ae6e-45b5-a22e-ad90de23013e/v2.0
42-
scope: api://56c1bd14-3ba7-4804-b47b-d46de6dce33e/.default
40+
audience: urn:sn:pulsar:sndev:test
41+
issuerUrl: https://auth.sncloud-stg.dev/
4342
keySecretName: sn-platform-oauth2-private-key
4443
keySecretKey: auth.json
4544
cleanupAuthConfig:
4645
oauth2Config:
47-
audience: api://56c1bd14-3ba7-4804-b47b-d46de6dce33e/.default
48-
issuerUrl: https://sts.windows.net/06a8a086-ae6e-45b5-a22e-ad90de23013e/v2.0
49-
scope: api://56c1bd14-3ba7-4804-b47b-d46de6dce33e/.default
46+
audience: urn:sn:pulsar:sndev:test
47+
issuerUrl: https://auth.sncloud-stg.dev/
5048
keySecretName: sn-platform-oauth2-private-key
5149
keySecretKey: auth.json
5250
image: streamnative/pulsar-io-batch-data-generator:3.2.2.1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
apiVersion: compute.functionmesh.io/v1alpha1
2+
kind: Source
3+
metadata:
4+
name: test-datagen-source
5+
spec:
6+
className: org.apache.pulsar.io.datagenerator.DataGeneratorSource
7+
clusterName: test-pulsar
8+
forwardSourceMessageProperty: true
9+
image: docker.io/streamnative/pulsar-io-data-generator:3.2.2.1
10+
java:
11+
extraDependenciesDir: /pulsar/lib
12+
jar: connectors/pulsar-io-data-generator-3.2.2.1.nar
13+
minReplicas: 1
14+
name: test-datagen-source
15+
namespace: default
16+
output:
17+
producerConf: {}
18+
topic: public/default/test-datagen-source
19+
typeClassName: org.apache.pulsar.io.datagenerator.Person
20+
processingGuarantee: atleast_once
21+
pulsar:
22+
authConfig:
23+
oauth2Config:
24+
audience: urn:sn:pulsar:sndev:test
25+
issuerUrl: https://auth.sncloud-stg.dev/
26+
keySecretName: sn-platform-oauth2-private-key
27+
keySecretKey: auth.json
28+
pulsarConfig: test-source
29+
replicas: 1
30+
resources:
31+
limits:
32+
cpu: "0.2"
33+
memory: 1.1G
34+
requests:
35+
cpu: "0.1"
36+
memory: 1G
37+
sourceConfig:
38+
sleepBetweenMessages: "5000"
39+
tenant: public
40+
---
41+
apiVersion: v1
42+
kind: ConfigMap
43+
metadata:
44+
name: test-source
45+
data:
46+
webServiceURL: http://sn-platform-pulsar-broker.default.svc.cluster.local:8080
47+
brokerServiceURL: pulsar://sn-platform-pulsar-broker.default.svc.cluster.local:6650
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
apiVersion: compute.functionmesh.io/v1alpha1
2+
kind: BackendConfig
3+
metadata:
4+
name: backend-config
5+
namespace: default
6+
spec:
7+
env:
8+
namespaced1: namespacedvalue1
9+
shared1: fromnamespace
10+
podenv: backendconfigvalue
11+
pod:
12+
liveness:
13+
initialDelaySeconds: 30
14+
periodSeconds: 10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,167 @@
1+
#!/usr/bin/env bash
2+
#
3+
# Licensed to the Apache Software Foundation (ASF) under one
4+
# or more contributor license agreements. See the NOTICE file
5+
# distributed with this work for additional information
6+
# regarding copyright ownership. The ASF licenses this file
7+
# to you under the Apache License, Version 2.0 (the
8+
# "License"); you may not use this file except in compliance
9+
# with the License. You may obtain a copy of the License at
10+
#
11+
# http://www.apache.org/licenses/LICENSE-2.0
12+
#
13+
# Unless required by applicable law or agreed to in writing,
14+
# software distributed under the License is distributed on an
15+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16+
# KIND, either express or implied. See the License for the
17+
# specific language governing permissions and limitations
18+
# under the License.
19+
#
20+
21+
set -e
22+
23+
E2E_DIR=$(dirname "$0")
24+
BASE_DIR=$(cd "${E2E_DIR}"/../../../../..;pwd)
25+
PULSAR_NAMESPACE=${PULSAR_NAMESPACE:-"default"}
26+
PULSAR_RELEASE_NAME=${PULSAR_RELEASE_NAME:-"sn-platform"}
27+
E2E_KUBECONFIG=${E2E_KUBECONFIG:-"/tmp/e2e-k8s.config"}
28+
29+
source "${BASE_DIR}"/.ci/helm.sh
30+
31+
if [ ! "$KUBECONFIG" ]; then
32+
export KUBECONFIG=${E2E_KUBECONFIG}
33+
fi
34+
35+
manifests_file="${BASE_DIR}"/.ci/tests/integration-oauth2/cases/global-and-namespaced-config-without-auto-update/manifests.yaml
36+
mesh_config_file="${BASE_DIR}"/.ci/tests/integration-oauth2/cases/global-and-namespaced-config-without-auto-update/mesh-config.yaml
37+
global_mesh_config_file="${BASE_DIR}"/.ci/clusters/global_backend_config.yaml
38+
39+
kubectl apply -f "${mesh_config_file}" > /dev/null 2>&1
40+
kubectl apply -f "${manifests_file}" > /dev/null 2>&1
41+
42+
verify_fm_result=$(ci::verify_function_mesh test-datagen-source 2>&1)
43+
if [ $? -ne 0 ]; then
44+
echo "$verify_fm_result"
45+
kubectl delete -f "${manifests_file}" > /dev/null 2>&1 || true
46+
exit 1
47+
fi
48+
49+
verify_env_result=$(ci::verify_env "test-datagen-source-source-0" global1 global1=globalvalue1 2>&1)
50+
if [ $? -ne 0 ]; then
51+
echo "$verify_env_result"
52+
kubectl delete -f "${mesh_config_file}" > /dev/null 2>&1
53+
kubectl delete -f "${manifests_file}" > /dev/null 2>&1 || true
54+
exit 1
55+
fi
56+
57+
verify_env_result=$(ci::verify_env "test-datagen-source-source-0" namespaced1 namespaced1=namespacedvalue1 2>&1)
58+
if [ $? -ne 0 ]; then
59+
echo "$verify_env_result"
60+
kubectl delete -f "${mesh_config_file}" > /dev/null 2>&1
61+
kubectl delete -f "${manifests_file}" > /dev/null 2>&1 || true
62+
exit 1
63+
fi
64+
65+
# if global and namespaced config has same key, the value from namespace should be used
66+
verify_env_result=$(ci::verify_env "test-datagen-source-source-0" shared1 shared1=fromnamespace 2>&1)
67+
if [ $? -ne 0 ]; then
68+
echo "$verify_env_result"
69+
kubectl delete -f "${mesh_config_file}" > /dev/null 2>&1
70+
kubectl delete -f "${manifests_file}" > /dev/null 2>&1 || true
71+
exit 1
72+
fi
73+
74+
# verify liveness config
75+
verify_liveness_result=$(ci::verify_liveness_probe test-datagen-source-source-0 '{"failureThreshold":3,"httpGet":{"path":"/","port":9094,"scheme":"HTTP"},"initialDelaySeconds":30,"periodSeconds":10,"successThreshold":1,"timeoutSeconds":10}' 2>&1)
76+
if [ $? -ne 0 ]; then
77+
echo "$verify_liveness_result"
78+
kubectl delete -f "${mesh_config_file}" > /dev/null 2>&1
79+
kubectl delete -f "${manifests_file}" > /dev/null 2>&1 || true
80+
exit 1
81+
fi
82+
83+
# update the namespaced config, it should not trigger the reconcile since the autoUpdate is false
84+
kubectl patch BackendConfig backend-config --type='json' -p='[{"op": "replace", "path": "/spec/env/shared1", "value": "newvalue"}]' > /dev/null 2>&1
85+
sleep 30
86+
87+
verify_env_result=$(ci::verify_env "test-datagen-source-source-0" shared1 shared1=fromnamespace 2>&1)
88+
if [ $? -ne 0 ]; then
89+
echo "$verify_env_result"
90+
kubectl delete -f "${mesh_config_file}" > /dev/null 2>&1
91+
kubectl delete -f "${manifests_file}" > /dev/null 2>&1 || true
92+
exit 1
93+
fi
94+
95+
# delete the namespaced config, the source should not be reconciled since the autoUpdate is false
96+
kubectl delete -f "${mesh_config_file}" > /dev/null 2>&1
97+
sleep 30
98+
99+
verify_env_result=$(ci::verify_env "test-datagen-source-source-0" namespaced1 namespaced1=namespacedvalue1 2>&1)
100+
if [ $? -ne 0 ]; then
101+
echo "$verify_env_result"
102+
kubectl delete -f "${mesh_config_file}" > /dev/null 2>&1
103+
kubectl delete -f "${manifests_file}" > /dev/null 2>&1 || true
104+
exit 1
105+
fi
106+
107+
verify_env_result=$(ci::verify_env "test-datagen-source-source-0" shared1 shared1=fromnamespace 2>&1)
108+
if [ $? -ne 0 ]; then
109+
echo "$verify_env_result"
110+
kubectl delete -f "${mesh_config_file}" > /dev/null 2>&1
111+
kubectl delete -f "${manifests_file}" > /dev/null 2>&1 || true
112+
exit 1
113+
fi
114+
115+
verify_liveness_result=$(ci::verify_liveness_probe test-datagen-source-source-0 '{"failureThreshold":3,"httpGet":{"path":"/","port":9094,"scheme":"HTTP"},"initialDelaySeconds":30,"periodSeconds":10,"successThreshold":1,"timeoutSeconds":10}' 2>&1)
116+
if [ $? -ne 0 ]; then
117+
echo "$verify_liveness_result"
118+
kubectl delete -f "${manifests_file}" > /dev/null 2>&1 || true
119+
exit 1
120+
fi
121+
122+
# delete the global config, the source should be reconciled since the autoUpdate is true in the global config
123+
kubectl delete -f "${global_mesh_config_file}" -n $FUNCTION_MESH_NAMESPACE > /dev/null 2>&1 || true
124+
sleep 30
125+
126+
verify_fm_result=$(ci::verify_function_mesh test-datagen-source 2>&1)
127+
if [ $? -ne 0 ]; then
128+
echo "$verify_fm_result"
129+
kubectl delete -f "${manifests_file}" > /dev/null 2>&1 || true
130+
exit 1
131+
fi
132+
133+
verify_env_result=$(ci::verify_env "test-datagen-source-source-0" global1 "" 2>&1)
134+
if [ $? -ne 0 ]; then
135+
echo "$verify_env_result"
136+
kubectl delete -f "${mesh_config_file}" > /dev/null 2>&1
137+
kubectl delete -f "${manifests_file}" > /dev/null 2>&1 || true
138+
exit 1
139+
fi
140+
141+
verify_env_result=$(ci::verify_env "test-datagen-source-source-0" namespaced1 "" 2>&1)
142+
if [ $? -ne 0 ]; then
143+
echo "$verify_env_result"
144+
kubectl delete -f "${mesh_config_file}" > /dev/null 2>&1
145+
kubectl delete -f "${manifests_file}" > /dev/null 2>&1 || true
146+
exit 1
147+
fi
148+
149+
verify_env_result=$(ci::verify_env "test-datagen-source-source-0" shared1 "" 2>&1)
150+
if [ $? -ne 0 ]; then
151+
echo "$verify_env_result"
152+
kubectl delete -f "${mesh_config_file}" > /dev/null 2>&1
153+
kubectl delete -f "${manifests_file}" > /dev/null 2>&1 || true
154+
exit 1
155+
fi
156+
157+
# it should use liveness config from namespaced config
158+
verify_liveness_result=$(ci::verify_liveness_probe test-datagen-source-source-0 "" 2>&1)
159+
if [ $? -eq 0 ]; then
160+
echo "e2e-test: ok" | yq eval -
161+
else
162+
echo "$verify_liveness_result"
163+
kubectl delete -f "${manifests_file}" > /dev/null 2>&1 || true
164+
exit 1
165+
fi
166+
167+
kubectl delete -f "${manifests_file}" > /dev/null 2>&1 || true
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
apiVersion: compute.functionmesh.io/v1alpha1
2+
kind: Sink
3+
metadata:
4+
name: test-datagen-sink
5+
spec:
6+
autoAck: true
7+
className: org.apache.pulsar.io.datagenerator.DataGeneratorPrintSink
8+
clusterName: test-pulsar
9+
image: docker.io/streamnative/pulsar-io-data-generator:3.2.2.1
10+
input:
11+
sourceSpecs:
12+
public/default/datagen:
13+
receiverQueueSize: 1000
14+
topics:
15+
- public/default/datagen
16+
typeClassName: org.apache.pulsar.io.datagenerator.Person
17+
java:
18+
extraDependenciesDir: /pulsar/lib
19+
jar: connectors/pulsar-io-data-generator-3.2.2.1.nar
20+
minReplicas: 1
21+
namespace: default
22+
processingGuarantee: atleast_once
23+
sinkConfig: {}
24+
pulsar:
25+
authConfig:
26+
oauth2Config:
27+
audience: urn:sn:pulsar:sndev:test
28+
issuerUrl: https://auth.sncloud-stg.dev/
29+
keySecretName: sn-platform-oauth2-private-key
30+
keySecretKey: auth.json
31+
pulsarConfig: test-sink
32+
replicas: 1
33+
resources:
34+
limits:
35+
cpu: "0.2"
36+
memory: 1.1G
37+
requests:
38+
cpu: "0.1"
39+
memory: 1G
40+
subscriptionName: mysub
41+
subscriptionPosition: latest
42+
tenant: public
43+
---
44+
apiVersion: v1
45+
kind: ConfigMap
46+
metadata:
47+
name: test-sink
48+
data:
49+
webServiceURL: http://sn-platform-pulsar-broker.default.svc.cluster.local:8080
50+
brokerServiceURL: pulsar://sn-platform-pulsar-broker.default.svc.cluster.local:6650
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
apiVersion: compute.functionmesh.io/v1alpha1
2+
kind: BackendConfig
3+
metadata:
4+
name: backend-config
5+
namespace: kube-system
6+
spec:
7+
autoUpdate: true
8+
pod:
9+
liveness:
10+
initialDelaySeconds: 50
11+
periodSeconds: 60

0 commit comments

Comments
 (0)