新增learn-kubernetes(https://github.com/yyong-brs/learn-kubernetes)相关文件
This commit is contained in:
58
learn/learn-kubernetes-master/kiamol/ch21/lab/README.md
Normal file
58
learn/learn-kubernetes-master/kiamol/ch21/lab/README.md
Normal file
@@ -0,0 +1,58 @@
|
||||
# Ch20 lab
|
||||
|
||||
## Setup
|
||||
|
||||
Deploy Knative with Contour:
|
||||
|
||||
```
|
||||
kubectl apply -f lab/knative/
|
||||
```
|
||||
|
||||
Deploy the to-do app:
|
||||
|
||||
```
|
||||
kubectl apply -f lab/todo-list/
|
||||
```
|
||||
|
||||
Get the ingress URL:
|
||||
|
||||
```
|
||||
kubectl get svc -n contour-external envoy -o jsonpath='http://{.status.loadBalancer.ingress[0].*}:80'
|
||||
```
|
||||
|
||||
> Map your `hosts` file to use the Contour IP for `todo.kiamol.local` and `api.todo.kiamol.local`
|
||||
|
||||
|
||||
## Solution
|
||||
|
||||
I've used a [Knative Service custom resource](./solution/todo-api.yaml) which specifies the API container image.
|
||||
|
||||
```
|
||||
kubectl apply -f lab/solution/todo-api.yaml
|
||||
```
|
||||
|
||||
Check the Knative Service is running:
|
||||
|
||||
```
|
||||
kubectl get ksvc -n todo
|
||||
```
|
||||
|
||||
Invoke the function:
|
||||
|
||||
```
|
||||
curl --data 'Write KIAMOL ch22' http://api.todo.kiamol.local/todos
|
||||
```
|
||||
|
||||
Print the function logs - you should see the event being published:
|
||||
|
||||
```
|
||||
kubectl -n todo logs -l serving.knative.dev/service=api -c user-container
|
||||
```
|
||||
|
||||
Print the save handler logs - you should see the new item being saved:
|
||||
|
||||
```
|
||||
kubectl -n todo logs -l component=save-handler
|
||||
```
|
||||
|
||||
> Browse to http://todo.kiamol.local to see the new item
|
||||
@@ -0,0 +1,652 @@
|
||||
# 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/v1
|
||||
kind: CustomResourceDefinition
|
||||
metadata:
|
||||
name: certificates.networking.internal.knative.dev
|
||||
labels:
|
||||
serving.knative.dev/release: "v0.16.0"
|
||||
knative.dev/crd-install: "true"
|
||||
spec:
|
||||
group: networking.internal.knative.dev
|
||||
versions:
|
||||
- name: v1alpha1
|
||||
served: true
|
||||
storage: true
|
||||
subresources:
|
||||
status: {}
|
||||
schema:
|
||||
openAPIV3Schema:
|
||||
type: object
|
||||
# this is a work around so we don't need to flush out the
|
||||
# schema for each version at this time
|
||||
#
|
||||
# see issue: https://github.com/knative/serving/issues/912
|
||||
x-kubernetes-preserve-unknown-fields: true
|
||||
additionalPrinterColumns:
|
||||
- name: Ready
|
||||
type: string
|
||||
jsonPath: ".status.conditions[?(@.type==\"Ready\")].status"
|
||||
- name: Reason
|
||||
type: string
|
||||
jsonPath: ".status.conditions[?(@.type==\"Ready\")].reason"
|
||||
names:
|
||||
kind: Certificate
|
||||
plural: certificates
|
||||
singular: certificate
|
||||
categories:
|
||||
- knative-internal
|
||||
- networking
|
||||
shortNames:
|
||||
- kcert
|
||||
scope: Namespaced
|
||||
|
||||
---
|
||||
# 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/v1
|
||||
kind: CustomResourceDefinition
|
||||
metadata:
|
||||
name: configurations.serving.knative.dev
|
||||
labels:
|
||||
serving.knative.dev/release: "v0.16.0"
|
||||
knative.dev/crd-install: "true"
|
||||
duck.knative.dev/podspecable: "true"
|
||||
spec:
|
||||
group: serving.knative.dev
|
||||
versions:
|
||||
- &version
|
||||
name: v1alpha1
|
||||
served: true
|
||||
storage: false
|
||||
subresources:
|
||||
status: {}
|
||||
schema:
|
||||
openAPIV3Schema:
|
||||
type: object
|
||||
# this is a work around so we don't need to flush out the
|
||||
# schema for each version at this time
|
||||
#
|
||||
# see issue: https://github.com/knative/serving/issues/912
|
||||
x-kubernetes-preserve-unknown-fields: true
|
||||
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"
|
||||
- !!merge <<: *version
|
||||
name: v1beta1
|
||||
- !!merge <<: *version
|
||||
name: v1
|
||||
storage: true
|
||||
names:
|
||||
kind: Configuration
|
||||
plural: configurations
|
||||
singular: configuration
|
||||
categories:
|
||||
- all
|
||||
- knative
|
||||
- serving
|
||||
shortNames:
|
||||
- config
|
||||
- cfg
|
||||
scope: Namespaced
|
||||
conversion:
|
||||
strategy: Webhook
|
||||
webhook:
|
||||
conversionReviewVersions: ["v1", "v1beta1"]
|
||||
clientConfig:
|
||||
service:
|
||||
name: webhook
|
||||
namespace: knative-serving
|
||||
|
||||
---
|
||||
# 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/v1
|
||||
kind: CustomResourceDefinition
|
||||
metadata:
|
||||
name: ingresses.networking.internal.knative.dev
|
||||
labels:
|
||||
serving.knative.dev/release: "v0.16.0"
|
||||
knative.dev/crd-install: "true"
|
||||
spec:
|
||||
group: networking.internal.knative.dev
|
||||
versions:
|
||||
- name: v1alpha1
|
||||
served: true
|
||||
storage: true
|
||||
subresources:
|
||||
status: {}
|
||||
schema:
|
||||
openAPIV3Schema:
|
||||
type: object
|
||||
# this is a work around so we don't need to flush out the
|
||||
# schema for each version at this time
|
||||
#
|
||||
# see issue: https://github.com/knative/serving/issues/912
|
||||
x-kubernetes-preserve-unknown-fields: true
|
||||
additionalPrinterColumns:
|
||||
- name: Ready
|
||||
type: string
|
||||
jsonPath: ".status.conditions[?(@.type=='Ready')].status"
|
||||
- name: Reason
|
||||
type: string
|
||||
jsonPath: ".status.conditions[?(@.type=='Ready')].reason"
|
||||
names:
|
||||
kind: Ingress
|
||||
plural: ingresses
|
||||
singular: ingress
|
||||
categories:
|
||||
- knative-internal
|
||||
- networking
|
||||
shortNames:
|
||||
- kingress
|
||||
- king
|
||||
scope: Namespaced
|
||||
|
||||
---
|
||||
# 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/v1
|
||||
kind: CustomResourceDefinition
|
||||
metadata:
|
||||
name: metrics.autoscaling.internal.knative.dev
|
||||
labels:
|
||||
serving.knative.dev/release: "v0.16.0"
|
||||
knative.dev/crd-install: "true"
|
||||
spec:
|
||||
group: autoscaling.internal.knative.dev
|
||||
versions:
|
||||
- name: v1alpha1
|
||||
served: true
|
||||
storage: true
|
||||
subresources:
|
||||
status: {}
|
||||
schema:
|
||||
openAPIV3Schema:
|
||||
type: object
|
||||
# this is a work around so we don't need to flush out the
|
||||
# schema for each version at this time
|
||||
#
|
||||
# see issue: https://github.com/knative/serving/issues/912
|
||||
x-kubernetes-preserve-unknown-fields: true
|
||||
additionalPrinterColumns:
|
||||
- name: Ready
|
||||
type: string
|
||||
jsonPath: ".status.conditions[?(@.type=='Ready')].status"
|
||||
- name: Reason
|
||||
type: string
|
||||
jsonPath: ".status.conditions[?(@.type=='Ready')].reason"
|
||||
names:
|
||||
kind: Metric
|
||||
plural: metrics
|
||||
singular: metric
|
||||
categories:
|
||||
- knative-internal
|
||||
- autoscaling
|
||||
scope: Namespaced
|
||||
|
||||
---
|
||||
# Copyright 2018 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/v1
|
||||
kind: CustomResourceDefinition
|
||||
metadata:
|
||||
name: podautoscalers.autoscaling.internal.knative.dev
|
||||
labels:
|
||||
serving.knative.dev/release: "v0.16.0"
|
||||
knative.dev/crd-install: "true"
|
||||
spec:
|
||||
group: autoscaling.internal.knative.dev
|
||||
versions:
|
||||
- name: v1alpha1
|
||||
served: true
|
||||
storage: true
|
||||
subresources:
|
||||
status: {}
|
||||
schema:
|
||||
openAPIV3Schema:
|
||||
type: object
|
||||
# this is a work around so we don't need to flush out the
|
||||
# schema for each version at this time
|
||||
#
|
||||
# see issue: https://github.com/knative/serving/issues/912
|
||||
x-kubernetes-preserve-unknown-fields: true
|
||||
additionalPrinterColumns:
|
||||
- name: DesiredScale
|
||||
type: integer
|
||||
jsonPath: ".status.desiredScale"
|
||||
- name: ActualScale
|
||||
type: integer
|
||||
jsonPath: ".status.actualScale"
|
||||
- name: Ready
|
||||
type: string
|
||||
jsonPath: ".status.conditions[?(@.type=='Ready')].status"
|
||||
- name: Reason
|
||||
type: string
|
||||
jsonPath: ".status.conditions[?(@.type=='Ready')].reason"
|
||||
names:
|
||||
kind: PodAutoscaler
|
||||
plural: podautoscalers
|
||||
singular: podautoscaler
|
||||
categories:
|
||||
- knative-internal
|
||||
- autoscaling
|
||||
shortNames:
|
||||
- kpa
|
||||
- pa
|
||||
scope: Namespaced
|
||||
|
||||
---
|
||||
# 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/v1
|
||||
kind: CustomResourceDefinition
|
||||
metadata:
|
||||
name: revisions.serving.knative.dev
|
||||
labels:
|
||||
serving.knative.dev/release: "v0.16.0"
|
||||
knative.dev/crd-install: "true"
|
||||
spec:
|
||||
group: serving.knative.dev
|
||||
versions:
|
||||
- &version
|
||||
name: v1alpha1
|
||||
served: true
|
||||
storage: false
|
||||
subresources:
|
||||
status: {}
|
||||
schema:
|
||||
openAPIV3Schema:
|
||||
type: object
|
||||
# this is a work around so we don't need to flush out the
|
||||
# schema for each version at this time
|
||||
#
|
||||
# see issue: https://github.com/knative/serving/issues/912
|
||||
x-kubernetes-preserve-unknown-fields: true
|
||||
additionalPrinterColumns:
|
||||
- name: Config Name
|
||||
type: string
|
||||
jsonPath: ".metadata.labels['serving\\.knative\\.dev/configuration']"
|
||||
- name: K8s 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"
|
||||
- !!merge <<: *version
|
||||
name: v1beta1
|
||||
- !!merge <<: *version
|
||||
name: v1
|
||||
storage: true
|
||||
names:
|
||||
kind: Revision
|
||||
plural: revisions
|
||||
singular: revision
|
||||
categories:
|
||||
- all
|
||||
- knative
|
||||
- serving
|
||||
shortNames:
|
||||
- rev
|
||||
scope: Namespaced
|
||||
conversion:
|
||||
strategy: Webhook
|
||||
webhook:
|
||||
conversionReviewVersions: ["v1", "v1beta1"]
|
||||
clientConfig:
|
||||
service:
|
||||
name: webhook
|
||||
namespace: knative-serving
|
||||
|
||||
---
|
||||
# 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/v1
|
||||
kind: CustomResourceDefinition
|
||||
metadata:
|
||||
name: routes.serving.knative.dev
|
||||
labels:
|
||||
serving.knative.dev/release: "v0.16.0"
|
||||
knative.dev/crd-install: "true"
|
||||
duck.knative.dev/addressable: "true"
|
||||
spec:
|
||||
group: serving.knative.dev
|
||||
versions:
|
||||
- &version
|
||||
name: v1alpha1
|
||||
served: true
|
||||
storage: false
|
||||
subresources:
|
||||
status: {}
|
||||
schema:
|
||||
openAPIV3Schema:
|
||||
type: object
|
||||
# this is a work around so we don't need to flush out the
|
||||
# schema for each version at this time
|
||||
#
|
||||
# see issue: https://github.com/knative/serving/issues/912
|
||||
x-kubernetes-preserve-unknown-fields: true
|
||||
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"
|
||||
- !!merge <<: *version
|
||||
name: v1beta1
|
||||
- !!merge <<: *version
|
||||
name: v1
|
||||
storage: true
|
||||
names:
|
||||
kind: Route
|
||||
plural: routes
|
||||
singular: route
|
||||
categories:
|
||||
- all
|
||||
- knative
|
||||
- serving
|
||||
shortNames:
|
||||
- rt
|
||||
scope: Namespaced
|
||||
conversion:
|
||||
strategy: Webhook
|
||||
webhook:
|
||||
conversionReviewVersions: ["v1", "v1beta1"]
|
||||
clientConfig:
|
||||
service:
|
||||
name: webhook
|
||||
namespace: knative-serving
|
||||
|
||||
---
|
||||
# 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/v1
|
||||
kind: CustomResourceDefinition
|
||||
metadata:
|
||||
name: serverlessservices.networking.internal.knative.dev
|
||||
labels:
|
||||
serving.knative.dev/release: "v0.16.0"
|
||||
knative.dev/crd-install: "true"
|
||||
spec:
|
||||
group: networking.internal.knative.dev
|
||||
versions:
|
||||
- name: v1alpha1
|
||||
served: true
|
||||
storage: true
|
||||
subresources:
|
||||
status: {}
|
||||
schema:
|
||||
openAPIV3Schema:
|
||||
type: object
|
||||
# this is a work around so we don't need to flush out the
|
||||
# schema for each version at this time
|
||||
#
|
||||
# see issue: https://github.com/knative/serving/issues/912
|
||||
x-kubernetes-preserve-unknown-fields: true
|
||||
additionalPrinterColumns:
|
||||
- name: Mode
|
||||
type: string
|
||||
jsonPath: ".spec.mode"
|
||||
- name: Activators
|
||||
type: integer
|
||||
jsonPath: ".spec.numActivators"
|
||||
- name: ServiceName
|
||||
type: string
|
||||
jsonPath: ".status.serviceName"
|
||||
- name: PrivateServiceName
|
||||
type: string
|
||||
jsonPath: ".status.privateServiceName"
|
||||
- name: Ready
|
||||
type: string
|
||||
jsonPath: ".status.conditions[?(@.type=='Ready')].status"
|
||||
- name: Reason
|
||||
type: string
|
||||
jsonPath: ".status.conditions[?(@.type=='Ready')].reason"
|
||||
names:
|
||||
kind: ServerlessService
|
||||
plural: serverlessservices
|
||||
singular: serverlessservice
|
||||
categories:
|
||||
- knative-internal
|
||||
- networking
|
||||
shortNames:
|
||||
- sks
|
||||
scope: Namespaced
|
||||
|
||||
---
|
||||
# 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/v1
|
||||
kind: CustomResourceDefinition
|
||||
metadata:
|
||||
name: services.serving.knative.dev
|
||||
labels:
|
||||
serving.knative.dev/release: "v0.16.0"
|
||||
knative.dev/crd-install: "true"
|
||||
duck.knative.dev/addressable: "true"
|
||||
duck.knative.dev/podspecable: "true"
|
||||
spec:
|
||||
group: serving.knative.dev
|
||||
versions:
|
||||
- &version
|
||||
name: v1alpha1
|
||||
served: true
|
||||
storage: false
|
||||
subresources:
|
||||
status: {}
|
||||
schema:
|
||||
openAPIV3Schema:
|
||||
type: object
|
||||
# this is a work around so we don't need to flush out the
|
||||
# schema for each version at this time
|
||||
#
|
||||
# see issue: https://github.com/knative/serving/issues/912
|
||||
x-kubernetes-preserve-unknown-fields: true
|
||||
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"
|
||||
- !!merge <<: *version
|
||||
name: v1beta1
|
||||
- !!merge <<: *version
|
||||
name: v1
|
||||
storage: true
|
||||
names:
|
||||
kind: Service
|
||||
plural: services
|
||||
singular: service
|
||||
categories:
|
||||
- all
|
||||
- knative
|
||||
- serving
|
||||
shortNames:
|
||||
- kservice
|
||||
- ksvc
|
||||
scope: Namespaced
|
||||
conversion:
|
||||
strategy: Webhook
|
||||
webhook:
|
||||
conversionReviewVersions: ["v1", "v1beta1"]
|
||||
clientConfig:
|
||||
service:
|
||||
name: webhook
|
||||
namespace: knative-serving
|
||||
|
||||
---
|
||||
# Copyright 2018 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: images.caching.internal.knative.dev
|
||||
labels:
|
||||
knative.dev/crd-install: "true"
|
||||
spec:
|
||||
group: caching.internal.knative.dev
|
||||
version: v1alpha1
|
||||
names:
|
||||
kind: Image
|
||||
plural: images
|
||||
singular: image
|
||||
categories:
|
||||
- knative-internal
|
||||
- caching
|
||||
shortNames:
|
||||
- img
|
||||
scope: Namespaced
|
||||
subresources:
|
||||
status: {}
|
||||
|
||||
---
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,124 @@
|
||||
# Not used directly, this lets the knative-serving service account reconcile
|
||||
# HTTPProxy resources.
|
||||
kind: ClusterRole
|
||||
apiVersion: rbac.authorization.k8s.io/v1
|
||||
metadata:
|
||||
name: knative-contour-core
|
||||
labels:
|
||||
networking.knative.dev/ingress-provider: contour
|
||||
serving.knative.dev/controller: "true"
|
||||
rules:
|
||||
- apiGroups: ["projectcontour.io"]
|
||||
resources: ["httpproxies"]
|
||||
verbs: ["get", "list", "create", "update", "delete", "deletecollection", "patch",
|
||||
"watch"]
|
||||
|
||||
---
|
||||
# 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: v1
|
||||
kind: ConfigMap
|
||||
metadata:
|
||||
name: config-contour
|
||||
namespace: knative-serving
|
||||
labels:
|
||||
networking.knative.dev/ingress-provider: contour
|
||||
serving.knative.dev/release: "v0.16.0"
|
||||
data:
|
||||
_example: |
|
||||
################################
|
||||
# #
|
||||
# EXAMPLE CONFIGURATION #
|
||||
# #
|
||||
################################
|
||||
|
||||
# visibility contains the configuration for how to expose services
|
||||
# of assorted visibilities. Each entry is keyed by the visibility
|
||||
# and contains two keys:
|
||||
# 1. the "class" value to pass to the Contour class annotations,
|
||||
# 2. the namespace/name of the Contour Envoy service.
|
||||
visibility: |
|
||||
ExternalIP:
|
||||
class: contour-external
|
||||
service: contour-external/envoy
|
||||
ClusterLocal:
|
||||
class: contour-internal
|
||||
service: contour-internal/envoy
|
||||
|
||||
---
|
||||
# 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: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: contour-ingress-controller
|
||||
namespace: knative-serving
|
||||
labels:
|
||||
networking.knative.dev/ingress-provider: contour
|
||||
spec:
|
||||
replicas: 1
|
||||
selector:
|
||||
matchLabels:
|
||||
app: contour-ingress-controller
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app: contour-ingress-controller
|
||||
spec:
|
||||
serviceAccountName: controller
|
||||
containers:
|
||||
- name: controller
|
||||
# This is the Go import path for the binary that is containerized
|
||||
# and substituted here.
|
||||
image: gcr.io/knative-releases/knative.dev/net-contour/cmd/controller@sha256:07ddbb34ac2d8412569eff362b3a51ad88fa2ca03b82aec41f655b81530c5226
|
||||
resources:
|
||||
requests:
|
||||
cpu: 40m
|
||||
memory: 40Mi
|
||||
limits:
|
||||
cpu: 400m
|
||||
memory: 400Mi
|
||||
env:
|
||||
- name: SYSTEM_NAMESPACE
|
||||
valueFrom:
|
||||
fieldRef:
|
||||
fieldPath: metadata.namespace
|
||||
- name: CONFIG_LOGGING_NAME
|
||||
value: config-logging
|
||||
- name: CONFIG_OBSERVABILITY_NAME
|
||||
value: config-observability
|
||||
- name: METRICS_DOMAIN
|
||||
value: knative.dev/net-contour
|
||||
ports:
|
||||
- name: metrics
|
||||
containerPort: 9090
|
||||
- name: profiling
|
||||
containerPort: 8008
|
||||
securityContext:
|
||||
allowPrivilegeEscalation: false
|
||||
|
||||
---
|
||||
@@ -0,0 +1,19 @@
|
||||
apiVersion: v1
|
||||
kind: ConfigMap
|
||||
metadata:
|
||||
name: config-network
|
||||
namespace: knative-serving
|
||||
labels:
|
||||
serving.knative.dev/release: "v0.16.0"
|
||||
annotations:
|
||||
knative.dev/example-checksum: c7f290c9
|
||||
data:
|
||||
ingress.class: "contour.ingress.networking.knative.dev"
|
||||
---
|
||||
apiVersion: v1
|
||||
kind: ConfigMap
|
||||
metadata:
|
||||
name: config-domain
|
||||
namespace: knative-serving
|
||||
data:
|
||||
kiamol.local: ""
|
||||
@@ -0,0 +1,12 @@
|
||||
apiVersion: serving.knative.dev/v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: api
|
||||
namespace: todo
|
||||
labels:
|
||||
kiamol: ch21-lab
|
||||
spec:
|
||||
template:
|
||||
spec:
|
||||
containers:
|
||||
- image: kiamol/ch21-todo-api
|
||||
@@ -0,0 +1,6 @@
|
||||
apiVersion: v1
|
||||
kind: Namespace
|
||||
metadata:
|
||||
name: todo
|
||||
labels:
|
||||
kiamol: ch21-lab
|
||||
@@ -0,0 +1,40 @@
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: todo-db
|
||||
namespace: todo
|
||||
labels:
|
||||
kiamol: ch21-lab
|
||||
spec:
|
||||
selector:
|
||||
matchLabels:
|
||||
app: todo-db
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app: todo-db
|
||||
spec:
|
||||
containers:
|
||||
- name: db
|
||||
image: postgres:11.6-alpine
|
||||
env:
|
||||
- name: POSTGRES_PASSWORD_FILE
|
||||
value: /secrets/postgres_password
|
||||
- name: PGDATA
|
||||
value: /var/lib/postgresql/data/pgdata
|
||||
volumeMounts:
|
||||
- name: secret
|
||||
mountPath: "/secrets"
|
||||
- name: data
|
||||
mountPath: /var/lib/postgresql/data
|
||||
volumes:
|
||||
- name: secret
|
||||
secret:
|
||||
secretName: todo-db-secret
|
||||
defaultMode: 0400
|
||||
items:
|
||||
- key: POSTGRES_PASSWORD
|
||||
path: postgres_password
|
||||
- name: data
|
||||
persistentVolumeClaim:
|
||||
claimName: todo-db-pvc
|
||||
@@ -0,0 +1,13 @@
|
||||
apiVersion: v1
|
||||
kind: PersistentVolumeClaim
|
||||
metadata:
|
||||
name: todo-db-pvc
|
||||
namespace: todo
|
||||
labels:
|
||||
kiamol: ch21-lab
|
||||
spec:
|
||||
accessModes:
|
||||
- ReadWriteOnce
|
||||
resources:
|
||||
requests:
|
||||
storage: 100Mi
|
||||
@@ -0,0 +1,10 @@
|
||||
apiVersion: v1
|
||||
kind: Secret
|
||||
metadata:
|
||||
name: todo-db-secret
|
||||
namespace: todo
|
||||
labels:
|
||||
kiamol: ch21-lab
|
||||
type: Opaque
|
||||
stringData:
|
||||
POSTGRES_PASSWORD: "kiamol-2*2*"
|
||||
@@ -0,0 +1,13 @@
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: todo-db
|
||||
namespace: todo
|
||||
labels:
|
||||
kiamol: ch21-lab
|
||||
spec:
|
||||
ports:
|
||||
- port: 5432
|
||||
targetPort: 5432
|
||||
selector:
|
||||
app: todo-db
|
||||
@@ -0,0 +1,17 @@
|
||||
apiVersion: v1
|
||||
kind: ConfigMap
|
||||
metadata:
|
||||
name: todo-list-config
|
||||
namespace: todo
|
||||
labels:
|
||||
kiamol: ch21-lab
|
||||
data:
|
||||
config.json: |-
|
||||
{
|
||||
"Database" : {
|
||||
"Provider" : "Postgres"
|
||||
},
|
||||
"MessageQueue": {
|
||||
"Url": "nats://message-queue:4222"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
apiVersion: v1
|
||||
kind: Secret
|
||||
metadata:
|
||||
name: todo-list-secret
|
||||
namespace: todo
|
||||
labels:
|
||||
kiamol: ch21-lab
|
||||
type: Opaque
|
||||
stringData:
|
||||
secrets.json: |-
|
||||
{
|
||||
"ConnectionStrings": {
|
||||
"ToDoDb": "Server=todo-db;Database=todo;User Id=postgres;Password=kiamol-2*2*;",
|
||||
"ToDoDb-ReadOnly": "Server=todo-db;Database=todo;User Id=postgres;Password=kiamol-2*2*;"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,141 @@
|
||||
apiVersion: v1
|
||||
kind: ConfigMap
|
||||
metadata:
|
||||
name: nats-config
|
||||
namespace: todo
|
||||
labels:
|
||||
kiamol: ch21-lab
|
||||
data:
|
||||
nats.conf: |
|
||||
pid_file: "/var/run/nats/nats.pid"
|
||||
http: 8222
|
||||
---
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: message-queue
|
||||
namespace: todo
|
||||
labels:
|
||||
app: nats
|
||||
kiamol: ch21-lab
|
||||
spec:
|
||||
selector:
|
||||
app: nats
|
||||
clusterIP: None
|
||||
ports:
|
||||
- name: client
|
||||
port: 4222
|
||||
- name: cluster
|
||||
port: 6222
|
||||
- name: monitor
|
||||
port: 8222
|
||||
- name: metrics
|
||||
port: 7777
|
||||
- name: leafnodes
|
||||
port: 7422
|
||||
- name: gateways
|
||||
port: 7522
|
||||
---
|
||||
apiVersion: apps/v1
|
||||
kind: StatefulSet
|
||||
metadata:
|
||||
name: nats
|
||||
namespace: todo
|
||||
labels:
|
||||
app: nats
|
||||
kiamol: ch21-lab
|
||||
spec:
|
||||
selector:
|
||||
matchLabels:
|
||||
app: nats
|
||||
replicas: 1
|
||||
serviceName: "nats"
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app: nats
|
||||
spec:
|
||||
# Common volumes for the containers
|
||||
volumes:
|
||||
- name: config-volume
|
||||
configMap:
|
||||
name: nats-config
|
||||
- name: pid
|
||||
emptyDir: {}
|
||||
|
||||
# Required to be able to HUP signal and apply config reload
|
||||
# to the server without restarting the pod.
|
||||
shareProcessNamespace: true
|
||||
|
||||
#################
|
||||
# #
|
||||
# NATS Server #
|
||||
# #
|
||||
#################
|
||||
terminationGracePeriodSeconds: 60
|
||||
containers:
|
||||
- name: nats
|
||||
image: nats:2.1.0-alpine3.10
|
||||
ports:
|
||||
- containerPort: 4222
|
||||
name: client
|
||||
hostPort: 4222
|
||||
- containerPort: 7422
|
||||
name: leafnodes
|
||||
hostPort: 7422
|
||||
- containerPort: 6222
|
||||
name: cluster
|
||||
- containerPort: 8222
|
||||
name: monitor
|
||||
- containerPort: 7777
|
||||
name: metrics
|
||||
command:
|
||||
- "nats-server"
|
||||
- "--config"
|
||||
- "/etc/nats-config/nats.conf"
|
||||
|
||||
# Required to be able to define an environment variable
|
||||
# that refers to other environment variables. This env var
|
||||
# is later used as part of the configuration file.
|
||||
env:
|
||||
- name: POD_NAME
|
||||
valueFrom:
|
||||
fieldRef:
|
||||
fieldPath: metadata.name
|
||||
- name: POD_NAMESPACE
|
||||
valueFrom:
|
||||
fieldRef:
|
||||
fieldPath: metadata.namespace
|
||||
- name: CLUSTER_ADVERTISE
|
||||
value: $(POD_NAME).nats.$(POD_NAMESPACE).svc
|
||||
volumeMounts:
|
||||
- name: config-volume
|
||||
mountPath: /etc/nats-config
|
||||
- name: pid
|
||||
mountPath: /var/run/nats
|
||||
|
||||
# Liveness/Readiness probes against the monitoring
|
||||
#
|
||||
livenessProbe:
|
||||
httpGet:
|
||||
path: /
|
||||
port: 8222
|
||||
initialDelaySeconds: 10
|
||||
timeoutSeconds: 5
|
||||
readinessProbe:
|
||||
httpGet:
|
||||
path: /
|
||||
port: 8222
|
||||
initialDelaySeconds: 10
|
||||
timeoutSeconds: 5
|
||||
|
||||
# Gracefully stop NATS Server on pod deletion or image upgrade.
|
||||
#
|
||||
lifecycle:
|
||||
preStop:
|
||||
exec:
|
||||
# Using the alpine based NATS image, we add an extra sleep that is
|
||||
# the same amount as the terminationGracePeriodSeconds to allow
|
||||
# the NATS Server to gracefully terminate the client connections.
|
||||
#
|
||||
command: ["/bin/sh", "-c", "/nats-server -sl=ldm=/var/run/nats/nats.pid && /bin/sleep 60"]
|
||||
@@ -0,0 +1,45 @@
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: todo-save-handler
|
||||
namespace: todo
|
||||
labels:
|
||||
kiamol: ch21-lab
|
||||
spec:
|
||||
selector:
|
||||
matchLabels:
|
||||
app: todo-list
|
||||
component: save-handler
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app: todo-list
|
||||
component: save-handler
|
||||
spec:
|
||||
containers:
|
||||
- name: web
|
||||
image: kiamol/ch20-todo-save-handler
|
||||
env:
|
||||
- name: Events__events.todo.itemsaved__Publish
|
||||
value: "true"
|
||||
volumeMounts:
|
||||
- name: config
|
||||
mountPath: "/app/config"
|
||||
readOnly: true
|
||||
- name: secret
|
||||
mountPath: "/app/secrets"
|
||||
readOnly: true
|
||||
volumes:
|
||||
- name: config
|
||||
configMap:
|
||||
name: todo-list-config
|
||||
items:
|
||||
- key: config.json
|
||||
path: config.json
|
||||
- name: secret
|
||||
secret:
|
||||
secretName: todo-list-secret
|
||||
defaultMode: 0400
|
||||
items:
|
||||
- key: secrets.json
|
||||
path: secrets.json
|
||||
@@ -0,0 +1,18 @@
|
||||
apiVersion: networking.k8s.io/v1beta1
|
||||
kind: Ingress
|
||||
metadata:
|
||||
name: todo-web
|
||||
namespace: todo
|
||||
labels:
|
||||
kiamol: ch21-lab
|
||||
annotations:
|
||||
kubernetes.io/ingress.class: contour-external
|
||||
spec:
|
||||
rules:
|
||||
- host: todo.kiamol.local
|
||||
http:
|
||||
paths:
|
||||
- path: /
|
||||
backend:
|
||||
serviceName: todo-web
|
||||
servicePort: 80
|
||||
@@ -0,0 +1,14 @@
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: todo-web
|
||||
namespace: todo
|
||||
labels:
|
||||
kiamol: ch21-lab
|
||||
spec:
|
||||
ports:
|
||||
- port: 80
|
||||
targetPort: 80
|
||||
selector:
|
||||
app: todo-list
|
||||
component: web
|
||||
@@ -0,0 +1,42 @@
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: todo-web
|
||||
namespace: todo
|
||||
labels:
|
||||
kiamol: ch21-lab
|
||||
spec:
|
||||
selector:
|
||||
matchLabels:
|
||||
app: todo-list
|
||||
component: web
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app: todo-list
|
||||
component: web
|
||||
spec:
|
||||
containers:
|
||||
- name: web
|
||||
image: kiamol/ch20-todo-list
|
||||
volumeMounts:
|
||||
- name: config
|
||||
mountPath: "/app/config"
|
||||
readOnly: true
|
||||
- name: secret
|
||||
mountPath: "/app/secrets"
|
||||
readOnly: true
|
||||
volumes:
|
||||
- name: config
|
||||
configMap:
|
||||
name: todo-list-config
|
||||
items:
|
||||
- key: config.json
|
||||
path: config.json
|
||||
- name: secret
|
||||
secret:
|
||||
secretName: todo-list-secret
|
||||
defaultMode: 0400
|
||||
items:
|
||||
- key: secrets.json
|
||||
path: secrets.json
|
||||
Reference in New Issue
Block a user