Almost never want to create a Pod directly. A Deployment is a managed group of Pods (meaning: the number of replicas is maintained across time).
Deployment is, for most users, the primary workload interface. If a Pod dies (e.g. a node goes away), Deployment will make sure that a new one comes up.
A Service is a related but distinct concept. A service is a group of pods which serve the same purpose on the network. That could be one Deployment, or it could be many Deployments. Not all Deployments want to be exposed as a Service, and some Services are backed by things other than Deployments.
This is a prime example of what kubernetes docs describe as “loose coupling”.
So I could have a frontend deployment listening on :8080 and a backend deployment listening on :7777 as a single service and exposing those 2 ports internally?
Related:
I tried creating a nginx ingress under the same namespace and the frontend was mounted unter Prefix / and the backend under Prefix /api.
However I have wrapped the frontend in a Go binary, aka embedded and any 404 would be served as /index.html, essentially the same as nginx try_files $uri $uri/ index.html etc.
However when trying to curl /api/v1/profile/ I would get the frontend with a 404.
I can’t seem to be able to do a
location / {
}
location /api/ {
}
The nginx ingress defines those prefix routes as ~* (or was it *~) aka a regexp and this of course then collides, as it’s not the proper way to define something like this.
Maybe I should create an issue on the nginx ingress repo.
I’m on the phone can post the ingress conf later, if anyone would like to take a look at it
With this curl -v -k https://iloveu.luketic/api/v1/profile/ returns html mounted under the / path, instead of hitting the backend mounted under /api/.
That was on a microk8s v1.28 cluster with microk8s enable ingress. Meanwhile I’ve destroyed that cluster so I can’t give details, but I know what it wasn’t using location / and location /api/.
I’m now on a k0s cluster, and installed the ingress-nginx via helm and will see what kind of configuration this produces.
But maybe I should create a new topic for that?
Below is my current live config (domain name changed), no k8s.
There’s a websocket route. Idk how to do that with an ingress nginx or other.