Skip to content

Commit 0480b73

Browse files
author
Vadym Mudryi
committed
updated readme
1 parent 960a2e1 commit 0480b73

File tree

5 files changed

+102
-69
lines changed

5 files changed

+102
-69
lines changed

README.md

Lines changed: 57 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,16 @@ You need to fork the [opencrvs-countryconfig](https://github.com/opencrvs/opencr
152152
8. Navigate to [http://localhost:10350/](http://localhost:10350/)
153153
9. Once all container images are up and running your environment will be available at https://opencrvs.localhost
154154

155+
## Seed data
156+
157+
1. Navigate to file `kubernetes/opencrvs-services/values-dev.yaml` in opencrvs-core (or your country config) repository
158+
2. Change value `data_seeder.enabled` to `true`.
159+
3. Save changes
160+
4. New tilt resource `data-seeder` will be created, check [http://localhost:10350/](http://localhost:10350/)
161+
5. Make sure data-seeder job completed without issues.
162+
6. Change value `data_seeder.enabled` to `false`.
163+
7. Save changes
164+
155165
## Common issues
156166

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

163173
### Reset local environment
164174

165-
Restart docker desktop
175+
Draft and working way is to restart docker desktop
176+
177+
### Troubleshooting connectivity inside Kubernetes cluster
178+
179+
1. Issue fresh token:
180+
181+
```bash
182+
USERNAME=o.admin
183+
SUPER_USER_PASSWORD=password
184+
curl -X POST "http://auth.opencrvs-dev.svc.cluster.local:4040/authenticate-super-user" \
185+
-H "Content-Type: application/json" \
186+
-d '{
187+
"username": "'"${USERNAME}"'",
188+
"password": "'"$SUPER_USER_PASSWORD"'"
189+
}'
190+
```
191+
192+
2. Check gateway host:
193+
```bash
194+
GATEWAY_HOST=http://gateway.opencrvs-dev.svc.cluster.local:7070
195+
curl -X GET \
196+
-H "Content-Type: application/json" \
197+
-H "Authorization: Bearer ${token}" \
198+
${GATEWAY_HOST}/locations?type=ADMIN_STRUCTURE&_count=0
199+
```
200+
3. Check config host:
201+
```bash
202+
curl -v -X GET \
203+
-H "Content-Type: application/json" \
204+
-H "Authorization: Bearer ${token}" \
205+
http://config.opencrvs-dev.svc.cluster.local:2021/locations?type=ADMIN_STRUCTURE&_count=0
206+
```
207+
4. Check Hearth:
208+
```bash
209+
curl -v http://hearth.opencrvs-deps-dev.svc.cluster.local:3447/fhir/Location
210+
```
211+
212+
### Login/Client service is not responding: Check login logs
213+
```
214+
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/"
215+
```
216+
217+
Solution: restart nginx inside login container or delete login pod
218+
```
219+
nginx -s reload
220+
```
221+
166222
167223
---
168224

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"

0 commit comments

Comments
 (0)