Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#393 slides about portainer api #400

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 52 additions & 0 deletions slides/swarm/gui.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,3 +49,55 @@ What about web interfaces to control and manage Swarm?
- Agent URL: `tasks.agent:9001`

- Let's browse around the interface

---

## Portainer API - Advanced privileges

- setup a non administrative user

- deploy an app template via portainer with only administrator rights

- deploy an app template via portainer with rights for the created user

- do `http POST :9000/api/auth Username="$USER" Password="$PASSWORD"`

- now try to query the deployed stacks `http GET :9000/api/stacks "Authorization: Bearer $TOKEN"`
you will only see the stack with the user rights

- you could prevent access for stacks like monitoring, log-forwarding and the portainer agent

---

## Single GUI/API for multiple swarms

- setup 2 swarms instead of one swarm with 3 nodes

- install the portainer agent on both swarms

```
docker service create \
--name portainer_agent \
--network portainer_agent_network \
--publish mode=host,target=9001,published=9001 \
-e AGENT_CLUSTER_ADDR=tasks.portainer_agent \
--mode global \
--mount type=bind,src=//var/run/docker.sock,dst=/var/run/docker.sock \
--mount type=bind,src=//var/lib/docker/volumes,dst=/var/lib/docker/volumes \
portainer/agent
```

- now go to portainer and add both agents as endpoint

- now you can deploy stacks via one api on multiple docker swarms

- deploy a stack on swarm2

```
http POST ':9000/api/stacks?method=repository&type=1&endpointId=2' \
"Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6MiwidXNlcm5hbWUiOiJ1c2VyMSIsInJvbGUiOjIsImV4cCI6MTU0MTQ5MDg4OH0.9hVYxfSfdNAnQDRfEsH9-EcQkI9aL3beEmxJz8_6uOI" \
Name="Voting" \
RepositoryURL="https://github.com/BretFisher/example-voting-app" \
ComposeFilePathInRepository="docker-stack.yml" \
SwarmID="$SWARMID"
```