{"id":14483432,"url":"https://github.com/peter-evans/nominatim-k8s","last_synced_at":"2025-04-30T09:16:36.573Z","repository":{"id":40614129,"uuid":"76341475","full_name":"peter-evans/nominatim-k8s","owner":"peter-evans","description":"Nominatim for Kubernetes on Google Container Engine (GKE).","archived":false,"fork":false,"pushed_at":"2023-01-12T12:58:43.000Z","size":46,"stargazers_count":70,"open_issues_count":4,"forks_count":29,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-04-30T09:16:24.693Z","etag":null,"topics":["canary-deployment","docker-image","gke","google-cloud","google-storage","kubernetes","nominatim","pbf"],"latest_commit_sha":null,"homepage":"https://hub.docker.com/r/peterevans/nominatim-k8s/","language":"Shell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/peter-evans.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-12-13T09:03:19.000Z","updated_at":"2025-03-01T15:54:11.000Z","dependencies_parsed_at":"2023-02-09T12:00:24.409Z","dependency_job_id":null,"html_url":"https://github.com/peter-evans/nominatim-k8s","commit_stats":null,"previous_names":[],"tags_count":20,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/peter-evans%2Fnominatim-k8s","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/peter-evans%2Fnominatim-k8s/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/peter-evans%2Fnominatim-k8s/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/peter-evans%2Fnominatim-k8s/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/peter-evans","download_url":"https://codeload.github.com/peter-evans/nominatim-k8s/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251674590,"owners_count":21625646,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["canary-deployment","docker-image","gke","google-cloud","google-storage","kubernetes","nominatim","pbf"],"created_at":"2024-09-03T00:01:46.098Z","updated_at":"2025-04-30T09:16:36.546Z","avatar_url":"https://github.com/peter-evans.png","language":"Shell","funding_links":[],"categories":["Shell"],"sub_categories":[],"readme":"# Nominatim for Kubernetes\n[![](https://images.microbadger.com/badges/image/peterevans/nominatim-k8s.svg)](https://microbadger.com/images/peterevans/nominatim-k8s)\n[![CircleCI](https://circleci.com/gh/peter-evans/nominatim-k8s/tree/master.svg?style=svg)](https://circleci.com/gh/peter-evans/nominatim-k8s/tree/master)\n\n[Nominatim](https://github.com/openstreetmap/Nominatim) for Kubernetes on Google Container Engine (GKE).\n\nThis Docker image and sample Kubernetes configuration files are one solution to persisting Nominatim data and providing immutable deployments.\n\n## Supported tags and respective `Dockerfile` links\n\n- [`2.6.2`, `2.6`, `latest`, `2.6.2-nominatim3.5.2`, `2.6-nominatim3.5.2`, `latest-nominatim3.5.2`  (*2.6/Dockerfile*)](https://github.com/peter-evans/nominatim-docker/tree/v2.6.2)\n- [`2.6.1`, `2.6.1-nominatim3.5.1`, `2.6-nominatim3.5.1`, `latest-nominatim3.5.1`  (*2.6/Dockerfile*)](https://github.com/peter-evans/nominatim-docker/tree/v2.6.1)\n- [`2.6.0`, `2.6.0-nominatim3.5.0`, `2.6-nominatim3.5.0`, `latest-nominatim3.5.0`  (*2.6/Dockerfile*)](https://github.com/peter-evans/nominatim-docker/tree/v2.6.0)\n- [`2.5.4`, `2.5`, `2.5.4-nominatim3.4.2`, `2.5-nominatim3.4.2`, `latest-nominatim3.4.2`  (*2.5/Dockerfile*)](https://github.com/peter-evans/nominatim-docker/tree/v2.5.4)\n\n## Usage\nThe Docker image can be run standalone without Kubernetes:\n\n```bash\ndocker run -d -p 8080:8080 \\\n-e NOMINATIM_PBF_URL='http://download.geofabrik.de/asia/maldives-latest.osm.pbf' \\\n--name nominatim peterevans/nominatim-k8s:latest\n```\nTail the logs to verify the database has been built and Apache is serving requests:\n```\ndocker logs -f \u003cCONTAINER ID\u003e\n```\nThen point your web browser to [http://localhost:8080/](http://localhost:8080/)\n\n## Kubernetes Deployment\n[Nominatim](https://github.com/openstreetmap/Nominatim)'s data import from the PBF file into PostgreSQL can take over an hour for a single country.\nIf a pod in a deployment fails, waiting over an hour for a new pod to start could lead to loss of service.\n\nThe sample Kubernetes files provide a means of persisting a single database in storage that is used by all pods in the deployment. \nEach pod having its own database is desirable in order to have no single point of failure. \nThe alternative to this solution is to maintain a HA PostgreSQL cluster.\n\nPostgreSQL's data directory is archived in storage and restored on new pods. \nWhile this may be a crude method of copying the database it is much faster than pg_dump/pg_restore and reduces the pod startup time.\n\n#### Explanation\nInitial deployment flow:\n\n1. Create a secret that contains the JSON key of a Google Cloud IAM service account that has read/write permissions to Google Storage.\n2. Deploy the canary deployment.\n3. Wait for the database to be created and its archive uploaded to Google Storage.\n4. Delete the canary deployment.\n5. Deploy the stable track deployment.\n\nTo update the live deployment with new PBF data:\n\n1. Deploy the canary deployment alongside the stable track deployment.\n2. Wait for the database to be created and its archive uploaded to Google Storage.\n3. Delete the canary deployment.\n4. Perform a rolling update on the stable track deployment to create pods using the new database.\n\n#### Creating the secret\n\n```bash\n# Google Cloud project ID and service account details\nPROJECT_ID=my-project\nSA_NAME=my-service-account\nSA_DISPLAY_NAME=\"My Service Account\"\nSA_EMAIL=$SA_NAME@$PROJECT_ID.iam.gserviceaccount.com\nKEY_FILE=service-account-key.json\n\n# Create a new GCP IAM service account\ngcloud iam service-accounts create $SA_NAME --display-name \"$SA_DISPLAY_NAME\"\n\n# Create and download a new key for the service account\ngcloud iam service-accounts keys create $KEY_FILE --iam-account $SA_EMAIL\n\n# Give the service account the \"Storage Object Viewer\" and \"Storage Object Creator\" IAM roles\ngcloud projects add-iam-policy-binding $PROJECT_ID --member serviceAccount:$SA_EMAIL --role roles/storage.objectViewer\ngcloud projects add-iam-policy-binding $PROJECT_ID --member serviceAccount:$SA_EMAIL --role roles/storage.objectCreator\n\n# Create a secret containing the service account key file\nkubectl create secret generic nominatim-storage-secret --from-file=$KEY_FILE\n```  \n\n#### Deployment configuration\nBefore deploying, edit the `env` section of both the canary deployment and stable track deployment.\n\n- `NOMINATIM_MODE` - `CREATE` from PBF data, or `RESTORE` from Google Storage.\n- `NOMINATIM_PBF_URL` - URL to PBF data file. (Optional when `NOMINATIM_MODE=RESTORE`)\n- `NOMINATIM_DATA_LABEL` - A meaningful and **unique** label for the data. e.g. maldives-20161213\n- `NOMINATIM_SA_KEY_PATH` - Path to the JSON service account key. This needs to match the `mountPath` of the volume mounted secret.\n- `NOMINATIM_PROJECT_ID` - Google Cloud project ID.\n- `NOMINATIM_GS_BUCKET` - Google Storage bucket.\n- `NOMINATIM_PG_THREADS` - Number of threads available for PostgreSQL. Defaults to 2.\n\n## License\n\nMIT License - see the [LICENSE](LICENSE) file for details\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpeter-evans%2Fnominatim-k8s","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpeter-evans%2Fnominatim-k8s","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpeter-evans%2Fnominatim-k8s/lists"}