Skip to content

Commit

Permalink
ApiServerSource stored version v1 and migration tool
Browse files Browse the repository at this point in the history
Signed-off-by: Pierangelo Di Pilato <pierangelodipilato@gmail.com>
  • Loading branch information
pierDipi committed Dec 16, 2020
1 parent ca2def5 commit 7b18c9b
Show file tree
Hide file tree
Showing 6 changed files with 154 additions and 10 deletions.
4 changes: 2 additions & 2 deletions config/core/resources/apiserversource.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -538,15 +538,15 @@ spec:
- <<: *version
name: v1beta1
served: true
storage: true
storage: false
# the schema of v1beta1 is exactly the same as v1alpha2 schema
schema:
openAPIV3Schema:
<<: *openAPIV3Schema
- <<: *version
name: v1
served: true
storage: false
storage: true
# the schema of v1 is exactly the same as v1beta1 schema
schema:
openAPIV3Schema:
Expand Down
46 changes: 46 additions & 0 deletions config/post-install/clusterrole.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# Copyright 2020 The Knative 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.

apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
name: knative-eventing-post-install-job-role
labels:
eventing.knative.dev/release: devel
rules:
# Storage version upgrader needs to be able to patch CRDs.
- apiGroups:
- "apiextensions.k8s.io"
resources:
- "customresourcedefinitions"
- "customresourcedefinitions/status"
verbs:
- "get"
- "list"
- "update"
- "patch"
- "watch"
# Our own resources we care about.
- apiGroups:
- "sources.knative.dev"
resources:
- "apiserversources"
verbs:
- "get"
- "list"
- "create"
- "update"
- "delete"
- "patch"
- "watch"
19 changes: 19 additions & 0 deletions config/post-install/placeholder.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/*
Copyright 2020 The Knative 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.
*/

// Package post_install is a placeholder that allows us to pull in config files
// via go mod vendor.
package post_install
38 changes: 38 additions & 0 deletions config/post-install/serviceaccount.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# Copyright 2020 The Knative 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.

apiVersion: v1
kind: ServiceAccount
metadata:
name: knative-eventing-post-install-job
namespace: knative-eventing
labels:
eventing.knative.dev/release: devel

---

apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
name: knative-eventing-post-install-job-role-binding
labels:
eventing.knative.dev/release: devel
subjects:
- kind: ServiceAccount
name: knative-eventing-post-install-job
namespace: knative-eventing
roleRef:
kind: ClusterRole
name: knative-eventing-post-install-job-role
apiGroup: rbac.authorization.k8s.io
40 changes: 40 additions & 0 deletions config/post-install/storage-version-migrator.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# Copyright 2020 The Knative 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
#
# https://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.

apiVersion: batch/v1
kind: Job
metadata:
name: storage-version-migration
namespace: knative-eventing
labels:
app: "storage-version-migration"
eventing.knative.dev/release: devel
spec:
ttlSecondsAfterFinished: 600
backoffLimit: 10
template:
metadata:
labels:
app: "storage-version-migration"
eventing.knative.dev/release: devel
annotations:
sidecar.istio.io/inject: "false"
spec:
serviceAccountName: knative-eventing-post-install-job
restartPolicy: OnFailure
containers:
- name: migrate
image: ko://knative.dev/eventing/vendor/knative.dev/pkg/apiextensions/storageversion/cmd/migrate
args:
- "apiserversources.sources.knative.dev"
17 changes: 9 additions & 8 deletions hack/generate-yamls.sh
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ readonly EVENTING_CRDS_YAML=${YAML_OUTPUT_DIR}/"eventing-crds.yaml"
readonly EVENTING_SUGAR_CONTROLLER_YAML=${YAML_OUTPUT_DIR}/"eventing-sugar-controller.yaml"
readonly EVENTING_MT_CHANNEL_BROKER_YAML=${YAML_OUTPUT_DIR}/"mt-channel-broker.yaml"
readonly EVENTING_IN_MEMORY_CHANNEL_YAML=${YAML_OUTPUT_DIR}/"in-memory-channel.yaml"
readonly EVENTING_POST_INSTALL_YAML=${YAML_OUTPUT_DIR}/"eventing-post-install-jobs.yaml"
readonly EVENTING_YAML=${YAML_OUTPUT_DIR}"/eventing.yaml"
declare -A RELEASES
RELEASES=(
Expand Down Expand Up @@ -94,14 +93,17 @@ ko resolve ${KO_FLAGS} -f config/brokers/mt-channel-broker/ | "${LABEL_YAML_CMD[
# Create in memory channel yaml
ko resolve ${KO_FLAGS} -f config/channels/in-memory-channel/ | "${LABEL_YAML_CMD[@]}" > "${EVENTING_IN_MEMORY_CHANNEL_YAML}"


all_yamls=(${EVENTING_CORE_YAML} ${EVENTING_CRDS_YAML} ${EVENTING_SUGAR_CONTROLLER_YAML} ${EVENTING_MT_CHANNEL_BROKER_YAML} ${EVENTING_IN_MEMORY_CHANNEL_YAML} ${EVENTING_YAML})

# # Template for POST_INSTALL usage:
# # Create vX.Y.Z post-install job yaml.
# ko resolve ${KO_FLAGS} -f config/post-install/vX.Y.Z/ | "${LABEL_YAML_CMD[@]}" > "${POST_INSTALL_YAML}"
# # If used, add ${EVENTING_POST_INSTALL_YAML} to all_yamls,
# all_yamls+=(${EVENTING_POST_INSTALL_YAML})
if [ -d "${YAML_REPO_ROOT}/config/post-install" ]; then

readonly EVENTING_POST_INSTALL_YAML=${YAML_OUTPUT_DIR}/"eventing-post-install.yaml"

echo "Resolving post install manifests"

ko resolve ${KO_FLAGS} -f config/post-install/ | "${LABEL_YAML_CMD[@]}" > "${EVENTING_POST_INSTALL_YAML}"
all_yamls+=(${EVENTING_POST_INSTALL_YAML})
fi

# Assemble the release
for yaml in "${!RELEASES[@]}"; do
Expand All @@ -116,7 +118,6 @@ done

echo "All manifests generated"


for yaml in "${!all_yamls[@]}"; do
echo "${all_yamls[${yaml}]}" >> ${YAML_LIST_FILE}
done

0 comments on commit 7b18c9b

Please sign in to comment.