-
Notifications
You must be signed in to change notification settings - Fork 97
/
Copy pathservice.yaml
100 lines (99 loc) · 3.71 KB
/
service.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
# Copyright 2023 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
#
# 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: serving.knative.dev/v1
kind: Service
# [START cloudrun_mc_hello_sidecar_step_metadata]
metadata:
name: "MC_SERVICE_NAME"
labels:
cloud.googleapis.com/location: "REGION"
annotations:
# Required to use Cloud Run multi-containers (preview feature)
run.googleapis.com/launch-stage: BETA
run.googleapis.com/description: sample tutorial service
# Externally available
run.googleapis.com/ingress: all
# [END cloudrun_mc_hello_sidecar_step_metadata]
# [START cloudrun_mc_hello_sidecar_step_deps]
spec:
template:
metadata:
annotations:
# Defines container startup order within multi-container service.
# Below requires hello container to spin up before nginx container,
# which depends on the hello container.
# https://cloud.google.com/run/docs/configuring/containers#container-ordering
run.googleapis.com/container-dependencies: "{nginx: [hello]}"
# [END cloudrun_mc_hello_sidecar_step_deps]
# [START cloudrun_mc_hello_sidecar_step_serving]
spec:
containers:
# A) Serving ingress container "nginx" listening at PORT 8080
# Main entrypoint of multi-container service.
# Source is stored in nginx_config secret in Secret Manager.
# Any pings to this container will proxy over to hello container at PORT 8888.
# https://cloud.google.com/run/docs/container-contract#port
- image: nginx
name: nginx
ports:
- name: http1
containerPort: 8080
resources:
limits:
cpu: 500m
memory: 256Mi
# Referencing declared volume below,
# Declaring volume to mount in current ingress container's filesystem
# https://cloud.google.com/run/docs/reference/rest/v2/Container#volumemount
volumeMounts:
- name: nginx-conf-secret
readOnly: true
mountPath: /etc/nginx/conf.d/
startupProbe:
timeoutSeconds: 240
periodSeconds: 240
failureThreshold: 1
tcpSocket:
port: 8080
# [END cloudrun_mc_hello_sidecar_step_serving]
# B) Sidecar container "hello" listening at PORT 8888,
# which can only be accessed by serving ingress container
# [START cloudrun_mc_hello_sidecar_step_sidecar]
- image: us-docker.pkg.dev/cloudrun/container/hello
name: hello
env:
- name: PORT
value: "8888"
resources:
limits:
cpu: 1000m
memory: 512Mi
startupProbe:
timeoutSeconds: 240
periodSeconds: 240
failureThreshold: 1
tcpSocket:
port: 8888
# [END cloudrun_mc_hello_sidecar_step_sidecar]
# Named volume pointing to
# nginx_config secret in secret manager
# [START cloudrun_mc_hello_sidecar_step_secret]
volumes:
- name: nginx-conf-secret
secret:
secretName: nginx_config
items:
- key: latest
path: default.conf
# [END cloudrun_mc_hello_sidecar_step_secret]