Configuring a Portainer endpoint via Dogu-config
This article describes how Portainer endpoints can be automatically added to Portainer at startup. at startup.
Preparation of the host computer
There are various ways to give Portainer access to Docker. The preferred option is to start a Portainer agent. Another option is to expose the Docker API directly.
Portainer agent
On the host computer (not in the VM), an agent must be started as a Docker container with the following command:
docker run -d \
-p 9001:9001 \
--name portainer_agent \
--restart=always \
-e LOG_LEVEL=DEBUG \
-v /var/run/docker.sock:/var/run/docker.sock \
-v /var/lib/docker/volumes:/var/lib/docker/volumes \
portainer/agent:2.21.2
Docker API
The Docker API must be exposed on the host computer. This can be configured with these instructions.
Creating the Dogu configuration
To ensure that the agent is automatically recognized and added when the Portainer is started, it must be stored as a JSON
configuration in the Dogu-config. In the Cloudogu EcoSystem 'Classic', the entry can be set manually for the key endpoint_configuration
key via etcdctl or configured using cesapp edit-config portainer
.
The following example configures the endpoints described above when Portainer is running in the EcoSystem VM and the endpoints on the host computer:
[
{
"Name": "ExampleAgent",
"EndpointURL":"192.168.56.1:9001",
"EndpointType": "AGENT"
},
{
"Name": "ExampleEndpoint",
"EndpointURL":"192.168.56.1:2375",
"EndpointType": "API"
}
]
The configuration must comply with the following JSON format:
[
{
"Name": "NAME",
"EndpointURL": "ENDPOINTADDRESS:PORT",
"EndpointType": "AGENT"
},
{
"Name": "ExampleAgent",
"EndpointURL":"123.23.3.1:9001",
"EndpointType": "AGENT"
},
{
"Name": "ExampleEndpoint",
"EndpointURL":"123.23.3.1:2375",
"EndpointType": "API"
},
{
"Name": "ExampleEndpointWithTls",
"EndpointURL":"123.23.3.1:2375",
"EndpointType": "API",
"TLS": "true"
}
]
Name: The name that will be displayed for the endpoint in Portainer. This can be freely chosen.
ENDPOINTADDRESS: The FQDN or IP of the machine to be managed.
PORT: The port of the Portainer agent (default: 9001).
EndpointURL: The URL to the endpoint
EndpointType (optional => default 'AGENT'): The type of the endpoint. Allowed are AGENT or API.
TLS (optional => default 'true' for AGENT and 'false' for API): Defines whether TLS is enabled at the endpoint. Is automatically always set to 'true' for type 'AGENT'. Allowed values: true | false
Updating the endpoints
In order for the changes to be recognized by Portainer, the Dogu must be restarted.
docker restart portainer