Skip to content

Commit

Permalink
Separately release our CRDs. (knative#4552)
Browse files Browse the repository at this point in the history
This change has two main parts:
1. Create separate release artifacts for our CRDs,
1. Create two versions of our CRD definitions, with and without v1beta1.

The `v1alpha1` CRDs are generated during `./hack/update-codegen.sh` from the
`v1beta1` CRDs, so we still have a single source of truth (e.g. for columns
and whatnot).

`ko apply -f config` is no longer sufficient to install Knative.  You need
to install either `ko apply -f config/v1alpha1` of `ko apply -f config/v1beta1`.
I have added a flag to select the install for e2e, which defaults to beta
to maintain our current test coverage.  We should add a leg that just runs with
alpha to ensure we don't regress alpha-only installs.

Related to: knative#4533
  • Loading branch information
mattmoor authored and knative-prow-robot committed Jun 28, 2019
1 parent 5f2f5f9 commit 058ca35
Show file tree
Hide file tree
Showing 15 changed files with 285 additions and 15 deletions.
5 changes: 4 additions & 1 deletion DEVELOPMENT.md
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,10 @@ when you use Minikube or Docker Desktop as the Kubernetes environment.
Next, run:
```shell
ko apply -f config/
# There are some issues with multi-versioned CRDs before Kubernetes 1.14, so
# depending on how you plan to use knative you may need to switch this to
# v1alpha1, see also: https://github.com/knative/serving/issues/4533
ko apply -f config/ -f config/v1beta1

# Optional steps

Expand Down
54 changes: 54 additions & 0 deletions config/v1alpha1/300-configuration.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
# Copyright 2019 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: apiextensions.k8s.io/v1beta1
kind: CustomResourceDefinition
metadata:
name: configurations.serving.knative.dev
labels:
serving.knative.dev/release: devel
knative.dev/crd-install: "true"
spec:
group: serving.knative.dev
versions:
- name: v1alpha1
served: true
storage: true
names:
kind: Configuration
plural: configurations
singular: configuration
categories:
- all
- knative
- serving
shortNames:
- config
- cfg
scope: Namespaced
subresources:
status: {}
additionalPrinterColumns:
- name: LatestCreated
type: string
JSONPath: .status.latestCreatedRevisionName
- name: LatestReady
type: string
JSONPath: .status.latestReadyRevisionName
- name: Ready
type: string
JSONPath: ".status.conditions[?(@.type=='Ready')].status"
- name: Reason
type: string
JSONPath: ".status.conditions[?(@.type=='Ready')].reason"
53 changes: 53 additions & 0 deletions config/v1alpha1/300-revision.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
# Copyright 2019 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: apiextensions.k8s.io/v1beta1
kind: CustomResourceDefinition
metadata:
name: revisions.serving.knative.dev
labels:
serving.knative.dev/release: devel
knative.dev/crd-install: "true"
spec:
group: serving.knative.dev
versions:
- name: v1alpha1
served: true
storage: true
names:
kind: Revision
plural: revisions
singular: revision
categories:
- all
- knative
- serving
shortNames:
- rev
scope: Namespaced
subresources:
status: {}
additionalPrinterColumns:
- name: Service Name
type: string
JSONPath: .status.serviceName
- name: Generation
type: string # int in string form :(
JSONPath: ".metadata.labels['serving\\.knative\\.dev/configurationGeneration']"
- name: Ready
type: string
JSONPath: ".status.conditions[?(@.type=='Ready')].status"
- name: Reason
type: string
JSONPath: ".status.conditions[?(@.type=='Ready')].reason"
50 changes: 50 additions & 0 deletions config/v1alpha1/300-route.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# Copyright 2019 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: apiextensions.k8s.io/v1beta1
kind: CustomResourceDefinition
metadata:
name: routes.serving.knative.dev
labels:
serving.knative.dev/release: devel
knative.dev/crd-install: "true"
spec:
group: serving.knative.dev
versions:
- name: v1alpha1
served: true
storage: true
names:
kind: Route
plural: routes
singular: route
categories:
- all
- knative
- serving
shortNames:
- rt
scope: Namespaced
subresources:
status: {}
additionalPrinterColumns:
- name: URL
type: string
JSONPath: .status.url
- name: Ready
type: string
JSONPath: ".status.conditions[?(@.type=='Ready')].status"
- name: Reason
type: string
JSONPath: ".status.conditions[?(@.type=='Ready')].reason"
57 changes: 57 additions & 0 deletions config/v1alpha1/300-service.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
# Copyright 2019 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: apiextensions.k8s.io/v1beta1
kind: CustomResourceDefinition
metadata:
name: services.serving.knative.dev
labels:
serving.knative.dev/release: devel
knative.dev/crd-install: "true"
spec:
group: serving.knative.dev
versions:
- name: v1alpha1
served: true
storage: true
names:
kind: Service
plural: services
singular: service
categories:
- all
- knative
- serving
shortNames:
- kservice
- ksvc
scope: Namespaced
subresources:
status: {}
additionalPrinterColumns:
- name: URL
type: string
JSONPath: .status.url
- name: LatestCreated
type: string
JSONPath: .status.latestCreatedRevisionName
- name: LatestReady
type: string
JSONPath: .status.latestReadyRevisionName
- name: Ready
type: string
JSONPath: ".status.conditions[?(@.type=='Ready')].status"
- name: Reason
type: string
JSONPath: ".status.conditions[?(@.type=='Ready')].reason"
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2018 The Knative Authors
# Copyright 2019 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.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2018 The Knative Authors
# Copyright 2019 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.
Expand Down
2 changes: 1 addition & 1 deletion config/300-route.yaml → config/v1beta1/300-route.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2018 The Knative Authors
# Copyright 2019 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.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2018 The Knative Authors
# Copyright 2019 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.
Expand Down
24 changes: 24 additions & 0 deletions hack/generate-yamls.sh
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,11 @@ rm -fr ${YAML_OUTPUT_DIR}/*.yaml

# Generated Knative component YAML files
readonly SERVING_YAML=${YAML_OUTPUT_DIR}/serving.yaml
readonly SERVING_CRD_ALPHA_YAML=${YAML_OUTPUT_DIR}/serving-alpha-crds.yaml
readonly SERVING_ALPHA_YAML=${YAML_OUTPUT_DIR}/serving-pre-1.14.yaml
readonly SERVING_CRD_BETA_YAML=${YAML_OUTPUT_DIR}/serving-beta-crds.yaml
readonly SERVING_BETA_YAML=${YAML_OUTPUT_DIR}/serving-post-1.14.yaml

readonly MONITORING_YAML=${YAML_OUTPUT_DIR}/monitoring.yaml
readonly MONITORING_METRIC_PROMETHEUS_YAML=${YAML_OUTPUT_DIR}/monitoring-metrics-prometheus.yaml
readonly MONITORING_TRACE_ZIPKIN_YAML=${YAML_OUTPUT_DIR}/monitoring-tracing-zipkin.yaml
Expand All @@ -75,6 +80,21 @@ cd "${YAML_REPO_ROOT}"

echo "Building Knative Serving"
ko resolve ${KO_YAML_FLAGS} -f config/ | "${LABEL_YAML_CMD[@]}" > "${SERVING_YAML}"
# These don't have images, but ko will concatenate them for us.
ko resolve ${KO_YAML_FLAGS} -f config/v1alpha1 | "${LABEL_YAML_CMD[@]}" > "${SERVING_CRD_ALPHA_YAML}"
ko resolve ${KO_YAML_FLAGS} -f config/v1beta1 | "${LABEL_YAML_CMD[@]}" > "${SERVING_CRD_BETA_YAML}"

# Create the full alpha install.
cat "${SERVING_YAML}" > "${SERVING_ALPHA_YAML}"
cat "${SERVING_CRD_ALPHA_YAML}" >> "${SERVING_ALPHA_YAML}"

# Create the full beta install.
cat "${SERVING_YAML}" > "${SERVING_BETA_YAML}"
cat "${SERVING_CRD_BETA_YAML}" >> "${SERVING_BETA_YAML}"

# Our ${SERVING_YAML} should be a complete install, so bias towards the most
# broadly compatible by default.
cat "${SERVING_ALPHA_YAML}" > "${SERVING_YAML}"

echo "Building Monitoring & Logging"
# Use ko to concatenate them all together.
Expand Down Expand Up @@ -112,4 +132,8 @@ echo "All manifests generated"
# List generated YAML files, with serving.yaml first.

ls -1 ${SERVING_YAML} > ${YAML_LIST_FILE}
ls -1 ${SERVING_CRD_ALPHA_YAML} >> ${YAML_LIST_FILE}
ls -1 ${SERVING_ALPHA_YAML} >> ${YAML_LIST_FILE}
ls -1 ${SERVING_CRD_BETA_YAML} >> ${YAML_LIST_FILE}
ls -1 ${SERVING_BETA_YAML} >> ${YAML_LIST_FILE}
ls -1 ${YAML_OUTPUT_DIR}/*.yaml | grep -v ${SERVING_YAML} >> ${YAML_LIST_FILE}
6 changes: 6 additions & 0 deletions hack/update-codegen.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,12 @@ fi

source $(dirname $0)/../vendor/github.com/knative/test-infra/scripts/library.sh


# Clone the v1beta1 types to v1alpha1 sans v1beta1.
for x in $(ls "${REPO_ROOT_DIR}/config/v1beta1"); do
sed -e '28,30d' "${REPO_ROOT_DIR}/config/v1beta1/$x" > "${REPO_ROOT_DIR}/config/v1alpha1/$x"
done

CODEGEN_PKG=${CODEGEN_PKG:-$(cd ${REPO_ROOT_DIR}; ls -d -1 ./vendor/k8s.io/code-generator 2>/dev/null || echo ../code-generator)}

KNATIVE_CODEGEN_PKG=${KNATIVE_CODEGEN_PKG:-$(cd ${REPO_ROOT_DIR}; ls -d -1 ./vendor/knative.dev/pkg 2>/dev/null || echo ../pkg)}
Expand Down
2 changes: 1 addition & 1 deletion test/cleanup.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ func CleanupOnInterrupt(cleanup func()) {
// TearDown will delete created names using clients.
func TearDown(clients *Clients, names ResourceNames) {
if clients != nil && clients.ServingBetaClient != nil {
clients.ServingBetaClient.Delete(
clients.ServingAlphaClient.Delete(
[]string{names.Route},
[]string{names.Config},
[]string{names.Service},
Expand Down
4 changes: 2 additions & 2 deletions test/clients.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ limitations under the License.
package test

import (
"knative.dev/pkg/test"
"github.com/knative/serving/pkg/client/clientset/versioned"
servingv1alpha1 "github.com/knative/serving/pkg/client/clientset/versioned/typed/serving/v1alpha1"
servingv1beta1 "github.com/knative/serving/pkg/client/clientset/versioned/typed/serving/v1beta1"
Expand All @@ -28,6 +27,7 @@ import (
_ "k8s.io/client-go/plugin/pkg/client/auth/oidc"
"k8s.io/client-go/rest"
"k8s.io/client-go/tools/clientcmd"
"knative.dev/pkg/test"
)

// Clients holds instances of interfaces for making requests to Knative Serving.
Expand Down Expand Up @@ -125,7 +125,7 @@ func newServingBetaClients(cfg *rest.Config, namespace string) (*ServingBetaClie

// Delete will delete all Routes and Configs with the names routes and configs, if clients
// has been successfully initialized.
func (clients *ServingBetaClients) Delete(routes []string, configs []string, services []string) error {
func (clients *ServingAlphaClients) Delete(routes []string, configs []string, services []string) error {
deletions := []struct {
client interface {
Delete(name string, options *v1.DeleteOptions) error
Expand Down
16 changes: 15 additions & 1 deletion test/e2e-common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ INSTALL_MONITORING_YAML=""

INSTALL_MONITORING=0

INSTALL_BETA=1

# List of custom YAMLs to install, if specified (space-separated).
INSTALL_CUSTOM_YAMLS=""

Expand Down Expand Up @@ -63,6 +65,14 @@ function parse_flags() {
readonly INSTALL_MONITORING=1
return 1
;;
--install-alpha)
readonly INSTALL_BETA=0
return 1
;;
--install-beta)
readonly INSTALL_BETA=1
return 1
;;
--custom-yamls)
[[ -z "$2" ]] && fail_test "Missing argument to --custom-yamls"
# Expect a list of comma-separated YAMLs.
Expand Down Expand Up @@ -122,7 +132,11 @@ function install_knative_serving_standard() {
if [[ -z "$1" ]]; then
# install_knative_serving_standard was called with no arg.
build_knative_from_source
INSTALL_RELEASE_YAML="${SERVING_YAML}"
if (( INSTALL_BETA )); then
INSTALL_RELEASE_YAML="${SERVING_BETA_YAML}"
else
INSTALL_RELEASE_YAML="${SERVING_ALPHA_YAML}"
fi
if (( INSTALL_MONITORING )); then
INSTALL_MONITORING_YAML="${MONITORING_YAML}"
fi
Expand Down
Loading

0 comments on commit 058ca35

Please sign in to comment.