{"id":16443039,"url":"https://github.com/jsilvela/kubecon-webapp-cnpg","last_synced_at":"2026-05-07T18:31:40.129Z","repository":{"id":138512783,"uuid":"490172291","full_name":"jsilvela/kubecon-webapp-cnpg","owner":"jsilvela","description":"Support code for a Virtual Office Hours demo given at the 2022 Kubecon Valencia","archived":false,"fork":false,"pushed_at":"2022-05-23T06:42:23.000Z","size":31,"stargazers_count":2,"open_issues_count":0,"forks_count":2,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-06-04T05:04:24.878Z","etag":null,"topics":["kubernetes","operator","postgresql"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jsilvela.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2022-05-09T07:08:08.000Z","updated_at":"2024-10-29T18:22:43.000Z","dependencies_parsed_at":"2023-03-16T19:15:14.436Z","dependency_job_id":null,"html_url":"https://github.com/jsilvela/kubecon-webapp-cnpg","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/jsilvela/kubecon-webapp-cnpg","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jsilvela%2Fkubecon-webapp-cnpg","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jsilvela%2Fkubecon-webapp-cnpg/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jsilvela%2Fkubecon-webapp-cnpg/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jsilvela%2Fkubecon-webapp-cnpg/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jsilvela","download_url":"https://codeload.github.com/jsilvela/kubecon-webapp-cnpg/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jsilvela%2Fkubecon-webapp-cnpg/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32750436,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-07T02:14:30.463Z","status":"ssl_error","status_checked_at":"2026-05-07T02:14:29.405Z","response_time":62,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["kubernetes","operator","postgresql"],"created_at":"2024-10-11T09:19:19.794Z","updated_at":"2026-05-07T18:31:40.122Z","avatar_url":"https://github.com/jsilvela.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Webapp development with CloudNativePG\n\nThis repo has support code for a Virtual Office Hours demo given at the\n2022 Kubecon Valencia, on 2022-05-18 by me (Jaime).\n\nContains:\n\n- Liquibase config and initial migration\n- Webapp in Go\n- Makefile and cheat-sheet (to aid this poor typist)\n- Dockerfile and K8s YAML's for the webapp\n\nAssumed to be installed on demo machine:\n\n- KinD cluster\n- CloudNativePG operator\n- Liquibase\n\nUses the `cluster-example.yaml` sample in `docs/src/samples`.\n\n## Summary\n\nThe purpose of the demo is to show CloudNativePG is a great tool to develop\nweb applications on dev machines, and opens up possibilities to do all sorts of\nthings before putting in prod.\n\nWe try to show a viable workflow using Liquibase for schema migrations, \nand a webapp written in Go using only the standard\n`net/http`, `database/sql` and `lib/pq` packages.\n\nTwo halves to the demo:\n\n1. \"Average\" or \"old-style\" approach: postgres installed locally, possibly even\n  dockerized. Webapp developed locally, executed natively or dockerized.\n  We ape this by installing a 1-pod cluster using the `cluster-example.yaml` sample\n  with 1 replica instead of 3.\n  We run the webapp outside of KinD and hit `localhost:5432` from it.\n\n2. Better way: we dockerize the webapp, push to the KinD nodes, create a\n  deployment and a service for it. We hit the `cluster-example-rw` service.\n  We show the possibilities that open up.\n\n## Demo and slides\n\n### Slide: Using CloudNativePG from outside Kubernetes\n\nShow diagram for \"Case 2\" from the\n[cnpg docs](https://cloudnative-pg.io/documentation/1.15.0/use_cases/)\n\n### Slide: \"The Old Way\", but using CloudNativePG\n\n#### Ingredient list\n\n1. Basic web application written in Go (aka golang)\n1. Kubernetes cluster (in this case KinD running on macOS)\n1. The CloudNativePG operator installed on KinD\n1. Schema migration tool: Liquibase\n\n#### game plan\n\n1. Create the simplest CloudNativePG cluster\n1. Start with an empty PostgreSQL DB\n1. Get DB connection credentials\n1. Apply migrations with Liquibase - comment on Postgres's **Transactional DDL**\n1. Add port forwarding to expose DB (necessary if running KinD on macOS)\n1. Start the webapp natively\n\n### Slide: Putting your webapp inside Kubernetes\n\nShow first diagram for \"Case 1\" from the\n[cnpg docs](https://cloudnative-pg.io/documentation/1.15.0/use_cases/)\n\nTake opportunity to show the web page for cnpg and the documentation link.\n\n### Slide: Leveraging CloudNativePG - cooking with fire\n\n#### Ingredient list\n\n1. Let’s Dockerize our webapp and load it into our KinD cluster\n1. Make a deployment and a loadBalancer for our webapp\n1. The webapp should now hit the -rw (cluster-example-rw) Service\n\n#### game plan\n\n1. Let’s scale our CloudNativePG cluster to 3 instances\n1. Close the running webapp\n1. Deploy the webapp  (show Dockerfile and K8s YAML while cluster scales up)\n1. Let’s add a watch on the cluster. Let’s put some load on it\n1. Let’s kill the primary!!\n1. (with enough time) - Have a look around in the `cloudnative-pg` repo\n\n## Slide: Reflections and questions\n\nTalk about how once we start leveraging CloudNativePG, we enable developers\nto do experiments that require DBA skills. And we allow them to develop locally\nwith a DB much more similar to what production will look like.\nWhen they deal with prod issues on their app, those developers will have gained\nhands-on experience already.\n\nAnd bridging the gap between dev and prod is one of the tenets of the DevOps\nmovement.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjsilvela%2Fkubecon-webapp-cnpg","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjsilvela%2Fkubecon-webapp-cnpg","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjsilvela%2Fkubecon-webapp-cnpg/lists"}