{"id":18972849,"url":"https://github.com/piotrostr/pong","last_synced_at":"2026-04-12T13:44:01.531Z","repository":{"id":78719811,"uuid":"494460172","full_name":"piotrostr/pong","owner":"piotrostr","description":"Rundown of the common ways of exposing a Kubernetes cluster to external traffic.","archived":false,"fork":false,"pushed_at":"2022-05-22T10:28:17.000Z","size":14,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-06-02T12:17:52.714Z","etag":null,"topics":["containers","devops","docker","gke","go","ingress","k8s"],"latest_commit_sha":null,"homepage":"","language":"Go","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/piotrostr.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}},"created_at":"2022-05-20T12:44:07.000Z","updated_at":"2022-05-28T19:50:48.000Z","dependencies_parsed_at":"2023-04-23T18:01:23.706Z","dependency_job_id":null,"html_url":"https://github.com/piotrostr/pong","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/piotrostr/pong","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/piotrostr%2Fpong","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/piotrostr%2Fpong/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/piotrostr%2Fpong/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/piotrostr%2Fpong/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/piotrostr","download_url":"https://codeload.github.com/piotrostr/pong/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/piotrostr%2Fpong/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":260897737,"owners_count":23079222,"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":["containers","devops","docker","gke","go","ingress","k8s"],"created_at":"2024-11-08T15:10:06.233Z","updated_at":"2026-04-12T13:43:56.508Z","avatar_url":"https://github.com/piotrostr.png","language":"Go","readme":"# pong server\n\nLet's assume there is an API ready to be deployed and one decides to\nuse the industry leading orchestrating software - Kubernetes.\n\nOriginating from Google, kubernetes in greek means helmsman or pilot and it\nserves exactly that purpose - commanding the fleet of, in this case,\ncontainers.\n\nThe core concepts are easy to grasp, but since running the \"real\" or more\nformally, the production cluster, requires a range of components, most of the\ntime one gets started with the development environment alternatives, like\n`minikube`, `microk8s` or the built-in (enableable) Docker Desktop Kubernetes engine.\n\nEven though it is very logical at first and it's easy to get started, it might\nbe a bit difficult to enable access to the cluster without port forwarding.\nPersonally, I am not a big fan of port forwarding and thus even developing\nlocal applications, I stand by developing them in a way that makes them ready\nto be deployed into production without any breaking changes.\n\nGenerally, there is a number of ways of getting traffic into the kubernetes\ncluster, mostly depending on where it is to be deployed.\n\n1. Locally using minikube or k3s with port forwarding\n   \n   ```sh\n   kubectl create deployment [deployment] --image=piotrostr/pong\n   kubectl expose deployment [deployment]\n   ```\n\n   It can then be forwarded a port from the node:\n\n   ```sh\n   kubectl port-forward service/[deployment] [port-host]:[port-container]\n   ```\n\n   This could potentially be useful for debugging a single deployment.\n\n   There is also an option to use the `kubectl proxy` and interact directly\n   with the local kubernetes api, but it is kind of hassleful compared to the\n   other options below.\n\n2. Using Docker Desktop Kubernetes provider (resources: \n   [`manifest-docker.yaml`](https://github.com/piotrostr/pong/blob/master/manifest-docker.yaml))\n\n   This is a nice one, as since docker-desktop uses vpnkit to expose any load\n   balancers and forward traffic into the cluster.\n   \n   The manifest here only includes a load balancer service and the deployment\n   itself, no ingress included.\n   \n   Simply\n   \n   ```sh\n   kubectl apply -f manifest-docker.yaml\n   ```\n\n   makes the application ready to be `curl`'ed.\n\n   I would say this is the go-to for debugging simple applications, working like \n   a charm with `skaffold dev`. \n   \n   More on skaffold [here](https://github.com/GoogleContainerTools/skaffold).\n\n3. On Google Kubernetes Engine (resources: \n   [`manifest-gke.yaml`](https://github.com/piotrostr/pong/blob/master/manifest-gke.yaml))\n\n   Note: requires the `gcloud` to be configured with the right project and GKE\n   enabled.\n\n   After including the ingress resource in the the manifest can be used to\n   provision a cluster on GCP cloud quite seamlessly.\n\n   ```yaml\n   apiVersion: networking.k8s.io/v1\n   kind: Ingress\n   metadata:\n     name: minimal-ingress\n   annotations:\n     ingress.kubernetes.io/ssl-redirect: 'false'\n   spec:\n   rules:\n     - http:\n         paths:\n           - path: /\n             pathType: Exact\n             backend:\n               service:\n                 name: pong-api\n                 port:\n                   number: 80\n   ```\n\n   Configure the `kubectl` to use the gcloud context:\n\n   ```sh\n   gcloud container clusters create-auto [cluster-name]\n   gcloud container clusters get-credentials [cluster-name]\n   ```\n\n   After applying the yaml, the load balancer will be provisioned from GCP and will\n   forward any traffic into the cluster.\n\n4. Using the [nginx](https://kubernetes.github.io/ingress-nginx/) ingress\n   (resources: [`manifest-nginx.yaml`](https://github.com/piotrostr/pong/blob/master/manifest-nginx.yaml))\n\n   Install it with\n\n   ```sh\n   helm upgrade --install ingress-nginx ingress-nginx \\\n     --repo https://kubernetes.github.io/ingress-nginx \\\n     --namespace ingress-nginx --create-namespace\n   ```\n\n   By including the same ingress resource as in the _3._ and adding\n   `ingressClassName: nginx` under `spec` (in order to define which controller to\n   use) it allows external traffic into the cluster and deployments without GKE or\n   EKS (Elastic Kubernetes Service from AWS). This manifest can deployed on a\n   single node cluster on an virtual machine quite easily, enabling one to benefit\n   from the Kubernetes awesome features like auto-scaling and auto-healing while\n   not being forced to use the AWS/GCP load balancing services and cluster costs,\n   which can pile up for small applications.\n\n   The nginx ingress is load balancing, meaning `curl` is distributed between the five pods \n   (change `replicas` in the `manifest-nginx.yaml` to modify the pod number).\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpiotrostr%2Fpong","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpiotrostr%2Fpong","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpiotrostr%2Fpong/lists"}