Configuring access to a registry
You can set up policies for accessing a registry from specific IP addresses.
- In the management console
, select the folder where the registry was created. - In the list of services, select Container Registry.
- Select the registry to configure access to.
- In the left-hand panel, click
Access for IP address. - Click Set.
- Enter the IP address and specify an action: PULL to allow pulling and PUSH to allow pushing Docker images to the registry.
- To configure access for multiple IPs, click Add.
- Click Save.
-
View the list of available registries, their names and IDs:
yc container registry list
Result:
+----------------------+--------+----------------------+ | ID | NAME | FOLDER ID | +----------------------+--------+----------------------+ | crpd50616s9a******** | my-reg | b1g88tflru0e******** | +----------------------+--------+----------------------+
-
Specify registry access settings:
yc container registry set-ip-permissions <registry_name> \ --pull <IP_address> \ --push <IP_address>
Where:
--pull
: Flag that allows pulling Docker images from the registry.--push
: Flag that allows pushing Docker images to the registry.
To learn more about the command, see the CLI reference.
As a result of executing this command, all the permissions set for IP addresses will be deleted. To continue, type
yes
and press Enter.Result:
WARN: All current ip permissions will be deleted. Are you sure?[y/N]
-
Check the current permissions:
yc container registry list-ip-permissions <registry_name>
Result:
+--------+-----------+ | ACTION | IP | +--------+-----------+ | PULL | 10.1.2.11 | | PUSH | 10.1.2.11 | +--------+-----------+
Terraform
For more information about the provider resources, see the documentation on the Terraform
If you change the configuration files, Terraform automatically detects which part of your configuration is already deployed, and what should be added or removed.
If you don't have Terraform, install it and configure the Yandex Cloud provider.
-
Specify registry access settings in the Terraform configuration file.
resource "yandex_container_registry_ip_permission" "my_ip_permission" { registry_id = <registry_ID> push = [ "<IP address>", "<IP address>" ] pull = [ "<IP address>", "<IP address>" ] }
Where:
my_registry
: Registry ID. If the configuration already contains the yandex_container_registry resource, you can specify it, e.g.,yandex_container_registry.my_registry.id
.pull
: IP addresses that can be used to pull Docker images from the registry. This is an optional parameter.push
: IP addresses that can be used to push Docker images to the registry. This is an optional parameter.
For more information about the
yandex_container_registry_ip_permission
parameters in Terraform, see the provider documentation . -
Create resources:
-
In the terminal, change to the folder where you edited the configuration file.
-
Make sure the configuration file is correct using the command:
terraform validate
If the configuration is correct, the following message is returned:
Success! The configuration is valid.
-
Run the command:
terraform plan
The terminal will display a list of resources with parameters. No changes are made at this step. If the configuration contains errors, Terraform will point them out.
-
Apply the configuration changes:
terraform apply
-
Confirm the changes: type
yes
in the terminal and press Enter.
Terraform will create all the required resources. You can check the new resources using the management console
or this CLI command:yc container registry list-ip-permissions <registry_name>
-