Skip to content

Commit 9b557b8

Browse files
Release v0.17.3 (#768)
* Add BackendConfig crd to provider cluster wide and namespace wide configs (#734) * Add MeshConfig crd * Reconcile objects automatically when MeshConfig is updated * Add testcases * Fix charts * Use Watches * Add rbac * Fix ci * Fix CVE * Rename MeshConfig to BackendConfig * fix ci * Fix env test * Fix ci * Fix ci * Add liveness in backend config (#767) * Add liveness config in backendconfig * Add ci * Add pod field * release v0.17.3
1 parent d07374a commit 9b557b8

File tree

59 files changed

+3587
-85
lines changed

Some content is hidden

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

59 files changed

+3587
-85
lines changed
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
apiVersion: compute.functionmesh.io/v1alpha1
2+
kind: BackendConfig
3+
metadata:
4+
name: global-backend-config
5+
spec:
6+
env:
7+
global1: globalvalue1
8+
shared1: fromglobal
9+
pod:
10+
liveness:
11+
initialDelaySeconds: 10
12+
periodSeconds: 30

.ci/helm.sh

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -596,3 +596,26 @@ function ci::verify_log_topic_with_auth() {
596596
fi
597597
return 1
598598
}
599+
600+
function ci::verify_env() {
601+
pod="$1-function-0"
602+
key=$2
603+
expect=$3
604+
result=$(kubectl exec -n ${NAMESPACE} ${pod} -- env | grep "${key}")
605+
echo "$result"
606+
echo "$expect"
607+
if [[ "$result" = "$expect" ]]; then
608+
return 0
609+
fi
610+
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+
return 1
620+
fi
621+
}

.ci/olm-tests/catalog.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@ metadata:
55
namespace: olm
66
spec:
77
sourceType: grpc
8-
image: kind-registry:5000/streamnativeio/function-mesh-catalog:v0.17.2
8+
image: kind-registry:5000/streamnativeio/function-mesh-catalog:v0.17.3

.ci/olm-tests/subs.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,6 @@ metadata:
66
spec:
77
channel: alpha
88
name: function-mesh
9-
startingCSV: function-mesh.v0.17.2
9+
startingCSV: function-mesh.v0.17.3
1010
source: my-test-catalog
1111
sourceNamespace: olm

.ci/tests/integration/cases/crypto-function/manifests.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ spec:
99
forwardSourceMessageProperty: true
1010
maxPendingAsyncRequests: 1000
1111
replicas: 1
12-
maxReplicas: 5
1312
logTopic: persistent://public/default/logging-function-logs
1413
input:
1514
topics:
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
apiVersion: compute.functionmesh.io/v1alpha1
2+
kind: Function
3+
metadata:
4+
name: function-sample-env
5+
namespace: default
6+
spec:
7+
image: streamnative/pulsar-functions-java-sample:2.9.2.23
8+
className: org.apache.pulsar.functions.api.examples.ExclamationFunction
9+
forwardSourceMessageProperty: true
10+
maxPendingAsyncRequests: 1000
11+
replicas: 1
12+
maxReplicas: 5
13+
logTopic: persistent://public/default/logging-function-logs
14+
input:
15+
topics:
16+
- persistent://public/default/input-java-topic
17+
typeClassName: java.lang.String
18+
output:
19+
topic: persistent://public/default/output-java-topic
20+
typeClassName: java.lang.String
21+
resources:
22+
requests:
23+
cpu: 50m
24+
memory: 1G
25+
limits:
26+
memory: 1.1G
27+
# each secret will be loaded ad an env variable from the `path` secret with the `key` in that secret in the name of `name`
28+
secretsMap:
29+
"name":
30+
path: "test-secret"
31+
key: "username"
32+
"pwd":
33+
path: "test-secret"
34+
key: "password"
35+
pulsar:
36+
pulsarConfig: "test-pulsar"
37+
tlsConfig:
38+
enabled: false
39+
allowInsecure: false
40+
hostnameVerification: true
41+
certSecretName: sn-platform-tls-broker
42+
certSecretKey: ""
43+
#authConfig: "test-auth"
44+
java:
45+
jar: /pulsar/examples/api-examples.jar
46+
# to be delete & use admission hook
47+
clusterName: test
48+
autoAck: true
49+
---
50+
apiVersion: v1
51+
kind: ConfigMap
52+
metadata:
53+
name: test-pulsar
54+
data:
55+
webServiceURL: http://sn-platform-pulsar-broker.default.svc.cluster.local:8080
56+
brokerServiceURL: pulsar://sn-platform-pulsar-broker.default.svc.cluster.local:6650
57+
#---
58+
#apiVersion: v1
59+
#kind: ConfigMap
60+
#metadata:
61+
# name: test-auth
62+
#data:
63+
# clientAuthenticationPlugin: "abc"
64+
# clientAuthenticationParameters: "xyz"
65+
# tlsTrustCertsFilePath: "uvw"
66+
# useTls: "true"
67+
# tlsAllowInsecureConnection: "false"
68+
# tlsHostnameVerificationEnable: "true"
69+
---
70+
apiVersion: v1
71+
data:
72+
username: YWRtaW4=
73+
password: MWYyZDFlMmU2N2Rm
74+
kind: Secret
75+
metadata:
76+
name: test-secret
77+
type: Opaque
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
apiVersion: compute.functionmesh.io/v1alpha1
2+
kind: BackendConfig
3+
metadata:
4+
name: backend-config
5+
namespace: kube-system
6+
spec:
7+
env:
8+
namespaced1: namespacedvalue1
9+
shared1: fromnamespace
10+
pod:
11+
liveness:
12+
initialDelaySeconds: 50
13+
periodSeconds: 60
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
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+
pod:
11+
liveness:
12+
initialDelaySeconds: 30
13+
periodSeconds: 10
Lines changed: 179 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,179 @@
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/cases/global-and-namespaced-config/manifests.yaml
36+
mesh_config_file="${BASE_DIR}"/.ci/tests/integration/cases/global-and-namespaced-config/mesh-config.yaml
37+
mesh_config_file_in_kube_system="${BASE_DIR}"/.ci/tests/integration/cases/global-and-namespaced-config/mesh-config-kube-system.yaml
38+
global_mesh_config_file="${BASE_DIR}"/.ci/clusters/global_backend_config.yaml
39+
40+
41+
kubectl apply -f "${mesh_config_file}" > /dev/null 2>&1
42+
kubectl apply -f "${manifests_file}" > /dev/null 2>&1
43+
44+
verify_fm_result=$(ci::verify_function_mesh function-sample-env 2>&1)
45+
if [ $? -ne 0 ]; then
46+
echo "$verify_fm_result"
47+
kubectl delete -f "${manifests_file}" > /dev/null 2>&1 || true
48+
exit 1
49+
fi
50+
51+
verify_env_result=$(ci::verify_env "function-sample-env" global1 global1=globalvalue1 2>&1)
52+
if [ $? -ne 0 ]; then
53+
echo "$verify_env_result"
54+
kubectl delete -f "${mesh_config_file}" > /dev/null 2>&1
55+
kubectl delete -f "${manifests_file}" > /dev/null 2>&1 || true
56+
exit 1
57+
fi
58+
59+
verify_env_result=$(ci::verify_env "function-sample-env" namespaced1 namespaced1=namespacedvalue1 2>&1)
60+
if [ $? -ne 0 ]; then
61+
echo "$verify_env_result"
62+
kubectl delete -f "${mesh_config_file}" > /dev/null 2>&1
63+
kubectl delete -f "${manifests_file}" > /dev/null 2>&1 || true
64+
exit 1
65+
fi
66+
67+
# if global and namespaced config has same key, the value from namespace should be used
68+
verify_env_result=$(ci::verify_env "function-sample-env" shared1 shared1=fromnamespace 2>&1)
69+
if [ $? -ne 0 ]; then
70+
echo "$verify_env_result"
71+
kubectl delete -f "${mesh_config_file}" > /dev/null 2>&1
72+
kubectl delete -f "${manifests_file}" > /dev/null 2>&1 || true
73+
exit 1
74+
fi
75+
76+
# verify liveness config
77+
verify_liveness_result=$(ci::verify_liveness_probe function-sample-env-function-0 '{"failureThreshold":3,"httpGet":{"path":"/","port":9094,"scheme":"HTTP"},"initialDelaySeconds":30,"periodSeconds":10,"successThreshold":1,"timeoutSeconds":10}' 2>&1)
78+
if [ $? -ne 0 ]; then
79+
echo "$verify_liveness_result"
80+
kubectl delete -f "${mesh_config_file}" > /dev/null 2>&1
81+
kubectl delete -f "${manifests_file}" > /dev/null 2>&1 || true
82+
exit 1
83+
fi
84+
85+
# delete the namespaced config, the function should be reconciled without namespaced env injected
86+
kubectl delete -f "${mesh_config_file}" > /dev/null 2>&1
87+
sleep 30
88+
89+
verify_fm_result=$(ci::verify_function_mesh function-sample-env 2>&1)
90+
if [ $? -ne 0 ]; then
91+
echo "$verify_fm_result"
92+
kubectl delete -f "${manifests_file}" > /dev/null 2>&1 || true
93+
exit 1
94+
fi
95+
96+
verify_env_result=$(ci::verify_env "function-sample-env" global1 global1=globalvalue1 2>&1)
97+
if [ $? -ne 0 ]; then
98+
echo "$verify_env_result"
99+
kubectl delete -f "${manifests_file}" > /dev/null 2>&1 || true
100+
exit 1
101+
fi
102+
103+
verify_env_result=$(ci::verify_env "function-sample-env" shared1 shared1=fromglobal 2>&1)
104+
if [ $? -ne 0 ]; then
105+
echo "$verify_env_result"
106+
kubectl delete -f "${manifests_file}" > /dev/null 2>&1 || true
107+
exit 1
108+
fi
109+
110+
verify_env_result=$(ci::verify_env "function-sample-env" namespaced1 "" 2>&1)
111+
if [ $? -ne 0 ]; then
112+
echo "$verify_env_result"
113+
kubectl delete -f "${manifests_file}" > /dev/null 2>&1 || true
114+
exit 1
115+
fi
116+
117+
# it should use liveness config from global config
118+
verify_liveness_result=$(ci::verify_liveness_probe function-sample-env-function-0 '{"failureThreshold":3,"httpGet":{"path":"/","port":9094,"scheme":"HTTP"},"initialDelaySeconds":10,"periodSeconds":30,"successThreshold":1,"timeoutSeconds":30}' 2>&1)
119+
if [ $? -ne 0 ]; then
120+
echo "$verify_liveness_result"
121+
kubectl delete -f "${manifests_file}" > /dev/null 2>&1 || true
122+
exit 1
123+
fi
124+
125+
# delete the global config, the function should be reconciled without global env injected
126+
kubectl delete -f "${global_mesh_config_file}" -n $FUNCTION_MESH_NAMESPACE > /dev/null 2>&1 || true
127+
sleep 30
128+
129+
verify_fm_result=$(ci::verify_function_mesh function-sample-env 2>&1)
130+
if [ $? -ne 0 ]; then
131+
echo "$verify_fm_result"
132+
kubectl delete -f "${manifests_file}" > /dev/null 2>&1 || true
133+
exit 1
134+
fi
135+
136+
verify_env_result=$(ci::verify_env "function-sample-env" global1 "" 2>&1)
137+
if [ $? -ne 0 ]; then
138+
echo "$verify_env_result"
139+
kubectl delete -f "${manifests_file}" > /dev/null 2>&1 || true
140+
exit 1
141+
fi
142+
143+
# it should has no liveness config
144+
verify_liveness_result=$(ci::verify_liveness_probe function-sample-env-function-0 "" 2>&1)
145+
if [ $? -ne 0 ]; then
146+
echo "$verify_liveness_result"
147+
kubectl delete -f "${manifests_file}" > /dev/null 2>&1 || true
148+
exit 1
149+
fi
150+
151+
# config created in an another namespace should not affect functions in other namespaces
152+
kubectl apply -f "${mesh_config_file_in_kube_system}" > /dev/null 2>&1
153+
sleep 30
154+
155+
verify_fm_result=$(ci::verify_function_mesh function-sample-env 2>&1)
156+
if [ $? -ne 0 ]; then
157+
echo "$verify_fm_result"
158+
kubectl delete -f "${manifests_file}" > /dev/null 2>&1 || true
159+
exit 1
160+
fi
161+
162+
# it should has no liveness config
163+
verify_liveness_result=$(ci::verify_liveness_probe function-sample-env-function-0 "" 2>&1)
164+
if [ $? -ne 0 ]; then
165+
echo "$verify_liveness_result"
166+
kubectl delete -f "${manifests_file}" > /dev/null 2>&1 || true
167+
exit 1
168+
fi
169+
170+
verify_env_result=$(ci::verify_env "function-sample-env" namespaced1 "" 2>&1)
171+
if [ $? -eq 0 ]; then
172+
echo "e2e-test: ok" | yq eval -
173+
else
174+
echo "$verify_env_result"
175+
kubectl delete -f "${manifests_file}" > /dev/null 2>&1 || true
176+
exit 1
177+
fi
178+
179+
kubectl delete -f "${manifests_file}" > /dev/null 2>&1 || true

.ci/tests/integration/e2e_with_tls.yaml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,12 +87,17 @@ setup:
8787
image="function-mesh-operator:latest"
8888
IMG=${image} make docker-build-skip-test
8989
kind load docker-image ${image}
90-
helm install ${FUNCTION_MESH_RELEASE_NAME} -n ${FUNCTION_MESH_NAMESPACE} --set operatorImage=${image} --create-namespace charts/function-mesh-operator
90+
helm install ${FUNCTION_MESH_RELEASE_NAME} -n ${FUNCTION_MESH_NAMESPACE} --set operatorImage=${image} --set controllerManager.globalBackendConfig=global-backend-config --set controllerManager.globalBackendConfigNamespace=${FUNCTION_MESH_NAMESPACE} --set controllerManager.namespacedBackendConfig=backend-config --create-namespace charts/function-mesh-operator
9191
wait:
9292
- namespace: function-mesh
9393
resource: pod
9494
label-selector: app.kubernetes.io/name=function-mesh-operator
9595
for: condition=Ready
96+
97+
- name: apply global env config map
98+
command: |
99+
kubectl create -n ${FUNCTION_MESH_NAMESPACE} -f .ci/clusters/global_backend_config.yaml
100+
96101
timeout: 60m
97102

98103
cleanup:
@@ -124,3 +129,5 @@ verify:
124129
expected: expected.data.yaml
125130
- query: bash .ci/tests/integration/cases/crypto-function/verify.sh
126131
expected: expected.data.yaml
132+
- query: timeout 5m bash .ci/tests/integration/cases/global-and-namespaced-config/verify.sh
133+
expected: expected.data.yaml

0 commit comments

Comments
 (0)