-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* 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
- Loading branch information
1 parent
d07374a
commit 9b557b8
Showing
59 changed files
with
3,587 additions
and
85 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
apiVersion: compute.functionmesh.io/v1alpha1 | ||
kind: BackendConfig | ||
metadata: | ||
name: global-backend-config | ||
spec: | ||
env: | ||
global1: globalvalue1 | ||
shared1: fromglobal | ||
pod: | ||
liveness: | ||
initialDelaySeconds: 10 | ||
periodSeconds: 30 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
77 changes: 77 additions & 0 deletions
77
.ci/tests/integration/cases/global-and-namespaced-config/manifests.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
apiVersion: compute.functionmesh.io/v1alpha1 | ||
kind: Function | ||
metadata: | ||
name: function-sample-env | ||
namespace: default | ||
spec: | ||
image: streamnative/pulsar-functions-java-sample:2.9.2.23 | ||
className: org.apache.pulsar.functions.api.examples.ExclamationFunction | ||
forwardSourceMessageProperty: true | ||
maxPendingAsyncRequests: 1000 | ||
replicas: 1 | ||
maxReplicas: 5 | ||
logTopic: persistent://public/default/logging-function-logs | ||
input: | ||
topics: | ||
- persistent://public/default/input-java-topic | ||
typeClassName: java.lang.String | ||
output: | ||
topic: persistent://public/default/output-java-topic | ||
typeClassName: java.lang.String | ||
resources: | ||
requests: | ||
cpu: 50m | ||
memory: 1G | ||
limits: | ||
memory: 1.1G | ||
# each secret will be loaded ad an env variable from the `path` secret with the `key` in that secret in the name of `name` | ||
secretsMap: | ||
"name": | ||
path: "test-secret" | ||
key: "username" | ||
"pwd": | ||
path: "test-secret" | ||
key: "password" | ||
pulsar: | ||
pulsarConfig: "test-pulsar" | ||
tlsConfig: | ||
enabled: false | ||
allowInsecure: false | ||
hostnameVerification: true | ||
certSecretName: sn-platform-tls-broker | ||
certSecretKey: "" | ||
#authConfig: "test-auth" | ||
java: | ||
jar: /pulsar/examples/api-examples.jar | ||
# to be delete & use admission hook | ||
clusterName: test | ||
autoAck: true | ||
--- | ||
apiVersion: v1 | ||
kind: ConfigMap | ||
metadata: | ||
name: test-pulsar | ||
data: | ||
webServiceURL: http://sn-platform-pulsar-broker.default.svc.cluster.local:8080 | ||
brokerServiceURL: pulsar://sn-platform-pulsar-broker.default.svc.cluster.local:6650 | ||
#--- | ||
#apiVersion: v1 | ||
#kind: ConfigMap | ||
#metadata: | ||
# name: test-auth | ||
#data: | ||
# clientAuthenticationPlugin: "abc" | ||
# clientAuthenticationParameters: "xyz" | ||
# tlsTrustCertsFilePath: "uvw" | ||
# useTls: "true" | ||
# tlsAllowInsecureConnection: "false" | ||
# tlsHostnameVerificationEnable: "true" | ||
--- | ||
apiVersion: v1 | ||
data: | ||
username: YWRtaW4= | ||
password: MWYyZDFlMmU2N2Rm | ||
kind: Secret | ||
metadata: | ||
name: test-secret | ||
type: Opaque |
13 changes: 13 additions & 0 deletions
13
.ci/tests/integration/cases/global-and-namespaced-config/mesh-config-kube-system.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
apiVersion: compute.functionmesh.io/v1alpha1 | ||
kind: BackendConfig | ||
metadata: | ||
name: backend-config | ||
namespace: kube-system | ||
spec: | ||
env: | ||
namespaced1: namespacedvalue1 | ||
shared1: fromnamespace | ||
pod: | ||
liveness: | ||
initialDelaySeconds: 50 | ||
periodSeconds: 60 |
13 changes: 13 additions & 0 deletions
13
.ci/tests/integration/cases/global-and-namespaced-config/mesh-config.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
apiVersion: compute.functionmesh.io/v1alpha1 | ||
kind: BackendConfig | ||
metadata: | ||
name: backend-config | ||
namespace: default | ||
spec: | ||
env: | ||
namespaced1: namespacedvalue1 | ||
shared1: fromnamespace | ||
pod: | ||
liveness: | ||
initialDelaySeconds: 30 | ||
periodSeconds: 10 |
179 changes: 179 additions & 0 deletions
179
.ci/tests/integration/cases/global-and-namespaced-config/verify.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,179 @@ | ||
#!/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 | ||
|
||
E2E_DIR=$(dirname "$0") | ||
BASE_DIR=$(cd "${E2E_DIR}"/../../../../..;pwd) | ||
PULSAR_NAMESPACE=${PULSAR_NAMESPACE:-"default"} | ||
PULSAR_RELEASE_NAME=${PULSAR_RELEASE_NAME:-"sn-platform"} | ||
E2E_KUBECONFIG=${E2E_KUBECONFIG:-"/tmp/e2e-k8s.config"} | ||
|
||
source "${BASE_DIR}"/.ci/helm.sh | ||
|
||
if [ ! "$KUBECONFIG" ]; then | ||
export KUBECONFIG=${E2E_KUBECONFIG} | ||
fi | ||
|
||
manifests_file="${BASE_DIR}"/.ci/tests/integration/cases/global-and-namespaced-config/manifests.yaml | ||
mesh_config_file="${BASE_DIR}"/.ci/tests/integration/cases/global-and-namespaced-config/mesh-config.yaml | ||
mesh_config_file_in_kube_system="${BASE_DIR}"/.ci/tests/integration/cases/global-and-namespaced-config/mesh-config-kube-system.yaml | ||
global_mesh_config_file="${BASE_DIR}"/.ci/clusters/global_backend_config.yaml | ||
|
||
|
||
kubectl apply -f "${mesh_config_file}" > /dev/null 2>&1 | ||
kubectl apply -f "${manifests_file}" > /dev/null 2>&1 | ||
|
||
verify_fm_result=$(ci::verify_function_mesh function-sample-env 2>&1) | ||
if [ $? -ne 0 ]; then | ||
echo "$verify_fm_result" | ||
kubectl delete -f "${manifests_file}" > /dev/null 2>&1 || true | ||
exit 1 | ||
fi | ||
|
||
verify_env_result=$(ci::verify_env "function-sample-env" global1 global1=globalvalue1 2>&1) | ||
if [ $? -ne 0 ]; then | ||
echo "$verify_env_result" | ||
kubectl delete -f "${mesh_config_file}" > /dev/null 2>&1 | ||
kubectl delete -f "${manifests_file}" > /dev/null 2>&1 || true | ||
exit 1 | ||
fi | ||
|
||
verify_env_result=$(ci::verify_env "function-sample-env" namespaced1 namespaced1=namespacedvalue1 2>&1) | ||
if [ $? -ne 0 ]; then | ||
echo "$verify_env_result" | ||
kubectl delete -f "${mesh_config_file}" > /dev/null 2>&1 | ||
kubectl delete -f "${manifests_file}" > /dev/null 2>&1 || true | ||
exit 1 | ||
fi | ||
|
||
# if global and namespaced config has same key, the value from namespace should be used | ||
verify_env_result=$(ci::verify_env "function-sample-env" shared1 shared1=fromnamespace 2>&1) | ||
if [ $? -ne 0 ]; then | ||
echo "$verify_env_result" | ||
kubectl delete -f "${mesh_config_file}" > /dev/null 2>&1 | ||
kubectl delete -f "${manifests_file}" > /dev/null 2>&1 || true | ||
exit 1 | ||
fi | ||
|
||
# verify liveness config | ||
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) | ||
if [ $? -ne 0 ]; then | ||
echo "$verify_liveness_result" | ||
kubectl delete -f "${mesh_config_file}" > /dev/null 2>&1 | ||
kubectl delete -f "${manifests_file}" > /dev/null 2>&1 || true | ||
exit 1 | ||
fi | ||
|
||
# delete the namespaced config, the function should be reconciled without namespaced env injected | ||
kubectl delete -f "${mesh_config_file}" > /dev/null 2>&1 | ||
sleep 30 | ||
|
||
verify_fm_result=$(ci::verify_function_mesh function-sample-env 2>&1) | ||
if [ $? -ne 0 ]; then | ||
echo "$verify_fm_result" | ||
kubectl delete -f "${manifests_file}" > /dev/null 2>&1 || true | ||
exit 1 | ||
fi | ||
|
||
verify_env_result=$(ci::verify_env "function-sample-env" global1 global1=globalvalue1 2>&1) | ||
if [ $? -ne 0 ]; then | ||
echo "$verify_env_result" | ||
kubectl delete -f "${manifests_file}" > /dev/null 2>&1 || true | ||
exit 1 | ||
fi | ||
|
||
verify_env_result=$(ci::verify_env "function-sample-env" shared1 shared1=fromglobal 2>&1) | ||
if [ $? -ne 0 ]; then | ||
echo "$verify_env_result" | ||
kubectl delete -f "${manifests_file}" > /dev/null 2>&1 || true | ||
exit 1 | ||
fi | ||
|
||
verify_env_result=$(ci::verify_env "function-sample-env" namespaced1 "" 2>&1) | ||
if [ $? -ne 0 ]; then | ||
echo "$verify_env_result" | ||
kubectl delete -f "${manifests_file}" > /dev/null 2>&1 || true | ||
exit 1 | ||
fi | ||
|
||
# it should use liveness config from global config | ||
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) | ||
if [ $? -ne 0 ]; then | ||
echo "$verify_liveness_result" | ||
kubectl delete -f "${manifests_file}" > /dev/null 2>&1 || true | ||
exit 1 | ||
fi | ||
|
||
# delete the global config, the function should be reconciled without global env injected | ||
kubectl delete -f "${global_mesh_config_file}" -n $FUNCTION_MESH_NAMESPACE > /dev/null 2>&1 || true | ||
sleep 30 | ||
|
||
verify_fm_result=$(ci::verify_function_mesh function-sample-env 2>&1) | ||
if [ $? -ne 0 ]; then | ||
echo "$verify_fm_result" | ||
kubectl delete -f "${manifests_file}" > /dev/null 2>&1 || true | ||
exit 1 | ||
fi | ||
|
||
verify_env_result=$(ci::verify_env "function-sample-env" global1 "" 2>&1) | ||
if [ $? -ne 0 ]; then | ||
echo "$verify_env_result" | ||
kubectl delete -f "${manifests_file}" > /dev/null 2>&1 || true | ||
exit 1 | ||
fi | ||
|
||
# it should has no liveness config | ||
verify_liveness_result=$(ci::verify_liveness_probe function-sample-env-function-0 "" 2>&1) | ||
if [ $? -ne 0 ]; then | ||
echo "$verify_liveness_result" | ||
kubectl delete -f "${manifests_file}" > /dev/null 2>&1 || true | ||
exit 1 | ||
fi | ||
|
||
# config created in an another namespace should not affect functions in other namespaces | ||
kubectl apply -f "${mesh_config_file_in_kube_system}" > /dev/null 2>&1 | ||
sleep 30 | ||
|
||
verify_fm_result=$(ci::verify_function_mesh function-sample-env 2>&1) | ||
if [ $? -ne 0 ]; then | ||
echo "$verify_fm_result" | ||
kubectl delete -f "${manifests_file}" > /dev/null 2>&1 || true | ||
exit 1 | ||
fi | ||
|
||
# it should has no liveness config | ||
verify_liveness_result=$(ci::verify_liveness_probe function-sample-env-function-0 "" 2>&1) | ||
if [ $? -ne 0 ]; then | ||
echo "$verify_liveness_result" | ||
kubectl delete -f "${manifests_file}" > /dev/null 2>&1 || true | ||
exit 1 | ||
fi | ||
|
||
verify_env_result=$(ci::verify_env "function-sample-env" namespaced1 "" 2>&1) | ||
if [ $? -eq 0 ]; then | ||
echo "e2e-test: ok" | yq eval - | ||
else | ||
echo "$verify_env_result" | ||
kubectl delete -f "${manifests_file}" > /dev/null 2>&1 || true | ||
exit 1 | ||
fi | ||
|
||
kubectl delete -f "${manifests_file}" > /dev/null 2>&1 || true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.