Learning about Services and how streams are proxy'd #28
Labels
No labels
bug
cleanup
duplicate
enhancement
forgefriends
help wanted
hetzner
invalid
label workflow
need more info
question
refactor
static-site
sync
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
infrastructure/k8s-cluster#28
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Notes from the chatroom
Fri, Oct 25, 2024, 15:03:08 - * Earl Warren backtracking
Fri, Oct 25, 2024, 15:04:01 - Earl Warren: I'm quite sure there are a lot of things I do not need to worry about. Right now I'm just massively confused about the whole thing. But after bumping into a few walls, I'll get it.
Fri, Oct 25, 2024, 15:04:34 - Earl Warren: trying to separate traefik concepts from k8s concepts is good advice, that helps 🙏
Fri, Oct 25, 2024, 15:06:00 - Earl Warren: I should not be looking at
kubectl -n kube-system describe svc traefikto understandflux/infrastructure/controllers/traefik.yamlbecause the output matches k8s concepts while the file matches traefik conceptsFri, Oct 25, 2024, 15:06:56 - Michael Kriese: for traefik we tell it: hey listen on public port 2020 and name it
ssh-nextFri, Oct 25, 2024, 15:08:35 - Michael Kriese: then we configure the
IngressRouteTCPwhich says: hey traefik forward traffic fromssh-nextto forgejo ssh serviceFri, Oct 25, 2024, 15:09:01 - Earl Warren: the problem is that I perfectly understand the intent. But the details are confusing.
Fri, Oct 25, 2024, 15:09:03 - Michael Kriese: the
forgejo-sshservice forwards to traefik podsFri, Oct 25, 2024, 15:09:44 - Michael Kriese: yeah, especially all involved objects can use different ports
Fri, Oct 25, 2024, 15:10:10 - Earl Warren: https://doc.traefik.io/traefik/v3.1/routing/entrypoints/ is what I would assume to explain https://github.com/traefik/traefik-helm-chart/blob/v32.1.1/traefik/values.yaml#L584 but none of the keys match the documentation.
Fri, Oct 25, 2024, 15:10:29 - Michael Kriese: so the kubernetes service is doing a kind of masquerading the service port to the pod port
Fri, Oct 25, 2024, 15:11:03 - Michael Kriese: so the service can use normal http and https ports while the pod needs to use higher ports when running as non root
Fri, Oct 25, 2024, 15:12:09 - Earl Warren: <@viceice:matrix.org "for traefik we tell it: hey list..."> so I assume "port: 2020" is the port that is public? Or is it exposedPort: 2020?
Fri, Oct 25, 2024, 15:12:10 - Michael Kriese: thats another cause why prefer to use named ports, so you don't need to remember to forward port x to port y. just say forward http to http or ssh to ssh
Fri, Oct 25, 2024, 15:12:25 - Michael Kriese:
exposedPort: 2020Fri, Oct 25, 2024, 15:12:47 - Michael Kriese:
port: 2020is the port where the traefik port listens onFri, Oct 25, 2024, 15:13:05 - Michael Kriese: so it can be different from exposedPort
Fri, Oct 25, 2024, 15:13:30 - Earl Warren: that's good
Fri, Oct 25, 2024, 15:13:53 - Earl Warren: https://github.com/traefik/traefik-helm-chart/blob/v32.1.1/traefik/values.yaml#L603-L604
what not helpful in that regard 😄
Fri, Oct 25, 2024, 15:13:58 - Michael Kriese: eg i use port 22 on my public loadbalancer ip and forward it via traefik to forgejo port 2222 (rootless)
Fri, Oct 25, 2024, 15:14:42 - Earl Warren: ok, that's sorted out 👍️
Fri, Oct 25, 2024, 15:15:27 - Michael Kriese: <@earl-warren:matrix.org "https://github.com/traefik/traef..."> but because of https://github.com/traefik/traefik-helm-chart/blob/v32.1.1/traefik/values.yaml#L602 that port is not published on
traefikserviceFri, Oct 25, 2024, 15:15:47 - Michael Kriese: so it's not accessable from internet (if no firewall would block it)
Fri, Oct 25, 2024, 15:16:21 - Michael Kriese: that port should never be publised to internet!!!
Fri, Oct 25, 2024, 15:16:49 - Earl Warren: ```yaml
exposedPort: 2020
expose:
default: false
Fri, Oct 25, 2024, 15:20:43 - Earl Warren: <@earl-warren:matrix.org "$ kubectl -n kube-system describ..."> I think I should not, too early.
Fri, Oct 25, 2024, 15:20:45 - Michael Kriese: you can ignore
nodePortfor now, it's basically the port which kubernetes uses to forward traffic fromPorttotargetPortvia iptable rulesFri, Oct 25, 2024, 15:21:25 - Earl Warren: <@viceice:matrix.org "this is what i do on traefik to ..."> now I wonder... what does it mean for traefik to listen to port 2222?
Fri, Oct 25, 2024, 15:21:54 - Earl Warren: or maybe it is the destination port
Fri, Oct 25, 2024, 15:22:15 - Earl Warren: no... I'm wrong
Fri, Oct 25, 2024, 15:22:27 - * Earl Warren scratching his head
Fri, Oct 25, 2024, 15:22:37 - Earl Warren: forgejo-next listens on 2222
Fri, Oct 25, 2024, 15:22:52 - Earl Warren: why would traefik need to... I miss something important
Fri, Oct 25, 2024, 15:23:22 - * Earl Warren reading again above
Fri, Oct 25, 2024, 15:23:25 - Michael Kriese: so for http traffic:
10.42.0.105:80,10.42.0.106:80Fri, Oct 25, 2024, 15:24:57 - Michael Kriese: <@earl-warren:matrix.org "now I wonder... what does it mea..."> this simply tells traefik to listen on port 2222 (can be any port, using this for dry, so i know it's the forgejo default ssh port for rootless)
Fri, Oct 25, 2024, 15:25:48 - Earl Warren: oh
Fri, Oct 25, 2024, 15:25:54 - Earl Warren: so it is not actually used?
Fri, Oct 25, 2024, 15:26:07 - Earl Warren: nobody connects to 2222 on traefik?
Fri, Oct 25, 2024, 15:26:37 - Earl Warren: it is for documentation purposes so it is used elsewhere?
Fri, Oct 25, 2024, 15:26:47 - Michael Kriese: not directly, you connect to port 22 and the kubernetes service is forwarding to traefik port 2222
Fri, Oct 25, 2024, 15:28:02 - Earl Warren: I'm afraid I'm wasting your time, I need to study this more carefully to get a mental image of what is going on 😊
Fri, Oct 25, 2024, 15:28:55 - Michael Kriese: so for traefik ports you configure two ports
port: xxxwhere traefik listens with an entrypoint andexposedPort: yyywhere public traffc needs to arrive (so for a loadbalancer service it can come from outside the clusterFri, Oct 25, 2024, 15:30:01 - Michael Kriese: thankfully i've a day off because the daycare is closed today
Fri, Oct 25, 2024, 15:30:15 - Michael Kriese: but i need to wake my daughter up now
Fri, Oct 25, 2024, 15:49:07 - * Earl Warren studies https://paste.centos.org/view/raw/163c149a, the output of
helm install something --dry-run --debug -f traefik.yml oci://ghcr.io/traefik/helm/traefikwithFri, Oct 25, 2024, 15:54:35 - Earl Warren: So it creates a service of kind LoadBalancer which listens on all exposed ports and reverse proxy them to the "Deployment" which are pods with names starting with traefik
Fri, Oct 25, 2024, 15:54:37 - Earl Warren: $ kubectl -n kube-system describe pod traefik-7c47c4b4c-47vbx | pastebinit
https://paste.centos.org/view/734fefab
Fri, Oct 25, 2024, 15:57:40 - Earl Warren: each pod listens to ports
Ports: 9100/TCP, 2020/TCP, 9000/TCP, 80/TCP, 8443/TCPas specified in the infrastructure/controllers/traefik.yaml and interpreted in https://github.com/traefik/traefik-helm-chart/blob/v32.1.1/traefik/values.yaml#L646-L673 (for websecure).Fri, Oct 25, 2024, 16:08:06 - Earl Warren: A Deployment can then request from traefik to be routed whatever comes through this port, this is the purpose of IngressRouteTCP.
Fri, Oct 25, 2024, 16:10:33 - Michael Kriese: 👍
Fri, Oct 25, 2024, 16:10:34 - Earl Warren: The
entryPointshere matches that part of the traefik Deployment:This is really the only way traefik can know that the container it lives in receives something on a given port.
Fri, Oct 25, 2024, 16:11:21 - Earl Warren: And this is also how it knows to match an entrypoint name to a port.
Fri, Oct 25, 2024, 16:17:47 - Earl Warren: The documentation of the IngressRouteTCP are in https://doc.traefik.io/traefik/v3.1/routing/providers/kubernetes-crd/#kind-ingressroutetcp and quite terse but there is nothing better.
Fri, Oct 25, 2024, 16:18:34 - Earl Warren:
match: HostSNI(*)makes sense for SSH because there is no notion of the host from which the request originates.Fri, Oct 25, 2024, 16:22:36 - Earl Warren: The service part:
tells it to reverse proxy whatever it gets to the service
forgejo-ssh. The documentation is not helpful as it does not give a hint about what is done (reverse proxying) and justFri, Oct 25, 2024, 16:24:23 - Michael Kriese: <@earl-warren:matrix.org "The service part:"> it connects traefik entry point to kubernetes service and port
Fri, Oct 25, 2024, 16:26:12 - Earl Warren: connects as in proxying the stream from the traefik Deployment to the forgejo-ssh Service? (trying to sort out names in my head) 😁
Fri, Oct 25, 2024, 16:34:38 - * Earl Warren studying the output of
~/k8s-cluster/flux/apps/forgejo-nexthelm install forgejo --dry-run --debug -f forgejo-next.yaml oci://code.forgejo.org/forgejo-helm/forgejo | pastebinithttps://paste.centos.org/view/275ac368
Fri, Oct 25, 2024, 16:36:54 - Earl Warren: ```yaml
Source: forgejo/templates/gitea/ssh-svc.yaml
apiVersion: v1
kind: Service
metadata:
name: forgejo-ssh
namespace: "default"
labels:
helm.sh/chart: forgejo-10.0.0
app: forgejo
app.kubernetes.io/name: forgejo
app.kubernetes.io/instance: forgejo
app.kubernetes.io/version: "9.0.0"
version: "9.0.0"
app.kubernetes.io/managed-by: Helm
annotations:
{}
spec:
type: ClusterIP
clusterIP: None
ports:
port: 22
targetPort: 2222
protocol: TCP
selector:
app.kubernetes.io/name: forgejo
app.kubernetes.io/instance: forgejo