Skip to content

Commit d91d669

Browse files
aslafy-zNimJay
andauthored
docs: kustomize component for base url (#2645)
* docs: kustomize component for base url * Create kustomization.yaml * Add license * Update copyright date --------- Co-authored-by: Nim Jayawardena <[email protected]>
1 parent 35040ac commit d91d669

File tree

2 files changed

+94
-0
lines changed

2 files changed

+94
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
# Customize the Base URL for Online Boutique
2+
3+
This component allows you to change the base URL for the Online Boutique application. By default, the application uses the root path ("/") as its base URL. This customization sets the base URL to "/online-boutique" and updates the health check paths accordingly.
4+
5+
## What it does
6+
7+
1. Sets the `BASE_URL` environment variable to "/online-boutique" for the frontend deployment.
8+
2. Updates the liveness probe path to "/online-boutique/_healthz".
9+
3. Updates the readiness probe path to "/online-boutique/_healthz".
10+
11+
## How to use
12+
13+
To apply this customization, you can use Kustomize to include this component in your deployment.
14+
15+
From the `kustomize/` folder at the root level of this repository, execute this command:
16+
17+
```bash
18+
kustomize edit add component components/custom-base-url
19+
```
20+
21+
This will update the `kustomize/kustomization.yaml` file, which could look similar to:
22+
23+
```yaml
24+
apiVersion: kustomize.config.k8s.io/v1beta1
25+
kind: Kustomization
26+
resources:
27+
- base
28+
components:
29+
- components/custom-base-url
30+
```
31+
32+
## Render and Deploy
33+
34+
You can locally render these manifests by running:
35+
36+
```bash
37+
kubectl kustomize .
38+
```
39+
40+
To deploy the customized application, run:
41+
42+
```bash
43+
kubectl apply -k .
44+
```
45+
46+
## Customizing the Base URL
47+
48+
If you want to use a different base URL, you can modify the `value` fields in the kustomization.yaml file. Make sure to update all three occurrences:
49+
50+
1. The `BASE_URL` environment variable
51+
2. The liveness probe path
52+
3. The readiness probe path
53+
54+
For example, to change the base URL to "/shop", you would modify the values as follows:
55+
56+
```yaml
57+
value: /shop
58+
value: /shop/_healthz
59+
value: /shop/_healthz
60+
```
61+
62+
Note: After changing the base URL, make sure to update any internal links or references within your application to use the new base URL.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# Copyright 2024 Google LLC
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
apiVersion: kustomize.config.k8s.io/v1alpha1
16+
kind: Component
17+
patches:
18+
- target:
19+
kind: Deployment
20+
name: frontend
21+
patch: |-
22+
- op: add
23+
path: /spec/template/spec/containers/0/env/-
24+
value:
25+
name: BASE_URL
26+
value: /online-boutique
27+
- op: replace
28+
path: /spec/template/spec/containers/0/livenessProbe/httpGet/path
29+
value: /online-boutique/_healthz
30+
- op: replace
31+
path: /spec/template/spec/containers/0/readinessProbe/httpGet/path
32+
value: /online-boutique/_healthz

0 commit comments

Comments
 (0)