Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: allow configuring config values in knative #1527

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions staging/knative/Chart.yaml
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
apiVersion: v2
name: knative
version: 1.15.4
version: 1.15.5
description: "Kubernetes-based platform to build, deploy, and manage modern serverless workloads"
home: https://knative.dev/
maintainers:
- name: adityajariwala
- name: mhrabovcin
- name: takirala
icon: https://raw.githubusercontent.com/knative/docs/master/docs/images/logo/rgb/knative-logo-rgb.jpg
appVersion: "v1.15.2"
dependencies:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -492,6 +492,11 @@ data:
# ALPHA feature: The new-apiserversource-filters flag allows you to use the new `filters` field
# in APIServerSource objects with its rich filtering capabilities.
new-apiserversource-filters: "disabled"
{{- if .Values.configMaps.configFeatures.additionalData }}
{{- range $key, $value := .Values.configMaps.configFeatures.additionalData }}
{{ $key }}: "{{ $value }}"
{{- end }}
{{- end }}
# Copyright 2021 The Knative Authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
Expand Down Expand Up @@ -2781,4 +2786,4 @@ webhooks:
name: sinkbindings.webhook.sources.knative.dev
timeoutSeconds: 10
---

{}
3 changes: 2 additions & 1 deletion staging/knative/charts/serving/templates/net-istio.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
# 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.

kind: ClusterRole
apiVersion: rbac.authorization.k8s.io/v1
metadata:
Expand Down Expand Up @@ -485,3 +484,5 @@ webhooks:
matchLabels:
app.kubernetes.io/name: knative-serving
app.kubernetes.io/component: net-istio
---
{}
10 changes: 8 additions & 2 deletions staging/knative/charts/serving/templates/serving-core.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
# 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: Namespace
metadata:
Expand Down Expand Up @@ -466,7 +465,12 @@ metadata:
app.kubernetes.io/version: "1.15.2"
annotations:
knative.dev/example-checksum: "47c2487f"
data: {}
data:
{{- if .Values.configMaps.configAutoscaler.additionalData }}
{{- range $key, $value := .Values.configMaps.configAutoscaler.additionalData }}
{{ $key }}: "{{ $value }}"
{{- end }}
{{- end }}
# Copyright 2020 The Knative Authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
Expand Down Expand Up @@ -1591,3 +1595,5 @@ metadata:
app.kubernetes.io/name: knative-serving
app.kubernetes.io/version: "1.15.2"
# The data is populated at install time.
---
{}
9 changes: 9 additions & 0 deletions staging/knative/patch/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Fork Patches

This directory contains patches to be applied to the upstream source in order to satisfy the needs of our fork.

## Usage

```
patch/patch.sh
```
16 changes: 16 additions & 0 deletions staging/knative/patch/helpers.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/usr/bin/env bash

function git_add_and_commit {
FILES_PATH=$1
git add "${FILES_PATH}"
FILENAME=$(basename "$0")
git commit -m "chore: apply ${FILENAME}"
}

function git_add_and_commit_with_msg {
FILES_PATH=$1
MSG=$2
git add "${FILES_PATH}"
FILENAME=$(basename "$0")
git commit -m "chore: apply ${FILENAME} - ${MSG}"
}
13 changes: 13 additions & 0 deletions staging/knative/patch/patch.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/bin/bash

set -euo pipefail

declare -a patches
while IFS= read -r line; do
patches+=("$line")
done < <(find patch/patch_*.sh | sort -V)

for p in ${patches[*]}; do
echo "Executing $p"
BASEDIR=${BASEDIR} $p
done
11 changes: 11 additions & 0 deletions staging/knative/patch/patch_1_eventing_core.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/usr/bin/env bash

source $(dirname "$0")/helpers.sh

set -xeuo pipefail

patch -d "${BASEDIR}" -p3 --no-backup-if-mismatch < patch/patches/00-eventing-core-config-map-config-features.patch

SRCFILE="${BASEDIR}"/charts/eventing/templates/eventing-core.yaml

git_add_and_commit "${SRCFILE}"
11 changes: 11 additions & 0 deletions staging/knative/patch/patch_2_serving_core.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/usr/bin/env bash

source $(dirname "$0")/helpers.sh

set -xeuo pipefail

patch -d "${BASEDIR}" -p3 --no-backup-if-mismatch < patch/patches/01-serving-core-config-map-config-autoscaler.patch

SRCFILE="${BASEDIR}"/charts/serving/templates/serving-core.yaml

git_add_and_commit "${SRCFILE}"
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
diff --git a/staging/knative/charts/eventing/templates/eventing-core.yaml b/staging/knative/charts/eventing/templates/eventing-core.yaml
index 25f89a9b..71a699d7 100644
--- a/staging/knative/charts/eventing/templates/eventing-core.yaml
+++ b/staging/knative/charts/eventing/templates/eventing-core.yaml
@@ -492,6 +492,11 @@ data:
# ALPHA feature: The new-apiserversource-filters flag allows you to use the new `filters` field
# in APIServerSource objects with its rich filtering capabilities.
new-apiserversource-filters: "disabled"
+{{- if .Values.configMaps.configFeatures.additionalData }}
+{{- range $key, $value := .Values.configMaps.configFeatures.additionalData }}
+ {{ $key }}: "{{ $value }}"
+{{- end }}
+{{- end }}
# Copyright 2021 The Knative Authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
diff --git a/staging/knative/charts/serving/templates/serving-core.yaml b/staging/knative/charts/serving/templates/serving-core.yaml
index 52dc335d..364d0eb4 100644
--- a/staging/knative/charts/serving/templates/serving-core.yaml
+++ b/staging/knative/charts/serving/templates/serving-core.yaml
@@ -466,7 +466,12 @@ metadata:
app.kubernetes.io/version: "1.15.2"
annotations:
knative.dev/example-checksum: "47c2487f"
-data: {}
+data:
+{{- if .Values.configMaps.configAutoscaler.additionalData }}
+{{- range $key, $value := .Values.configMaps.configAutoscaler.additionalData }}
+ {{ $key }}: "{{ $value }}"
+{{- end }}
+{{- end }}
# Copyright 2020 The Knative Authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
3 changes: 3 additions & 0 deletions staging/knative/upgrade_knative.sh
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,9 @@ rm charts/eventing/templates/eventing-core-1.yaml
rm charts/eventing/templates/eventing-temp.yaml
rm charts/serving/templates/net-istio-temp.yaml

# Inject helm templating for enabling config map updates from values.yaml
BASEDIR=$(dirname "$(realpath "$0")") ./patch/patch.sh

# Bump app version
sed "s/appVersion:.*/appVersion: \"v${SERVING_TAG}\"/g" Chart.yaml > Chart.yaml.temp
sed "s/appVersion:.*/appVersion: \"v${SERVING_TAG}\"/g" charts/serving/Chart.yaml > charts/serving/Chart.yaml.temp
Expand Down
6 changes: 6 additions & 0 deletions staging/knative/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,15 @@ global:

eventing:
enabled: false
configMaps:
configFeatures:
additionalData: {}

serving:
enabled: true
configMaps:
configAutoscaler:
additionalData: {}
knativeIngressGateway:
spec:
selector:
Expand Down
Loading