{"id":15235505,"url":"https://github.com/cloudnative-pg/cnpg-playground","last_synced_at":"2025-04-14T00:25:52.793Z","repository":{"id":257756369,"uuid":"859224572","full_name":"cloudnative-pg/cnpg-playground","owner":"cloudnative-pg","description":"Local Learning Environment for CloudNativePG Using Docker and Kind","archived":false,"fork":false,"pushed_at":"2024-12-31T10:11:13.000Z","size":147,"stargazers_count":23,"open_issues_count":2,"forks_count":6,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-03-27T14:47:26.775Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Shell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/cloudnative-pg.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":"CODEOWNERS","security":null,"support":null,"governance":"GOVERNANCE.md","roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-09-18T09:51:26.000Z","updated_at":"2025-02-24T17:10:22.000Z","dependencies_parsed_at":null,"dependency_job_id":"71393e77-40d1-451e-9176-a21bc1f0a3f8","html_url":"https://github.com/cloudnative-pg/cnpg-playground","commit_stats":null,"previous_names":["cloudnative-pg/cnpg-playground"],"tags_count":0,"template":false,"template_full_name":"cloudnative-pg/cnpg-template","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cloudnative-pg%2Fcnpg-playground","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cloudnative-pg%2Fcnpg-playground/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cloudnative-pg%2Fcnpg-playground/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cloudnative-pg%2Fcnpg-playground/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/cloudnative-pg","download_url":"https://codeload.github.com/cloudnative-pg/cnpg-playground/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248800110,"owners_count":21163404,"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":[],"created_at":"2024-09-29T08:01:45.956Z","updated_at":"2025-04-14T00:25:52.783Z","avatar_url":"https://github.com/cloudnative-pg.png","language":"Shell","funding_links":[],"categories":["Shell","others"],"sub_categories":[],"readme":"[![CloudNativePG](./logo/cloudnativepg.png)](https://cloudnative-pg.io/)\n\n# Local Learning Environment for CloudNativePG\n\nWelcome to **`cnpg-playground`**, a local learning environment designed for\nlearning and experimenting with CloudNativePG using Docker and Kind.\n\n## Prerequisites\n\nEnsure you have the latest available versions of the following tools installed\non a Unix-based system:\n\n- [Docker](https://www.docker.com/)\n- [Git](https://git-scm.com/)\n- [Kubectl](https://kubernetes.io/docs/tasks/tools/)\n- [The `cnpg` plugin for `kubectl`](https://cloudnative-pg.io/documentation/current/kubectl-plugin/)\n- [Kind](https://kind.sigs.k8s.io/)\n\nYou don’t need superuser privileges to run the scripts, but elevated\npermissions may be required to install the prerequisites.\n\n### Additional Tools\n\nFor an improved experience with the CNPG Playground, it’s recommended to\ninstall the following tools:\n\n- **[`curl`](https://curl.se/)**: Command-line tool for data transfer.\n- **[`jq`](https://jqlang.github.io/jq/)**: JSON processor for handling API\n  outputs.\n- **[`stern`](https://github.com/stern/stern)**: Multi-pod log tailing tool.\n- **[`kubectx`](https://github.com/ahmetb/kubectx)**: Kubernetes context\n  switcher.\n\nRecommended `kubectl` plugins:\n\n- **[`view-secret`](https://github.com/elsesiy/kubectl-view-secret)**: Decodes\n  Kubernetes secrets.\n- **[`view-cert`](https://github.com/lmolas/kubectl-view-cert)**: Inspects TLS\n  certificates.\n\nThese tools streamline working with the CNPG Playground.\n\n## Local Environment Overview\n\nThis environment emulates a two-region infrastructure (EU and US), with each\nregion containing:\n\n- An object storage service powered by [MinIO](https://min.io/) containers\n- A Kubernetes cluster, deployed using [Kind](https://kind.sigs.k8s.io/),\n  consisting of:\n\n    - One control plane node\n    - One node for infrastructure components\n    - One node for applications\n    - Three nodes dedicated to PostgreSQL\n\nThe architecture is illustrated in the diagram below:\n\n![Local Environment Architecture](images/cnpg-playground-architecture.png)\n\n## Setting Up the Learning Environment\n\nTo set up the environment, simply run the following script:\n\n```bash\n./scripts/setup.sh\n```\n\n## Connecting to the Kubernetes Clusters\n\nTo configure and interact with both Kubernetes clusters during the learning\nprocess, you will need to connect to them.\n\nThe **setup** script provides detailed instructions for accessing the clusters.\nIf you need to view the connection details again after the setup, you can\nretrieve them by running:\n\n```bash\n./scripts/info.sh\n```\n\n## Inspecting Nodes in a Kubernetes Cluster\n\nTo inspect the nodes in a Kubernetes cluster, you can use the following\ncommand:\n\n```bash\nkubectl get nodes\n```\n\nFor example, when connected to the `k8s-eu` cluster, this command will display\noutput similar to:\n\n```console\nNAME                   STATUS   ROLES           AGE     VERSION\nk8s-eu-control-plane   Ready    control-plane   10m     v1.32.0\nk8s-eu-worker          Ready    infra           9m58s   v1.32.0\nk8s-eu-worker2         Ready    app             9m58s   v1.32.0\nk8s-eu-worker3         Ready    postgres        9m58s   v1.32.0\nk8s-eu-worker4         Ready    postgres        9m58s   v1.32.0\nk8s-eu-worker5         Ready    postgres        9m58s   v1.32.0\n```\n\nIn this example:\n- The control plane node (`k8s-eu-control-plane`) manages the cluster.\n- Worker nodes have different roles, such as `infra` for infrastructure, `app`\n  for application workloads, and `postgres` for PostgreSQL databases. Each node\n  runs Kubernetes version `v1.32.0`.\n\n## Demonstration with CNPG Playground\n\nThe **CNPG Playground** provides an excellent environment for demonstrating the\n**CloudNativePG operator** and the broader concept of running PostgreSQL on\nKubernetes. You can easily create your own scenarios and customized demo\nenvironments.\n\nTo get you started, we’ve designed a demo scenario that highlights the\n**distributed topology** feature. This scenario walks you through setting up a\n**PostgreSQL cluster distributed across two distinct regions** within the\nplayground.\n\nFor detailed instructions and resources, visit the\n[demo folder](./demo/README.md).\n\n## Installing CloudNativePG on the Control Plane\n\nIf you plan to use the CNPG Playground without the demo mentioned earlier,\nyou’ll need to install CloudNativePG manually.\n\nTo install the latest stable version of the CloudNativePG operator on the\ncontrol plane nodes in both Kubernetes clusters, execute the following\ncommands:\n\n```bash\nfor region in eu us; do\n   kubectl cnpg install generate --control-plane | \\\n      kubectl --context kind-k8s-${region} apply -f - --server-side\n\n   kubectl --context kind-k8s-${region} rollout status deployment \\\n      -n cnpg-system cnpg-controller-manager\ndone\n```\n\nThese commands will deploy the CloudNativePG operator with server-side apply on\nboth the `kind-k8s-eu` and `kind-k8s-us` clusters.\n\nEnsure that you have the latest version of the `cnpg` plugin installed on your\nlocal machine.\n\n## Cleaning up the Learning Environment\n\nWhen you're ready to clean up and remove all resources from the learning\nenvironment, run the following script to tear down the containers and\nassociated resources:\n\n```bash\n./scripts/teardown.sh\n```\n\nThis will safely destroy all running containers and return your environment to\nits initial state.\n\n## Nix Flakes\n\nDo you use Nix flakes? If you do, this package have a configured\ndev shell that can be used with:\n\n```\nnix develop .\n```\n\n## Using Linux or WSL2\n\nYou may need:\n\n```\nsudo sysctl fs.inotify.max_user_watches=524288\nsudo sysctl fs.inotify.max_user_instances=512\n```\n\nMore information in the [relative ticket comment](https://github.com/kubernetes-sigs/kind/issues/3423#issuecomment-1872074526).\n\n## Using Rancher Desktop\n\nYou may need to follow the instructions [in the Rancher Desktop\nGuide](https://docs.rancherdesktop.io/how-to-guides/increasing-open-file-limit/)\nto increase the open file limit.\n\n```\nprovision:\n- mode: system\n  script: |\n    #!/bin/sh\n    cat \u003c\u003c'EOF' \u003e /etc/security/limits.d/rancher-desktop.conf\n    * soft     nofile         82920\n    * hard     nofile         82920\n    EOF\n    sysctl -w vm.max_map_count=262144\n    sysctl fs.inotify.max_user_watches=524288\n    sysctl fs.inotify.max_user_instances=512\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcloudnative-pg%2Fcnpg-playground","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcloudnative-pg%2Fcnpg-playground","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcloudnative-pg%2Fcnpg-playground/lists"}