@@ -29,29 +29,37 @@ Change the name "test-api-platform" to your Google project ID (not the project n
29
29
[ Quickstart Google Cloud] ( https://cloud.google.com/sdk/docs/quickstart?hl=de )
30
30
If you do not have gcloud yet, install it with these command.
31
31
32
- curl https://sdk.cloud.google.com | bash
32
+ ```
33
+ curl https://sdk.cloud.google.com | bash
34
+ ```
33
35
34
36
#### 1. Build the PHP and Caddy Docker images and tag them
35
37
36
38
Versioning: The 0.1.0 is the version. This value should be the same as the attribute ` appVersion ` in ` Chart.yaml ` .
37
39
Infos for [ Google Container pulling and pushing] ( https://cloud.google.com/container-registry/docs/pushing-and-pulling )
38
40
39
- docker build -t gcr.io/test-api-platform/php:0.1.0 -t gcr.io/test-api-platform/php:latest api --target api_platform_php
40
- docker build -t gcr.io/test-api-platform/caddy:0.1.0 -t gcr.io/test-api-platform/caddy:latest api --target api_platform_caddy
41
- docker build -t gcr.io/test-api-platform/pwa:0.1.0 -t gcr.io/test-api-platform/pwa:latest pwa --target api_platform_pwa_prod
41
+ ```
42
+ docker build -t gcr.io/test-api-platform/php:0.1.0 -t gcr.io/test-api-platform/php:latest api --target api_platform_php
43
+ docker build -t gcr.io/test-api-platform/caddy:0.1.0 -t gcr.io/test-api-platform/caddy:latest api --target api_platform_caddy
44
+ docker build -t gcr.io/test-api-platform/pwa:0.1.0 -t gcr.io/test-api-platform/pwa:latest pwa --target api_platform_pwa_prod
45
+ ```
42
46
43
47
#### 2. Push your images to your Docker registry
44
48
45
- gcloud auth configure-docker
46
- docker push gcr.io/test-api-platform/php
47
- docker push gcr.io/test-api-platform/caddy
48
- docker push gcr.io/test-api-platform/pwa
49
+ ```
50
+ gcloud auth configure-docker
51
+ docker push gcr.io/test-api-platform/php
52
+ docker push gcr.io/test-api-platform/caddy
53
+ docker push gcr.io/test-api-platform/pwa
54
+ ```
49
55
50
56
Optional push the version images:
51
57
52
- docker push gcr.io/test-api-platform/php:0.1.0
53
- docker push gcr.io/test-api-platform/caddy:0.1.0
54
- docker push gcr.io/test-api-platform/pwa:0.1.0
58
+ ```
59
+ docker push gcr.io/test-api-platform/php:0.1.0
60
+ docker push gcr.io/test-api-platform/caddy:0.1.0
61
+ docker push gcr.io/test-api-platform/pwa:0.1.0
62
+ ```
55
63
56
64
The result should look similar to these images.
57
65
@@ -62,35 +70,43 @@ The result should look similar to these images.
62
70
63
71
### 1. Check the Helm version
64
72
65
- helm version
73
+ ```
74
+ helm version
75
+ ```
66
76
67
77
If you are using version 2.x follow this [ guide to migrate Helm to v3] ( https://helm.sh/docs/topics/v2_v3_migration/#helm )
68
78
69
79
### 2. Firstly you need to update helm dependencies by running
70
80
71
- helm dependency update ./helm/api-platform
81
+ ```
82
+ helm dependency update ./helm/api-platform
83
+ ```
72
84
73
85
This will create a folder helm/api-platform/charts/ and add all dependencies there.
74
86
Actual this is [ bitnami/postgresql] ( https://bitnami.com/stack/postgresql/helm ) , a file postgresql-[ VERSION] .tgz is created.
75
87
76
88
### 3. Optional: If you made changes to the Helm chart, check if its format is correct
77
89
78
- helm lint ./helm/api-platform
90
+ ```
91
+ helm lint ./helm/api-platform
92
+ ```
79
93
80
94
### 4. Deploy your API to the container
81
95
82
- helm upgrade main ./helm/api-platform --namespace=default --create-namespace --wait \
83
- --install \
84
- --set "php.image.repository=gcr.io/test-api-platform/php" \
85
- --set php.image.tag=latest \
86
- --set "caddy.image.repository=gcr.io/test-api-platform/caddy" \
87
- --set caddy.image.tag=latest \
88
- --set "pwa.image.repository=gcr.io/test-api-platform/pwa" \
89
- --set pwa.image.tag=latest \
90
- --set php.appSecret='!ChangeMe!' \
91
- --set postgresql.postgresqlPassword='!ChangeMe!' \
92
- --set postgresql.persistence.enabled=true \
93
- --set "corsAllowOrigin=^https?:\/\/[a-z]*\.mywebsite.com$"
96
+ ```
97
+ helm upgrade main ./helm/api-platform --namespace=default --create-namespace --wait \
98
+ --install \
99
+ --set "php.image.repository=gcr.io/test-api-platform/php" \
100
+ --set php.image.tag=latest \
101
+ --set "caddy.image.repository=gcr.io/test-api-platform/caddy" \
102
+ --set caddy.image.tag=latest \
103
+ --set "pwa.image.repository=gcr.io/test-api-platform/pwa" \
104
+ --set pwa.image.tag=latest \
105
+ --set php.appSecret='!ChangeMe!' \
106
+ --set postgresql.postgresqlPassword='!ChangeMe!' \
107
+ --set postgresql.persistence.enabled=true \
108
+ --set "corsAllowOrigin=^https?:\/\/[a-z]*\.mywebsite.com$"
109
+ ```
94
110
95
111
The ` " ` are necessary for Windows. Use ^ on Windows instead of \ to split commands into multiple lines.
96
112
You can add the parameter ` --dry-run ` to check upfront if anything is correct.
@@ -109,10 +125,12 @@ get access on your local machine to the deploy. See image below.
109
125
If you prefer to use a managed DBMS like [ Heroku Postgres] ( https://www.heroku.com/postgres ) or
110
126
[ Google Cloud SQL] ( https://cloud.google.com/sql/docs/postgres/ ) (recommended):
111
127
112
- helm upgrade api-platform ./helm/api-platform \
113
- # ...
114
- --set postgresql.enabled=false \
115
- --set postgresql.url=pgsql://username:password@host/database?serverVersion=13
128
+ ```
129
+ helm upgrade api-platform ./helm/api-platform \
130
+ # ...
131
+ --set postgresql.enabled=false \
132
+ --set postgresql.url=pgsql://username:password@host/database?serverVersion=13
133
+ ```
116
134
117
135
Finally, build the ` pwa ` (client and admin) JavaScript apps and [ deploy them on a static
118
136
site hosting service] ( https://create-react-app.dev/docs/deployment/ ) .
@@ -122,8 +140,10 @@ site hosting service](https://create-react-app.dev/docs/deployment/).
122
140
You can access the php container of the pod with the following command.
123
141
In this example the symfony console is called.
124
142
125
- CADDY_PHP_POD=$(kubectl --namespace=default get pods -l app.kubernetes.io/name=api-platform -o jsonpath="{.items[0].metadata.name}")
126
- kubectl --namespace=default exec -it $CADDY_PHP_POD -c api-platform-php -- bin/console
143
+ ```
144
+ CADDY_PHP_POD=$(kubectl --namespace=default get pods -l app.kubernetes.io/name=api-platform -o jsonpath="{.items[0].metadata.name}")
145
+ kubectl --namespace=default exec -it $CADDY_PHP_POD -c api-platform-php -- bin/console
146
+ ```
127
147
128
148
## Caution for system architecture
129
149
@@ -148,7 +168,8 @@ You can upgrade with the same command from the installation and pass all paramet
148
168
Infos about [ best practices for tagging images for kubernetes] ( https://kubernetes.io/docs/concepts/containers/images/ )
149
169
You have to use the * .image.pullPolicy=Always see the last 3 parameters.
150
170
151
- helm upgrade api-platform ./helm/api-platform --namespace=default \
171
+ ```
172
+ helm upgrade api-platform ./helm/api-platform --namespace=default \
152
173
--set "php.image.repository=gcr.io/test-api-platform/php" \
153
174
--set php.image.tag=latest \
154
175
--set "caddy.image.repository=gcr.io/test-api-platform/caddy" \
@@ -162,6 +183,7 @@ You have to use the *.image.pullPolicy=Always see the last 3 parameters.
162
183
--set php.image.pullPolicy=Always \
163
184
--set caddy.image.pullPolicy=Always \
164
185
--set pwa.image.pullPolicy=Always
186
+ ```
165
187
166
188
## GitHub Actions Example for deployment
167
189
@@ -175,24 +197,30 @@ Start by creating a new template for the queue-worker-deployment. The `deploymen
175
197
176
198
Add the following lines under ` containers ` to overwrite the command.
177
199
178
- command:
179
- {{ range .Values.queue_worker.command }}
180
- - {{ . | quote }}
181
- {{ end }}
182
- args:
183
- {{ range .Values.queue_worker.commandArgs }}
184
- - {{ . | quote }}
185
- {{ end }}
200
+ ```
201
+ command:
202
+ {{ range .Values.queue_worker.command }}
203
+ - {{ . | quote }}
204
+ {{ end }}
205
+ args:
206
+ {{ range .Values.queue_worker.commandArgs }}
207
+ - {{ . | quote }}
208
+ {{ end }}
209
+ ```
186
210
187
211
Here is an example on how to use it from your ` values.yaml ` :
188
212
189
- command: ['bin/console']
190
- commandArgs: ['messenger:consume', 'async', '--memory-limit=100M']
213
+ ```
214
+ command: ['bin/console']
215
+ commandArgs: ['messenger:consume', 'async', '--memory-limit=100M']
216
+ ```
191
217
192
218
The ` readinessProbe ` and the ` livenessProble ` can not use the default ` docker-healthcheck ` but should test if the command is running.
193
219
194
- readinessProbe:
195
- exec:
196
- command: ["/bin/sh", "-c", "/bin/ps -ef | grep messenger:consume | grep -v grep"]
197
- initialDelaySeconds: 120
198
- periodSeconds: 3
220
+ ```
221
+ readinessProbe:
222
+ exec:
223
+ command: ["/bin/sh", "-c", "/bin/ps -ef | grep messenger:consume | grep -v grep"]
224
+ initialDelaySeconds: 120
225
+ periodSeconds: 3
226
+ ```
0 commit comments