Skip to content

Commit 236f907

Browse files
author
Vadym Mudryi
committed
updated readme
1 parent 960a2e1 commit 236f907

File tree

6 files changed

+139
-79
lines changed

6 files changed

+139
-79
lines changed

README.md

Lines changed: 93 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ You need to clone the [opencrvs-core](https://github.com/opencrvs/opencrvs-core)
112112
```
113113
6. [Temporary Step] Switch to the k8s-version branch:
114114
```bash
115-
git checkout k8s-version
115+
git checkout k8s-refresh
116116
```
117117
7. Run Tilt:
118118
```bash
@@ -123,27 +123,55 @@ You need to clone the [opencrvs-core](https://github.com/opencrvs/opencrvs-core)
123123

124124
---
125125

126-
## [🚧 Coming soon] For OpenCRVS Country Configuration Developers
126+
## For OpenCRVS Country Config Developers
127127

128-
You need to fork the [opencrvs-countryconfig](https://github.com/opencrvs/opencrvs-countryconfig) repository and clone the [infrastructure](https://github.com/opencrvs/infrastructure) repository. If these repositories are already on your laptop, ensure they are in the same folder.
128+
Please follow official documentation how to setup your own country configuration at [Set-up your own, local, country configuration](https://documentation.opencrvs.org/setup/3.-installation/3.2-set-up-your-own-country-configuration).
129+
You need to fork (clone) the [opencrvs-countryconfig](https://github.com/opencrvs/opencrvs-countryconfig) repository and clone the [infrastructure](https://github.com/opencrvs/infrastructure) repository. If repositories are already on your laptop, ensure they are in the same parent folder, for example:
130+
```
131+
repositories/
132+
infrastructure
133+
opencrvs-countryconfig
134+
...
135+
```
129136
130-
1. Create a new folder or use an existing folder to store the repositories.
137+
**Step by step instruction**
138+
139+
1. Create a new folder or use an existing folder to store the repositories. For example folder could be located at your home directory or in documents:
140+
```bash
141+
mkdir ~/Documents/repository
142+
```
131143
2. Open a terminal (command line) and navigate to the folder.
132-
3. Clone your fork of the OpenCRVS Country Configuration repository:
144+
```bash
145+
cd ~/Documents/repository
146+
```
147+
3. Clone OpenCRVS Country Config repository:
148+
149+
For county config use:
150+
```bash
151+
git clone https://github.com/opencrvs/opencrvs-countryconfig
152+
```
153+
For your own fork use:
133154
```bash
134155
git clone [email protected]:<your-github-account>/<your-repository>.git
135156
```
157+
136158
4. Clone the Infrastructure repository:
137159
```bash
138160
git clone [email protected]:opencrvs/infrastructure.git
139161
```
140-
5. Change directory to your forked repository:
162+
5. Change directory to country config (your own) repository:
163+
164+
For county config use:
165+
```bash
166+
cd opencrvs-countryconfig
167+
```
168+
For your own fork use:
141169
```bash
142170
cd <your-repository>
143171
```
144-
6. [Temporary Step] Switch to the k8s-version branch:
172+
6. [Temporary Step] Switch to the k8s-refresh branch:
145173
```bash
146-
git checkout k8s-version
174+
git checkout k8s-refresh
147175
```
148176
7. Run Tilt:
149177
```bash
@@ -152,6 +180,16 @@ You need to fork the [opencrvs-countryconfig](https://github.com/opencrvs/opencr
152180
8. Navigate to [http://localhost:10350/](http://localhost:10350/)
153181
9. Once all container images are up and running your environment will be available at https://opencrvs.localhost
154182

183+
## Seed data
184+
185+
1. Navigate to file `kubernetes/opencrvs-services/values-dev.yaml` in opencrvs-core (or your country config) repository
186+
2. Change value `data_seeder.enabled` to `true`.
187+
3. Save changes
188+
4. New tilt resource `data-seeder` will be created, check [http://localhost:10350/](http://localhost:10350/)
189+
5. Make sure data-seeder job completed without issues.
190+
6. Change value `data_seeder.enabled` to `false`.
191+
7. Save changes
192+
155193
## Common issues
156194

157195
### Container start is failing with ImagePullBackOff
@@ -162,7 +200,53 @@ Check image tag was set properly, use `kubectl`, adjust value in `kubernetes/ope
162200

163201
### Reset local environment
164202

165-
Restart docker desktop
203+
Draft and working way is to restart docker desktop
204+
205+
### Troubleshooting connectivity inside Kubernetes cluster
206+
207+
1. Issue fresh token:
208+
209+
```bash
210+
USERNAME=o.admin
211+
SUPER_USER_PASSWORD=password
212+
curl -X POST "http://auth.opencrvs-dev.svc.cluster.local:4040/authenticate-super-user" \
213+
-H "Content-Type: application/json" \
214+
-d '{
215+
"username": "'"${USERNAME}"'",
216+
"password": "'"$SUPER_USER_PASSWORD"'"
217+
}'
218+
```
219+
220+
2. Check gateway host:
221+
```bash
222+
GATEWAY_HOST=http://gateway.opencrvs-dev.svc.cluster.local:7070
223+
curl -X GET \
224+
-H "Content-Type: application/json" \
225+
-H "Authorization: Bearer ${token}" \
226+
${GATEWAY_HOST}/locations?type=ADMIN_STRUCTURE&_count=0
227+
```
228+
3. Check config host:
229+
```bash
230+
curl -v -X GET \
231+
-H "Content-Type: application/json" \
232+
-H "Authorization: Bearer ${token}" \
233+
http://config.opencrvs-dev.svc.cluster.local:2021/locations?type=ADMIN_STRUCTURE&_count=0
234+
```
235+
4. Check Hearth:
236+
```bash
237+
curl -v http://hearth.opencrvs-deps-dev.svc.cluster.local:3447/fhir/Location
238+
```
239+
240+
### Login/Client service is not responding: Check login logs
241+
```
242+
2025/03/19 07:53:38 [error] 15#15: *1 upstream timed out (110: Connection timed out) while connecting to upstream, client: 10.1.3.102, server: localhost, request: "GET /api/countryconfig/login-config.js HTTP/1.1", upstream: "http://10.100.14.175:3040/login-config.js", host: "login.opencrvs.localhost", referrer: "https://login.opencrvs.localhost/"
243+
```
244+
245+
Solution: restart nginx inside login container or delete login pod
246+
```
247+
nginx -s reload
248+
```
249+
166250
167251
---
168252

charts/opencrvs-services/README.md

Lines changed: 45 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ Helm chart to deploy all OpenCRVS services on Kubernetes cluster.
1818
<tr>
1919
<td>elasticsearch_host</td>
2020
<td>elasticsearch.opencrvs-deps-dev.svc.cluster.local:9200</td>
21-
<td>Elasticsearch configuration, including the hostname and port. TODO: Consider defining the port as a separate variable.</td>
21+
<td>Elasticsearch configuration, including the hostname and port.<br> <b>NOTE</b>: Some services require authentication, please use secrets to redefine ES_HOST variable if needed.</td>
2222
</tr>
2323
<tr>
2424
<td>influxdb.host</td>
@@ -55,6 +55,11 @@ Helm chart to deploy all OpenCRVS services on Kubernetes cluster.
5555
<td>mongodb-0.mongodb.opencrvs-deps-dev.svc.cluster.local</td>
5656
<td>MongoDB hostname configuration.</td>
5757
</tr>
58+
<tr>
59+
<td>redis_host</td>
60+
<td>redis-0.redis.opencrvs-deps-dev.svc.cluster.local</td>
61+
<td>Redis hostname configuration.</td>
62+
</tr>
5863
<tr>
5964
<td>hostname</td>
6065
<td>farajaland.com</td>
@@ -80,26 +85,17 @@ Helm chart to deploy all OpenCRVS services on Kubernetes cluster.
8085
<td>{}</td>
8186
<td>Mapping kubernetes secrets as environment variables. For more information see [Mapping secrets](#mapping-secrets)</td>
8287
</tr>
88+
<tr>
89+
<td>data_seeder.enabled</td>
90+
<td>true</td>
91+
<td>Seed data as post-install step, data seeder is executed only once while `helm install`. In some cases when data is already seeded, e/g upgrade, this value must be set to false. **Note**: default user is used for data seeding, it will fail anyway on database with non-default data.</td>
92+
</tr>
8393
</tbody>
8494
</table>
8595

86-
# Microservice environment variables configuration
87-
88-
<pre>Do we need this section?</pre>
89-
90-
Helm chart allows to define environment variables in following scopes:
91-
- **Global variables** are defined at top level of values file and is added to all containers. See `env` key in [values.yaml](values.yaml)
92-
- **Service level variables** are defined for each particular service. See `<service_name>.env` key in [values.yaml](values.yaml)
93-
- **Secret environment variables** are defined at service level as `<service_name>.secrets` key, see [values.yaml](values.yaml).
9496

9597
# Mapping secrets
9698

97-
Suppose we need to store ES_HOST variable as a secret since it contains url with login and password for Elastic search.
98-
Kubernetes secret is key/value object usually created from `.env` file, for example:
99-
```
100-
ES_HOST=user:randompass@elasticsearch:9200
101-
```
102-
10399
Mapping needs to be added for particular service to access variable inside workload (service), e/g for `search` service to access ES_HOST following configuration is needed:
104100
```
105101
search:
@@ -117,4 +113,37 @@ secrets:
117113
Summary:
118114
- `secret_name`, name of Kubernetes secret object
119115
- `secret_key`, key (variable name) inside Kubernetes secret data property
120-
- `environment_variable`, environment variable name inside container. If `secret_key` value `environment_variable` are the same, last one can be omitted.
116+
- `environment_variable`, environment variable name inside container. If `secret_key` value `environment_variable` are the same, last one can be omitted.
117+
118+
**Step by step example**
119+
120+
Suppose we need to store ES_HOST variable as a secret and provide variable value to service `search`.
121+
122+
1. Create `.env` like file and put all variables:
123+
```
124+
ES_HOST=user:randompass@elasticsearch:9200
125+
```
126+
2. Create kubernetes secret from `.env` file:
127+
```
128+
kubectl create secret generic elasticsearch-secret --from-env-file=.env
129+
```
130+
3. Make sure the secret was created:
131+
```
132+
kubectl get secret -oyaml elasticsearch-secret
133+
```
134+
Example output:
135+
```yaml
136+
apiVersion: v1
137+
data:
138+
ES_HOST: dXNlcjpyYW5kb21wYXNzQGVsYXN0aWNzZWFyY2g6OTIwMA==
139+
...
140+
```
141+
3. Map variable in your helm chart values file:
142+
```yaml
143+
search:
144+
secrets:
145+
elasticsearch-secret:
146+
- ES_HOST
147+
...
148+
```
149+
4. Redeploy service with `helm upgrade`

charts/opencrvs-services/Troubleshooting inside Kubernetes cluste.md

Lines changed: 0 additions & 47 deletions
This file was deleted.

charts/opencrvs-services/templates/data-seeder.yaml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,5 @@ spec:
2525
- name: COUNTRY_CONFIG_HOST
2626
value: http://countryconfig.{{ .Release.Namespace }}.svc.cluster.local:3040
2727
{{- include "render-env-vars" (dict "service_name" "data_seeder" "Values" .Values) }}
28-
completions: 1 # Run the job once
29-
backoffLimit: 0 # Don't retry if the job fails
3028
restartPolicy: "OnFailure"
3129
{{- end }}

charts/opencrvs-services/templates/migration-job.yaml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,4 @@ spec:
4444
- name: WAIT_HOSTS
4545
value: "{{ .Values.mongodb_host }}:27017,{{ .Values.influxdb.host }}:{{ .Values.influxdb.port }},{{ .Values.minio.host }}:{{ .Values.minio.port }},{{ .Values.elasticsearch_host }}"
4646
{{- include "render-env-vars" (dict "service_name" "migration" "Values" .Values) }}
47-
# TODO: Check if these properties are required for the migration job.
48-
completions: 1 # Run the job once
49-
backoffLimit: 0 # Don't retry if the job fails
5047
restartPolicy: "OnFailure"

charts/opencrvs-services/values.yaml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,7 @@ config:
5656
CHECK_INVALID_TOKEN: true
5757
NODE_ENV: production
5858
# Mapping for external secrets goes here:
59-
60-
secrets:
59+
secrets: {}
6160

6261
countryconfig:
6362
image:

0 commit comments

Comments
 (0)