Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/main'
Browse files Browse the repository at this point in the history
# Conflicts:
#	apis/core/v1beta2/function_webhook.go
#	controllers/core/function_controller.go
#	pkg/core/serving/knative/servingrun.go
  • Loading branch information
Bryce-huang committed Sep 22, 2023
2 parents 7523476 + 5d9d72f commit 5c266c3
Show file tree
Hide file tree
Showing 21 changed files with 577 additions and 609 deletions.
35 changes: 12 additions & 23 deletions .github/workflows/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,6 @@ on:
- 'config/samples/function-with-plugins-serving-only.yaml'
- 'controllers/**'
- 'hack/generate-cert.sh'
- 'hack/delete.sh'
- 'hack/deploy.sh'
- 'pkg/**'
- 'Dockerfile'
- 'main.go'
Expand Down Expand Up @@ -121,22 +119,14 @@ jobs:
- name: Install dependent components
run: |
chmod a+x ./hack/deploy.sh
./hack/deploy.sh --all
# Remove the resources request to avoid Insufficient CPU error
kubectl patch deployments.apps -n tekton-pipelines tekton-pipelines-webhook -p '{"spec":{"template":{"spec":{"containers":[{"name":"webhook","resources":null}]}}}}'
kubectl patch deployments.apps -n knative-serving activator -p '{"spec":{"template":{"spec":{"containers":[{"name":"activator","resources":null}]}}}}'
kubectl patch deployments.apps -n knative-serving controller -p '{"spec":{"template":{"spec":{"containers":[{"name":"controller","resources":null}]}}}}'
kubectl patch deployments.apps -n knative-serving autoscaler -p '{"spec":{"template":{"spec":{"containers":[{"name":"autoscaler","resources":null}]}}}}'
kubectl patch deployments.apps -n knative-serving domainmapping-webhook -p '{"spec":{"template":{"spec":{"containers":[{"name":"domainmapping-webhook","resources":null}]}}}}'
kubectl patch deployments.apps -n knative-serving webhook -p '{"spec":{"template":{"spec":{"containers":[{"name":"webhook","resources":null}]}}}}'
kubectl patch deployments.apps -n keda keda-operator -p '{"spec":{"template":{"spec":{"containers":[{"name":"keda-operator","resources":null}]}}}}'
kubectl patch deployments.apps -n keda keda-metrics-apiserver -p '{"spec":{"template":{"spec":{"containers":[{"name":"keda-metrics-apiserver","resources":null}]}}}}'
kubectl patch deployments.apps -n projectcontour contour-gateway-provisioner -p '{"spec":{"template":{"spec":{"containers":[{"name":"contour-gateway-provisioner","resources":null}]}}}}'
# Install kafka
helm repo add strimzi https://strimzi.io/charts/
helm install kafka-operator -n default strimzi/strimzi-kafka-operator
kubectl apply -f config/samples/function-kafka-quick.yaml
# Install nats and stan
helm repo add nats https://nats-io.github.io/k8s/helm/charts/
helm install nats nats/nats
helm install stan nats/stan --set stan.nats.url=nats://nats:4222
- name: Build and Push image
run: |
Expand All @@ -145,12 +135,14 @@ jobs:
- name: Install OpenFunction
run: |
kubectl apply --server-side=true -f config/bundle.yaml
kubectl apply -f config/strategy/build-strategy.yaml
kubectl patch deployments.apps -n openfunction openfunction-controller-manager -p "{\"spec\":{\"template\":{\"spec\":{\"containers\":[{\"name\":\"openfunction\",\"image\":\"kind-registry:5000/openfunction/openfunction:latest\",\"resources\":null}]}}}}"
kubectl rollout status -n openfunction deployment openfunction-controller-manager --timeout=1m
sleep 10
kubectl apply -f config/gateway/default-gateway.yaml
# Install CRDs
make install
kubectl apply -f https://openfunction.sh1a.qingstor.com/crds/gateway-api-v0.8.0.yaml
# Install OpenFunction Chart
helm repo add openfunction https://openfunction.github.io/charts/
helm repo update
helm install openfunction openfunction/openfunction -n openfunction --create-namespace --devel -f "${GITHUB_WORKSPACE}"/.github/workflows/values
sleep 60
# - name: Setup tmate session
# uses: mxschmitt/action-tmate@v1
Expand Down Expand Up @@ -199,9 +191,6 @@ jobs:
- name: Function with events e2e test
timeout-minutes: 10
run: |
helm repo add nats https://nats-io.github.io/k8s/helm/charts/
helm install nats nats/nats
helm install stan nats/stan --set stan.nats.url=nats://nats:4222
# deploy the eventbus backend nats streaming
while /bin/true; do
nats_status=`kubectl get pod nats-0 -o jsonpath='{.status.conditions[?(@.type=="Ready")].status}'`
Expand Down
6 changes: 4 additions & 2 deletions .github/workflows/output.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,18 @@
# limitations under the License.

echo "---Status of all related pods---"
kubectl get po -n cert-manager
kubectl get po -n projectcontour
kubectl get po -n dapr-system
kubectl get po -n ingress-nginx
kubectl get po -n keda
kubectl get po -n knative-serving
kubectl get po -n kourier-system
kubectl get po -n openfunction
kubectl get po -n shipwright-build
kubectl get po -n tekton-pipelines

echo "---Gateways---"
kubectl get gateways.networking.openfunction.io -n openfunction openfunction -oyaml

echo "---Functions---"
kubectl get fn -oyaml

Expand Down
2 changes: 0 additions & 2 deletions .github/workflows/push-image.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,6 @@ on:
- 'apis/**'
- 'config/bundle.yaml'
- 'controllers/**'
- 'hack/delete.sh'
- 'hack/deploy.sh'
- 'pkg/**'
- 'Dockerfile'
- 'main.go'
Expand Down
128 changes: 128 additions & 0 deletions .github/workflows/values
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
# Copyright 2023 The OpenFunction Authors.
#
# Licensed 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.

global:
Dapr:
enabled: true
Keda:
enabled: true
KnativeServing:
enabled: true
TektonPipelines:
enabled: false
ShipwrightBuild:
enabled: false
Contour:
enabled: true

controllerManager:
openfunction:
image:
repository: kind-registry:5000/openfunction/openfunction
tag: latest
resources:
limits:
cpu: 0
memory: 0
requests:
cpu: 0
memory: 0

knative-serving:
activator:
activator:
resources:
limits:
cpu: 0
memory: 0
requests:
cpu: 0
memory: 0
controller:
controller:
resources:
limits:
cpu: 0
memory: 0
requests:
cpu: 0
memory: 0
autoscaler:
autoscaler:
resources:
limits:
cpu: 0
memory: 0
requests:
cpu: 0
memory: 0
domainMapping:
domainMapping:
resources:
limits:
cpu: 0
memory: 0
requests:
cpu: 0
memory: 0
domainmappingWebhook:
domainmappingWebhook:
resources:
limits:
cpu: 0
memory: 0
requests:
cpu: 0
memory: 0
webhook:
webhook:
resources:
limits:
cpu: 0
memory: 0
requests:
cpu: 0
memory: 0
netContourController:
controller:
resources:
limits:
cpu: 0
memory: 0
requests:
cpu: 0
memory: 0
keda:
resources:
operator:
limits:
cpu: 0
memory: 0
requests:
cpu: 0
memory: 0
metricServer:
limits:
cpu: 0
memory: 0
requests:
cpu: 0
memory: 0
webhooks:
limits:
cpu: 0
memory: 0
requests:
cpu: 0
memory: 0
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ docker-push-dev: ## Push dev docker image with the openfunction.
##@ Deployment

install: manifests kustomize ## Install CRDs into the K8s cluster specified in ~/.kube/config.
$(KUSTOMIZE) build config/crd | kubectl apply --server-side=true --force-conflicts -f -
$(KUSTOMIZE) build config/crd | sed 's/webhook-service/openfunction-&/g' | kubectl apply --server-side=true --force-conflicts -f -

uninstall: manifests kustomize ## Uninstall CRDs from the K8s cluster specified in ~/.kube/config.
$(KUSTOMIZE) build config/crd | kubectl delete -f -
Expand Down
28 changes: 14 additions & 14 deletions apis/core/v1beta2/function_webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,14 +100,12 @@ func (r *Function) Default() {
version := "latest"
r.Spec.Version = &version
}
if r.Spec.Serving == nil {
r.Spec.Serving = &ServingImpl{}
}
if r.Spec.Serving.Triggers == nil {

if r.Spec.Serving != nil && r.Spec.Serving.Triggers == nil {
r.Spec.Serving.Triggers = &Triggers{}
}

if r.Spec.Serving.Triggers.Dapr == nil || len(r.Spec.Serving.Triggers.Dapr) == 0 {
if r.Spec.Serving != nil && len(r.Spec.Serving.Triggers.Dapr) == 0 {
if r.Spec.Serving.Triggers.Http == nil {
r.Spec.Serving.Triggers.Http = &HttpTrigger{}
}
Expand Down Expand Up @@ -344,15 +342,17 @@ func (r *Function) ValidateServing() error {
}

if keda := scaleOptions.Keda; keda != nil {
job, object, httpso := keda.ScaledJob, keda.ScaledObject, keda.HTTPScaledObject
// case that only ScaledJob is declared
flagJob := job != nil && object == nil && httpso == nil
// case that only ScaledObject is declared
flagScaledObject := job == nil && object != nil && httpso == nil
// case that only HTTPScaledObject is declared
flagHTTPScaledObject := job == nil && object == nil && httpso != nil
// if none of these cases happened, return error
if !(flagJob || flagScaledObject || flagHTTPScaledObject) {
scalerCount := 0
if keda.ScaledJob != nil {
scalerCount += 1
}
if keda.ScaledObject != nil {
scalerCount += 1
}
if keda.HTTPScaledObject != nil {
scalerCount += 1
}
if scalerCount > 1 {
return field.Required(
field.NewPath("spec", "serving", "scaleOptions", "keda"),
"Exactly one of scaledJob, scaledObject and httpScaledObject should be enabled")
Expand Down
2 changes: 1 addition & 1 deletion apis/core/v1beta2/function_webhook_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ func Test_Validate(t *testing.T) {
},
},
},
wantErr: true,
wantErr: false,
},
{
name: "function.spec.serving.scaleOptions.keda.httpScaledObject.targetPendingRequests",
Expand Down
Loading

0 comments on commit 5c266c3

Please sign in to comment.