{"id":24558114,"url":"https://github.com/rse/k8s-sample","last_synced_at":"2025-04-19T09:58:52.071Z","repository":{"id":37958143,"uuid":"211950546","full_name":"rse/k8s-sample","owner":"rse","description":"Kubernetes (K8S) Sample Application","archived":false,"fork":false,"pushed_at":"2024-09-16T11:27:04.000Z","size":681,"stargazers_count":4,"open_issues_count":0,"forks_count":5,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-04-15T21:55:48.035Z","etag":null,"topics":["docker","kubernetes","postgresql","sample","sqlite"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","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/rse.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}},"created_at":"2019-09-30T20:28:16.000Z","updated_at":"2024-09-16T11:27:08.000Z","dependencies_parsed_at":"2024-09-16T13:08:05.600Z","dependency_job_id":null,"html_url":"https://github.com/rse/k8s-sample","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rse%2Fk8s-sample","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rse%2Fk8s-sample/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rse%2Fk8s-sample/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rse%2Fk8s-sample/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rse","download_url":"https://codeload.github.com/rse/k8s-sample/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249670023,"owners_count":21308669,"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":["docker","kubernetes","postgresql","sample","sqlite"],"created_at":"2025-01-23T05:47:25.537Z","updated_at":"2025-04-19T09:58:52.053Z","avatar_url":"https://github.com/rse.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"\nk8s-sample \u0026mdash; Kubernetes Sample Application\n================================================\n\nThis is a sample application to showcase the software deployment on\nthe container run-time environments [Docker](https://www.docker.com/)\nand [Kubernetes (K8S)](https://kubernetes.io/). The\nsample application uses a Rich-Client architecture, comprised of an\n[HTML5](https://en.wikipedia.org/wiki/HTML5) Single-Page Application\n(SPA) client and a [Node.js](https://nodejs.org/) server and runs\nunder an arbitrary URL prefix. To showcase important run-time aspects,\nthe application shows detailed environment information, persists data\n(both locally via [SQLite](https://www.sqlite.org/) and remotely\nvia [PostgreSQL](https://www.postgresql.org/)) and allows one to\ncontrol the application process. The application is packaged into a\n[Docker](https://www.docker.com/) container and then this container\nis deployed onto a [Docker](https://www.docker.com/) run-time\nenvironment via [Docker-Compose](https://docs.docker.com/compose/) and\nonto a [Kubernetes](https://kubernetes.io/) run-time environment via\n[Helm](https://helm.sh/).\n\nThis project provides you the entire life-cycle: connecting and\nbootstrapping the run-time environments, building and running the\napplication locally, building the application into a container\nand deploying the container onto the run-time environments. On\nthe client side all this just needs a plain Linux/amd64 system\n(e.g. [use Windows Subsystem for Linux (WSL) under Windows 10](https://github.com/rse/unix-under-windows))\nwith the [git(1)](https://git-scm.com/) and [curl(1)](https://curl.haxx.se/) programs installed. \nEverything is performed remotely, does not need any local privileges (including the local\ndownloaded client programs) and does not change the local Linux system\nat all.\n\nSneak Preview\n-------------\n\n![k8s-sample screenshot](screenshot.png)\n\nQuick Test-Drive\n----------------\n\nFor standard contexts:\n\n```sh\n$ git clone https://github.com/rse/k8s-sample/                         # clone repository\n$ cd k8s-sample                                                        # enter working copy\n$ (cd 1-env-util \u0026\u0026 make)                                              # etablish environment utility\n$ bash   2-env-setup/1-setup-std.bash \u003ckubeconfig-file\u003e [\u003cdocker-url\u003e] # setup environment\n$ source 2-env-setup/2-env.bash                                        # attach environment\n$ source 2-env-setup/3-root.bash                                       # create cluster admin\n$ source 2-env-setup/4-namespace.bash                                  # create application namespace\n$ cd 6-run-kubernetes                                                  # enter Kubernetes deployment procedure\n$ make install [DB_ENABLED=true]                                       # execute Kubernetes deployment procedure\n$ open http[s]://\u003cingress-endpoint\u003e/k8s-sample/                        # open deployed application\n```\n\nFor special msg Project Server (PS) contexts\n(where `\u003chostname\u003e` is the FQDN of the msg Project Server instance\nwhere you have SSH access to):\n\n```sh\n$ git clone https://github.com/rse/k8s-sample/     # clone repository\n$ cd k8s-sample                                    # enter working copy\n$ (cd 1-env-util \u0026\u0026 make)                          # etablish environment utility\n$ bash   2-env-setup/1-setup-ps.bash \u003chostname\u003e    # setup environment\n$ source 2-env-setup/2-env.bash                    # attach environment\n$ source 2-env-setup/3-root.bash                   # create cluster admin\n$ source 2-env-setup/4-namespace.bash              # create application namespace\n$ cd 6-run-kubernetes                          # enter Kubernetes deployment procedure\n$ make install [DB_ENABLED=true]                   # execute Kubernetes deployment procedure\n$ open http[s]://\u003chostname\u003e/ase-k3s/k8s-sample/    # open deployed application\n```\n\nShort Background\n----------------\n\nOn the application development side, the Docker and Kubernetes worlds\nare primarily driven by four command-line client programs this\n**k8s-sample** is using, too:\n\n|            | low-level\u003cbr/\u003e(commands) | high-level\u003cbr/\u003e(stacks) |\n|----------- | ------------------------ | ----------------------- |\n| Docker     | `docker`                 | `docker-compose`        |\n| Kubernetes | `kubectl`                | `helm`                  |\n\nThe Parts In Detail\n-------------------\n\nThe **k8s-sample** consists of the following parts:\n\n- **Kubernetes Environment Utility**: `1-env-util`\u003cbr/\u003e\n  Here you can find a procedure for locally installing the companion\n  [**k8s-util(1)**](https://github.com/rse/k8s-util) utility. It ensures\n  that the command-line clients for accessing a Docker and Kubernetes\n  run-time environment are available and helps managing the\n  run-time access credentials in the part `2-env-setup`:\n\n    ```sh\n    $ (cd 1-env-util \u0026\u0026 make)\n    ```\n\n- **Kubernetes Environment Setup**: `2-env-setup`\u003cbr/\u003e\n  Here you can find the scripts for establishing and attaching to the\n  Kubernetes run-time environment.\n\n  For standard contexts (arbitrary locally pre-existing Docker and\n  remotely pre-existing Kubernetes installation), use the following\n  command (where `\u003ckubeconfig\u003e` is the Kubernetes configuration of the\n  admin account as manually fetched from the Kubernetes installation):\n\n    ```sh\n    $ bash 2-env-setup/1-setup-std.bash \u003ckubeconfig\u003e [\u003cdocker-url\u003e]\n    ```\n\n  For msg Project Server (PS) contexts (where `\u003chostname\u003e` is the\n  hostname of the msg Project Server instance), instead the following\n  command should be used (which installs the Rancher K3S software stack\n  and uses both Docker and Kubernetes remotely):\n\n    ```sh\n    $ bash 2-env-setup/1-setup-ps.bash \u003chostname\u003e\n    ```\n\n  In case you have trouble with the TLS connectivity to your Kubernetes\n  cluster (usually in case of self-signed server certificates or a\n  certificate of an unknown CA), you can force Kubernetes to accept the\n  situation with:\n\n    ```sh\n    $ kubectl config get-clusters\n    $ kubectl config set clusters.\u003ccluster-name\u003e.insecure-skip-tls-verify true\n    ```\n\n  Now we import the setup results into our shell environment with:\n\n    ```sh\n    $ source 2-env-setup/2-env.bash\n    ```\n\n  Then we create a cluster admin service account `root`, because\n  applications like the official Kubernetes Dashboard allow\n  authentication of \"on-cluster\" accounts only (instead of \"off-cluster\"\n  account like the initial admin account):\n\n    ```sh\n    $ source 2-env-setup/3-root.bash\n    ```\n\n  Finally, we create a dedicated namespace (and corresponding namespace\n  service account) `k8s-sample` for our application:\n\n    ```sh\n    $ source 2-env-setup/4-namespace.bash\n    ```\n\n- **Application Source Code**: `3-app-source`\u003cbr/\u003e\n  Here you can find the sources of the **k8s-sample** HTML5 SPA client and\n  the corresponding Node.js server. Only used by you in case you want\n  to understand and locally test-drive the application itself.\n\n  ```sh\n  $ (cd 3-app-source/fe \u0026\u0026 make build)\n  $ (cd 3-app-source/be \u0026\u0026 make build start)\n  ```\n\n  After this you can access the application under `https://127.0.0.1:9090/`.\n  You can stop the application with `CTRL+C`.\n\n- **Application Container Build Procedure**: `4-app-container`\u003cbr/\u003e\n  Here you can find the procedure for building and packaging the\n  **k8s-sample** application as a Docker/OCI container for use in both\n  step 5 and 6. Only used by you in case you want to understand the\n  Docker/OCI container packaging or build and push the container to\n  your container image repository/registry (e.g. Docker Hub).\n\n  ```sh\n  $ (cd 4-app-container \u0026\u0026 make build push)\n  ```\n\n- **Docker Deployment Procedure**: `5-run-docker`\u003cbr/\u003e\n  Here you can find the procedure for installing the **k8s-sample**\n  container (from step 4) onto a Docker run-time environment via the\n  clients docker(1) and docker-compose(1).\n\n  ```sh\n  $ (cd 5-run-docker \u0026\u0026 make install [DATABASE=pgsql])\n  ```\n\n  After this you can access the application under `http://\u003chostname\u003e:9090/`.\n  You can uninstall the application again with:\n\n  ```sh\n  $ (cd 5-run-docker \u0026\u0026 make uninstall)\n  ```\n\n- **Kubernetes Deployment Procedure**: `6-run-kubernetes`\u003cbr/\u003e\n  Here you can find the procedure for installing the **k8s-sample**\n  container (from step 4) onto a Kubernetes run-time environment via the\n  clients kubectl(1) and helm(1).\n\n  ```sh\n  $ (cd 6-run-kubernetes \u0026\u0026 make install [DB_ENABLED=true])\n  ```\n\n  After this you can access the application under `http://\u003cendpoint\u003e/k8s-sample/`\n  where `\u003cendpoint\u003e` is your Kubernetes ingress endpoint. For a msg Project Server\n  with the K3S Kubernetes stack, the URL is `http://\u003chostname\u003e/ase-k3s/k8s-sample/`\n  where `\u003chostname\u003e` is your msg Project Server instance.\n  You can uninstall the application again with:\n\n  ```sh\n  $ (cd 6-run-kubernetes \u0026\u0026 make uninstall)\n  ```\n\nLicense\n-------\n\nCopyright \u0026copy; 2019-2020 Dr. Ralf S. Engelschall (http://engelschall.com/)\n\nPermission is hereby granted, free of charge, to any person obtaining\na copy of this software and associated documentation files (the\n\"Software\"), to deal in the Software without restriction, including\nwithout limitation the rights to use, copy, modify, merge, publish,\ndistribute, sublicense, and/or sell copies of the Software, and to\npermit persons to whom the Software is furnished to do so, subject to\nthe following conditions:\n\nThe above copyright notice and this permission notice shall be included\nin all copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND,\nEXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\nMERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.\nIN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY\nCLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,\nTORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE\nSOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frse%2Fk8s-sample","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frse%2Fk8s-sample","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frse%2Fk8s-sample/lists"}