Skip to content
This repository has been archived by the owner on Jun 19, 2022. It is now read-only.

Commit

Permalink
Flip storage version of CloudBuildSource to v1
Browse files Browse the repository at this point in the history
  • Loading branch information
eclipselu committed Oct 5, 2020
1 parent 6bdb0a0 commit 3b0cb5c
Show file tree
Hide file tree
Showing 7 changed files with 368 additions and 3 deletions.
4 changes: 2 additions & 2 deletions config/core/resources/cloudbuildsource.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ spec:
- &version
name: v1
served: true
storage: false
storage: true
subresources:
status: {}
additionalPrinterColumns:
Expand Down Expand Up @@ -188,7 +188,7 @@ spec:
- <<: *version
name: v1beta1
served: true
storage: true
storage: false
schema: *v1Schema
- <<: *version
name: v1alpha1
Expand Down
209 changes: 209 additions & 0 deletions config/pre-install/v0.19.0/cloudbuildsource.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,209 @@
# Copyright 2020 Google LLC
#
# 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: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
labels:
duck.knative.dev/source: "true"
events.cloud.google.com/release: devel
events.cloud.google.com/crd-install: "true"
annotations:
registry.knative.dev/eventTypes: |
[
{
"type": "google.cloud.cloudbuild.build.v1.statusChanged",
"schema": "https://raw.githubusercontent.com/googleapis/google-cloudevents/master/proto/google/events/cloud/cloudbuild/v1/data.proto",
"description": "This event is sent when your build's state changes, such as when your build is created, when your build transitions to a working state, and when your build completes."
}
]
name: cloudbuildsources.events.cloud.google.com
spec:
group: events.cloud.google.com
names:
categories:
- all
- knative
- cloudbuildsource
- sources
kind: CloudBuildSource
plural: cloudbuildsources
scope: Namespaced
preserveUnknownFields: false
conversion:
strategy: Webhook
webhook:
# conversionReviewVersions indicates what ConversionReview versions are understood/preferred by the webhook.
# The first version in the list understood by the API server is sent to the webhook.
# The webhook must respond with a ConversionReview object in the same version it received.
conversionReviewVersions: ["v1", "v1beta1"]
clientConfig:
service:
name: webhook
namespace: cloud-run-events
versions:
- &version
name: v1
served: true
storage: true
subresources:
status: {}
additionalPrinterColumns:
- name: Ready
type: string
jsonPath: ".status.conditions[?(@.type==\"Ready\")].status"
- name: Reason
type: string
jsonPath: ".status.conditions[?(@.type==\"Ready\")].reason"
- name: Age
type: date
jsonPath: .metadata.creationTimestamp
# We remove status.ServiceAccountName from the schema in v1.
schema: &v1Schema
openAPIV3Schema: &openAPIV3Schema
type: object
properties: &properties
spec:
type: object
required:
- sink
properties:
sink:
type: object
description: >
Sink which receives the notifications.
properties:
uri:
type: string
minLength: 1
ref:
type: object
required:
- apiVersion
- kind
- name
properties:
apiVersion:
type: string
minLength: 1
kind:
type: string
minLength: 1
namespace:
type: string
name:
type: string
minLength: 1
ceOverrides:
type: object
description: >
Defines overrides to control modifications of the event sent to the sink.
properties:
extensions:
type: object
description: >
Extensions specify what attribute are added or overridden on the outbound event. Each
`Extensions` key-value pair are set on the event as an attribute extension independently.
x-kubernetes-preserve-unknown-fields: true
serviceAccountName:
type: string
description: >
Kubernetes service account used to bind to a google service account to poll the Cloud Pub/Sub Subscription.
The value of the Kubernetes service account must be a valid DNS subdomain name.
(see https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#dns-subdomain-names)
secret:
type: object
description: >
Credential used to poll the Cloud Pub/Sub Subscription. It is not used to create or delete the
Subscription, only to poll it. The value of the secret entry must be a service account key in
the JSON format (see https://cloud.google.com/iam/docs/creating-managing-service-account-keys).
Defaults to secret.name of 'google-cloud-key' and secret.key of 'key.json'.
properties:
name:
type: string
key:
type: string
optional:
type: boolean
project:
type: string
description: >
Google Cloud Project ID of the project into which the topic should be created. If omitted uses
the Project ID from the GKE cluster metadata service.
status: &status
type: object
properties: &statusProperties
observedGeneration:
type: integer
format: int64
conditions:
type: array
items:
type: object
properties:
lastTransitionTime:
# We use a string in the stored object but a wrapper object at runtime.
type: string
message:
type: string
reason:
type: string
severity:
type: string
status:
type: string
type:
type: string
required:
- type
- status
sinkUri:
type: string
ceAttributes:
type: array
items:
type: object
properties:
type:
type: string
source:
type: string
projectId:
type: string
topicId:
type: string
subscriptionId:
type: string
- <<: *version
name: v1beta1
served: true
storage: false
schema: *v1Schema
- <<: *version
name: v1alpha1
# TODO: Flip served bit of v1alpha1 in https://github.com/google/knative-gcp/issues/1544.
served: true
storage: false
# v1alpha1 have status.properties.serviceAccountName in the schema
schema:
openAPIV3Schema:
<<: *openAPIV3Schema
properties:
<<: *properties
status:
<<: *status
properties:
<<: *statusProperties
serviceAccountName:
type: string
57 changes: 57 additions & 0 deletions config/pre-install/v0.19.0/clusterrole.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
# Copyright 2020 Google LLC
#
# 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-gcp-pre-install-job-role
labels:
events.cloud.google.com/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:
- "events.cloud.google.com"
resources:
- "cloudbuildsources"
verbs: &everything
- "get"
- "list"
- "create"
- "update"
- "delete"
- "patch"
- "watch"
- apiGroups:
- "internal.events.cloud.google.com"
resources:
- "pullsubscriptions"
- "topics"
verbs: *everything
- apiGroups:
- "messaging.cloud.google.com"
resources:
- "channels"
verbs: *everything
19 changes: 19 additions & 0 deletions config/pre-install/v0.19.0/dummy.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/*
Copyright 2020 Google LLC
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 preinstall is a placeholder that allows us to pull in config files
// via go mod vendor.
package preinstall
39 changes: 39 additions & 0 deletions config/pre-install/v0.19.0/serviceaccount.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# Copyright 2020 Google LLC
#
# 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-gcp-pre-install-job
namespace: cloud-run-events
labels:
events.cloud.google.com/release: devel

---

apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
name: knative-gcp-pre-install-job-role-binding
labels:
events.cloud.google.com/release: devel
subjects:
- kind: ServiceAccount
name: knative-gcp-pre-install-job
namespace: cloud-run-events
roleRef:
kind: ClusterRole
name: knative-gcp-pre-install-job-role
apiGroup: rbac.authorization.k8s.io

41 changes: 41 additions & 0 deletions config/pre-install/v0.19.0/storage-version-migration.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# Copyright 2020 Google LLC
#
# 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: batch/v1
kind: Job
metadata:
name: storage-version-migration-knative-gcp
namespace: cloud-run-events
labels:
app: "storage-version-migration-knative-gcp"
events.cloud.google.com/release: devel
spec:
ttlSecondsAfterFinished: 600
backoffLimit: 10
template:
metadata:
labels:
app: "storage-version-migration-knative-gcp"
annotations:
sidecar.istio.io/inject: "false"
spec:
serviceAccountName: knative-gcp-pre-install-job
restartPolicy: OnFailure
containers:
- name: migrate
# This is the Go import path for the binary that is containerized
# and substituted here.
image: ko://github.com/google/knative-gcp/vendor/knative.dev/pkg/apiextensions/storageversion/cmd/migrate
args:
- "cloudbuildsources.events.cloud.google.com"
2 changes: 1 addition & 1 deletion hack/release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ source $(dirname "$0")/../vendor/knative.dev/test-infra/scripts/release.sh
declare -A COMPONENTS
COMPONENTS=(
["cloud-run-events-core.yaml"]="config"
["cloud-run-events-pre-install-jobs.yaml"]="config/pre-install/v0.18.0"
["cloud-run-events-pre-install-jobs.yaml"]="config/pre-install/v0.19.0"
)
readonly COMPONENTS

Expand Down

0 comments on commit 3b0cb5c

Please sign in to comment.