Running Portainer and a edge agent behind a ingress with https #12542
darkeagle1337
started this conversation in
Ideas
Replies: 2 comments
-
|
Great, thx @darkeagle1337 that's exactly what i was looking for. |
Beta Was this translation helpful? Give feedback.
0 replies
-
|
GG, I needed to adjust the ws: to https:// for Cloudflare... What a stupid problem. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Ask a Question!
Hi all,
this is not a bug or a problem, I'd like to share my analysis and solution with you, so other people can find this and adopt it to their solution, also maybe it's something for the portainer agent documentation.
Goal
Portainer UI and API accessible from
portainer.example.ioand edge agent tunnel working againstagent.portainer.example.io.Step 1: Install Portainer
First I installed portainer as described in the (docs). I am using nginx as the ingress controller.
Then I add this ingress for the agent:
The connection also allows HTTP connections, so we had to set the
nginx.ingress.kubernetes.io/ssl-redirectannotation tofalse.The important things are the following annotations. For more information https://nginx.org/en/docs/http/websocket.html
I don't use the `nginx.ingress.kubernetes.io/configuration-snippet' annotation because it might crash the ingress controller if the snippet has a syntax error.
Step 2: Add an enviroment
Next, you can create an environment in the Portainer UI. If you select the Docker Edge Agent and create it, you will get a join token that can be used by an Edge Agent to register with a Portainer instance.
The key represents the following data in this particular format
portainer_instance_url|tunnel_server_addr|tunnel_server_fingerprint|endpoint_IDExample:
Base64 Encoded:
aHR0cHM6Ly9wb3J0YWluZXIuZXhhbXBsZS5pb3xhZ2VudC5wb3J0YWluZXIuZXhhbXBsZS5pb3xub2FPb1R3Sk94RHhkZ1pqWXhLWWRsRHFOSmxyVjljaU1sMWZoUWxBaTFZPXw2Njk3Decoded:
https://portainer.example.io|portainer.example.io:8000|noaOoTwJOxDxdgZjYxKYdlDqNJlrV9ciMl1fhQlAi1Y=|6697By default, tunnel_server_addr is always the host of the portainer and the tunnel port (default: 8000).
https://github.com/portainer/portainer/blob/develop/api/http/handler/endpoints/endpoint_create.go#L378
Have a look at https://github.com/portainer/portainer/blob/develop/api/chisel/key.go#L14
But for our purpose this is not usable, because we don't want to expose port 8000 from our Kubernetes cluster and we want to achieve a secure connection to the websocket.
So we need to modify the decoded token and re-encode it.
Tip:
wss://<host>:443look correct but it won't work https://github.com/jpillora/chisel/blob/ab8f06a83048dca0c24dc0b06932dc98df54e8b1/client/client.go#L86Step 3: Start and connect
Start the Portainer edge agent using the docker command:
From the Portainer UI, you can then connect to your environment.
Best regards,
Christian
Beta Was this translation helpful? Give feedback.
All reactions