{"id":19150158,"url":"https://github.com/carvel-dev/guestbook-example-on-kubernetes","last_synced_at":"2025-05-07T05:22:25.230Z","repository":{"id":49959124,"uuid":"183107901","full_name":"carvel-dev/guestbook-example-on-kubernetes","owner":"carvel-dev","description":"K8s guestbook example deployed with k14s tools","archived":false,"fork":false,"pushed_at":"2023-01-23T18:25:30.000Z","size":57,"stargazers_count":3,"open_issues_count":1,"forks_count":5,"subscribers_count":14,"default_branch":"develop","last_synced_at":"2025-04-19T18:33:47.915Z","etag":null,"topics":["carvel","k8s","kubernetes","yaml","ytt"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","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/carvel-dev.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":"SECURITY.md","support":null}},"created_at":"2019-04-23T22:59:54.000Z","updated_at":"2023-04-13T01:57:00.000Z","dependencies_parsed_at":"2023-02-13T02:02:06.666Z","dependency_job_id":null,"html_url":"https://github.com/carvel-dev/guestbook-example-on-kubernetes","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/carvel-dev%2Fguestbook-example-on-kubernetes","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/carvel-dev%2Fguestbook-example-on-kubernetes/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/carvel-dev%2Fguestbook-example-on-kubernetes/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/carvel-dev%2Fguestbook-example-on-kubernetes/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/carvel-dev","download_url":"https://codeload.github.com/carvel-dev/guestbook-example-on-kubernetes/tar.gz/refs/heads/develop","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252819051,"owners_count":21808964,"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":["carvel","k8s","kubernetes","yaml","ytt"],"created_at":"2024-11-09T08:10:55.073Z","updated_at":"2025-05-07T05:22:25.211Z","avatar_url":"https://github.com/carvel-dev.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"![logo](logos/CarvelLogo.png)\n\n# Modified Guestbook k8s Example\n\nGuestbook k8s example is meant to showcase how k14s tools work together with a realistic application.\n\nThis example is based on [guestbook example from kubernetes/examples](https://github.com/kubernetes/examples/blob/d94a4484e1f73a277df25b13153f54cc60773eb5/guestbook/all-in-one/guestbook-all-in-one.yaml). Changes were done to remove unused functionality.\n\n## Install k14s Tools\n\nHead over to [k14s.io](https://k14s.io/) for installation instructions.\n\n## Deploy\n\n```bash\ngit clone https://github.com/k14s/k8s-guestbook-example\ncd k8s-guestbook-example/\n```\n\nUsing k14s tools, deploy via:\n\n```bash\nkapp deploy -a guestbook -f \u003c(ytt -f config/ | kbld -f-) --diff-changes\n```\n\nAbove command does the following:\n\n- generate configuration from `config/` via [ytt](https://get-ytt.io)\n  - no network access\n  - see [Directory Layout](#directory-layout) below for details\n- build images (with Docker) from source directories (`frontend/` and `redis-slave/`) via [kbld](https://get-kbld.io)\n  - talks to Docker via Docker CLI and directly to registries\n- deploys configuration to k8s cluster via [kapp](https://get-kapp.io)\n  - talks to k8s API server\n\nIf you are using Minikube as your deployment target, run `eval $(minikube docker-env)` beforehand so that kbld can successfully shell out to Docker CLI. By default images are kept locally (not pushed).\n\nIf you are using remote cluster as your deployment target you will have to provide registry destination where images could be pushed and be accessible to the cluster. You will still need to have access to Docker CLI and be logged in so that pushes are successful.\n\n```bash\ndocker login ...\nkapp deploy -a guestbook -f \u003c(ytt -f config/ --data-value push_images=true --data-value push_images_repo=docker.io/dkalinin | kbld -f-) -c\n```\n\n(Even if you are deploying to remote cluster, Minikube could be used for its Docker daemon; just make sure that your `~/.kube/config` points to your remote cluster.)\n\n### Deploying to Online Playground\n\nIf you want to use online playground instead of your own cluster, head over to [Katacoda Kubernetes Playground](https://www.katacoda.com/courses/kubernetes/playground). You will have to set `--data-value katacoda=true` flag when using ytt and untaint master node, before proceeding with the above command. See comments in [`config/katacoda.yml`](config/katacoda.yml) for additional details.\n\n```bash\nkubectl taint nodes master node-role.kubernetes.io/master-\n```\n\n(Command does end with a hyphen.)\n\n### Viewing Frontend App\n\nOnce deployed successfully, you can access frontend service at `127.0.0.1:8080` in your browser via `kubectl port-forward` command:\n\n```bash\nkubectl port-forward svc/frontend 8080:80\n```\n\nYou will have to restart port forward command after making changes as pods are recreated. Alternatively consider using [k14s' kwt tool](https://github.com/k14s/kwt) which exposes cluser IP subnets and cluster DNS to your machine and does not require any restarts:\n\n```bash\nsudo -E kwt net start\n```\n\nand open [`http://frontend.default.svc.cluster.local/`](http://frontend.default.svc.cluster.local/).\n\n### Making Changes\n\nOnce deployed, feel free to make changes to the app, and re-run same command.\n\nFor example, change [`frontend/guestbook.php`](frontend/guestbook.php):\n\n```diff\n-$bg = getenv('GUESTBOOK_BG');\n+$bg = 'yellow';\n```\n\nor change [`frontend/frontend.yml`](frontend/frontend.yml):\n\n```diff\n-  GUESTBOOK_BG: \"#eee\"\n+  GUESTBOOK_BG: \"yellow\"\n```\n\nand run exactly same command as before:\n\n```bash\nkapp deploy -a guestbook -f \u003c(ytt -f config/ ...any opts... | kbld -f -) --diff-changes\n```\n\nNote that during second deploy each tool will try to be as optimal as possible based on changes made:\n\n- kbld (via Docker) will only rebuild affected layers/images\n- kapp will only deploy resources that changed or were affected by the change\n\n## Directory Layout\n\n- [`frontend/`](frontend/): frontend app (Apache2 + PHP + Redis client)\n- [`redis-slave/`](redis-slave/): Dockerfile to configure Redis as a slave\n- [`config/build.yml`](config/build.yml): configuration for kbld to manage images\n- [`config/frontend.yml`](config/frontend.yml): frontend configuration\n- [`config/frontend-scale.yml`](config/frontend-scale.yml): separate configuration to scale up frontend\n- [`config/redis-master.yml`](config/redis-master.yml): configuration to deploy Redis in master mode\n- [`config/redis-slave.yml`](config/redis-slave.yml): configuration to deploy Redis as a slave\n- [`config/katacoda.yml`](config/katacoda.yml): ytt overlays to customize deployment for Katacoda Playground\n- [`config/values.yml`](config/values.yml): global configuration knobs\n\n## Highlighted Features\n\nHere are some features of k14s tools as used in this example:\n\n### ytt\n\n- several configuration files use `data.values.redis_port` value from [`config/values.yml`](config/values.yml)\n  - this feature is useful for organizing shared configuration in one place\n- separate overlay configuration that customizes another resource\n  - example: [`config/frontend-scale.yml`](config/frontend-scale.yml)\n\n### kbld\n\n- easy to convert source code for `frontend` application and `redis-slave` into container images\n  - source: [`config/build.yml`](config/build.yml)\n- swap one image for another via `ImageOverrides` configuration\n\n### kapp\n\n- all configuration resources are tagged consistently, hence could be tracked\n  - see `kapp inspect -a guestbook` and `kapp inspect -a guestbook --tree`\n- label selectors on Service and Deployment resources are scoped to this application automatically\n  - example: [`config/frontend.yml`](config/frontend.yml) only specifies `frontend: \"\"` label, and kapp augments it with an application specific label\n- `kapp.k14s.io/update-strategy: fallback-on-replace` annotation on Deployment resources allows to easily change any part of Deployment\n  - by default if update is allowed by k8s, no forceful action will be taken\n  - example: `frontend` Deployment\n- `kapp.k14s.io/versioned: \"\"` annotation on ConfigMap resource allows us to change ConfigMap data and be certain that related Deployment resources will be updated with new values\n  - example: `frontend` Deployment picks up env variables from `frontend-config` ConfigMap\n- all pod logs from this application could be found via `kapp logs -f -a guestbook`\n\n### Join the Community and Make Carvel Better\nCarvel is better because of our contributors and maintainers. It is because of you that we can bring great software to the community.\nPlease join us during our online community meetings. Details can be found on our [Carvel website](https://carvel.dev/community/).\n\nYou can chat with us on Kubernetes Slack in the #carvel channel and follow us on Twitter at @carvel_dev.\n\nCheck out which organizations are using and contributing to Carvel: [Adopter's list](https://github.com/vmware-tanzu/carvel/blob/master/ADOPTERS.md)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcarvel-dev%2Fguestbook-example-on-kubernetes","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcarvel-dev%2Fguestbook-example-on-kubernetes","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcarvel-dev%2Fguestbook-example-on-kubernetes/lists"}