{"id":19049002,"url":"https://github.com/tcdowney/sinatra-k8s-sample","last_synced_at":"2025-04-24T01:02:53.080Z","repository":{"id":150794875,"uuid":"219336358","full_name":"tcdowney/sinatra-k8s-sample","owner":"tcdowney","description":"A basic stateless Ruby app for experimenting with Kubernetes","archived":false,"fork":false,"pushed_at":"2022-12-01T01:52:45.000Z","size":107,"stargazers_count":4,"open_issues_count":2,"forks_count":3,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-24T01:02:21.710Z","etag":null,"topics":["kubernetes","ruby","sinatra"],"latest_commit_sha":null,"homepage":null,"language":"Ruby","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/tcdowney.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2019-11-03T17:11:50.000Z","updated_at":"2024-09-21T02:11:22.000Z","dependencies_parsed_at":"2023-05-06T06:39:37.737Z","dependency_job_id":null,"html_url":"https://github.com/tcdowney/sinatra-k8s-sample","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/tcdowney%2Fsinatra-k8s-sample","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tcdowney%2Fsinatra-k8s-sample/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tcdowney%2Fsinatra-k8s-sample/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tcdowney%2Fsinatra-k8s-sample/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tcdowney","download_url":"https://codeload.github.com/tcdowney/sinatra-k8s-sample/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250540948,"owners_count":21447427,"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":["kubernetes","ruby","sinatra"],"created_at":"2024-11-08T23:09:22.996Z","updated_at":"2025-04-24T01:02:53.073Z","avatar_url":"https://github.com/tcdowney.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# sinatra-k8s-sample\n\n[![Docker Pulls](https://img.shields.io/docker/pulls/downey/sinatra-k8s-sample.svg)](https://cloud.docker.com/u/downey/repository/docker/downey/sinatra-k8s-sample)\n\nA basic stateless Ruby app for experimenting with Kubernetes\n\n![Belafonte Example](assets/belafonte.png)\n\n---\n\nThis repo contains the sample code of a basic Sinatra app called [Belafonte](https://en.wikipedia.org/wiki/The_Life_Aquatic_with_Steve_Zissou) that can be deployed to Kubernetes for learning and exploration.\n\nIt was written to be an example application for my blog post on [Cloud Native Buildpacks and kapp in Kubernetes](https://dev.to/downey/simplify-kubernetes-app-deployments-with-cloud-native-buildpacks-and-kapp-339b).\n\nThe app prints out some basic information about the `pod` it is running on and demonstrates inter-pod communication by fetching a UUID from another microservice that spits out UUIDs ([httpbin](https://github.com/postmanlabs/httpbin)).\n\n## Building the Image\n\nI use the [Cloud Native Buildpacks](https://buildpacks.io/) [`pack`](https://github.com/buildpack/pack) CLI and heroku Ruby buildpack to build and publish the container image for this app.\n```bash\npack build downey/sinatra-k8s-sample --builder heroku/buildpacks --buildpack heroku/ruby --publish\n```\n\nIf you want to publish to your own image repository, replace the `downey/sinatra-k8s-sample` portion above.\n\n## Deploying to Kubernetes\n\nI have been deploying to a Digital Ocean hosted Kubernetes cluster that has the following installed:\n\n* [kubernetes/ingress-nginx](https://github.com/kubernetes/ingress-nginxhttps://github.com/kubernetes/ingress-nginx) for workload Ingress\n    * https://kubernetes.github.io/ingress-nginx/deploy/#gce-gke (followed the GKE steps for Digital Ocean)\n* [cert-manager](https://github.com/jetstack/cert-manager) for automated provisioning of lets-encrypt TLS certs\n    * https://docs.cert-manager.io/en/latest/getting-started/install/kubernetes.html\n* A lets-encrypt `ClusterIssuer` for `cert-manager`\n    ```yaml\n    apiVersion: cert-manager.io/v1alpha2\n    kind: ClusterIssuer\n    metadata:\n      name: letsencrypt-prod\n      namespace: cert-manager\n    spec:\n      acme:\n        email: email@example.com # change to your email address\n        http01: {}\n        privateKeySecretRef:\n          name: letsencrypt-prod\n        server: https://acme-v02.api.letsencrypt.org/directory\n        solvers:\n        - http01:\n            ingress:\n              class: nginx\n    ```\n    \nTo deploy the app itself I have been using the [`kapp`](https://get-kapp.io/) CLI.\n\n```bash\nkapp deploy -a belafonte -f deploy\n```\n\nThis will deploy everything in the `deploy` directory and `kapp` will ensure resources are applied in a reasonable order (e.g. namespaces and CRDs first) and it will wait until the status checks succeed for resources before continuing.\n\nAfter that finished you can run `kapp inspect -a belafonte` and you should see all of the resources that were deployed. Example:\n\n```bash\nResources in app 'belafonte'\n\nNamespace  Name                             Kind                Owner    Conds.  Rs  Ri  Age\n(cluster)  belafonte                        Namespace           kapp     -       ok  -   33m\nbelafonte  belafonte                        Certificate         cluster  1/1 t   ok  -   33m\n^          belafonte                        Deployment          kapp     2/2 t   ok  -   33m\n^          belafonte                        Endpoints           cluster  -       ok  -   33m\n^          belafonte                        Ingress             kapp     -       ok  -   33m\n^          belafonte                        Service             kapp     -       ok  -   33m\n^          belafonte-1918113368             CertificateRequest  cluster  1/1 t   ok  -   33m\n^          belafonte-1918113368-3886681398  Order               cluster  -       ok  -   33m\n^          belafonte-694ffdfdd4             ReplicaSet          cluster  -       ok  -   33m\n^          belafonte-7c874788d7             ReplicaSet          cluster  -       ok  -   11s\n^          belafonte-7c874788d7-lm6hj       Pod                 cluster  4/4 t   ok  -   11s\n^          httpbin                          Deployment          kapp     2/2 t   ok  -   33m\n^          httpbin                          Endpoints           cluster  -       ok  -   33m\n^          httpbin                          Service             kapp     -       ok  -   33m\n^          httpbin-85b9b4c565               ReplicaSet          cluster  -       ok  -   33m\n^          httpbin-85b9b4c565-x2nmb         Pod                 cluster  4/4 t   ok  -   33m\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftcdowney%2Fsinatra-k8s-sample","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftcdowney%2Fsinatra-k8s-sample","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftcdowney%2Fsinatra-k8s-sample/lists"}