yandex-cloud / docker-machine-driver-yandex Goto Github PK
View Code? Open in Web Editor NEWYandex.Cloud driver for Docker Machine
License: MIT License
Yandex.Cloud driver for Docker Machine
License: MIT License
Здравствуйте, будет ли добавлена возможность создания vm с gpu?
Разбираюсь с поведением параметра --yandex-userdata
Что хочу получить:
На создаваемой машине необходимо добавить несколько строчек в hosts.
С виду параметр --yandex-userdata
подходит для этой цели, чтобы передать дополнительные настройки cloud-init
Что делаю:
Создаю файл /tmp/custom-userdata.yml
#cloud-config
runcmd:
- echo Test runcmd
- echo 127.0.0.1 myservice >> /etc/hosts
добавляю параметр --yandex-userdata=/tmp/custom-userdata.yml
полная команда выглядит так:
docker-machine --debug create -d yandex \
--yandex-cloud-id=*** \
--yandex-folder-id=*** \
--yandex-subnet-id=*** \
--yandex-token=*** \
--yandex-ssh-user=*** \
--yandex-cores=1 \
--yandex-disk-size=20 \
--yandex-disk-type=network-hdd \
--yandex-memory=2 \
--yandex-use-internal-ip=1 \
--yandex-nat=0 \
--yandex-userdata=/tmp/custom-userdata.yml \
foo
Что ожидаю:
Создания ВМ с сообщением "Test runcmd" в логах создания и изменненым hosts
Что получаю:
"зависание" на ожидании ssh-ключа доступа
(foo) Creating instance...
(foo) Use image with ID "fd8fjtn3mj2kfe7h6f0r" from folder ID "standard-images"
(foo) Waiting for Instance with ID "fhmk77og2809r847lui1"
(foo) Calling .GetConfigRaw
(foo) Calling .DriverName
(foo) Calling .DriverName
Waiting for machine to be running, this may take a few minutes...
(foo) Calling .GetState
(foo) DBG | Instance State: RUNNING
Detecting operating system of created instance...
Waiting for SSH to be available...
Getting to WaitForSSH function...
(foo) Calling .GetSSHHostname
(foo) Calling .GetSSHPort
(foo) Calling .GetSSHKeyPath
(foo) Calling .GetSSHKeyPath
(foo) Calling .GetSSHUsername
Using SSH client type: external
<nil>
Error getting ssh command 'exit 0' : stat /root/.docker/machine/machines/foo/id_rsa: no such file or directory
Getting to WaitForSSH function...
(foo) Calling .GetSSHHostname
(foo) Calling .GetSSHPort
(foo) Calling .GetSSHKeyPath
(foo) Calling .GetSSHKeyPath
(foo) Calling .GetSSHUsername
Using SSH client type: external
<nil>
Error getting ssh command 'exit 0' : stat /root/.docker/machine/machines/foo/id_rsa: no such file or directory
Getting to WaitForSSH function...
Посмотрел код и понял, что user-data используется самим драйвером для добавления сгенерированного ключа доступа и настроек пользователя.
Если же передавать свои user-data, то не происходит генерации ключей доступа docker-mashine к ВМ и установка не завершается успешно.
Что еще пробовал сделать:
Использовать заранее сгененированный ключ для доступа
custom-userdata.yml
#cloud-config
ssh_pwauth: no
users:
- name: ***
sudo: ALL=(ALL) NOPASSWD:ALL
shell: /bin/bash
ssh_authorized_keys:
- ssh-rsa AAAAB3Nza...
runcmd:
- echo Test runcmd
- echo 127.0.0.1 myservice >> /etc/hosts
cp ~/.ssh/id_rsa ~/.docker/machine/machines/foo/id_rsa
После такого изменения ВМ создается с ожидаемыми параметрами и сообщениями
Что предлагаю:
Предлагаю несколько вариантов улучшения:
При использовании динамических gitlab-runners выявили ошибку, когда из-за сбоя в сети или работе API ЯО генерируется большое количество "призрачных" ВМ в docker-machine, со статусом error. При этом, сам gitlab-runner не останавливается и пытается создать еще и еще ВМ. В результате, когда таких сбойных ВМ накапливается в пару сотен docker-machine полностью отказывается работать.
Судя по всему проблема, в том, что когда не удается создать машину в ЯО в docker-machine все равно остается запись и при попытке удаления таких "призрачных" машин происходит ошибка, что не удалось найти ВМ по пустому ID. Как решение можно на такую ошибку добавить force удаление, тогда по сути несуществующая машина будет почищена из списка docker-machine.
Изменения примерно тут https://github.com/yandex-cloud/docker-machine-driver-yandex/blob/master/driver/driver.go#L442
Либо предварительно делать проверку на существования инстанса с таким ID и если его, нет то просто удалять его.
Что делаю:
docker-machine create -d yandex \
--yandex-cloud-id=*** \
--yandex-folder-id=*** \
--yandex-subnet-id=*** \
--yandex-token=*** \
--yandex-ssh-user=*** \
--yandex-cores=1 \
--yandex-disk-size=20 \
--yandex-disk-type=network-hdd \
--yandex-memory=2 \
--yandex-use-internal-ip=1 \
foo
Что ожидаю:
Создание ВМ только с локальным IP
Что получаю:
ВМ с локальным и внешним IP
Дополнительным "бонусом" перестает работать таблица маршрутизации, указанная у private-subnet пока не удалю внешний IP.
Дополнения:
docker-machine при этом получает корректный внутренний URL, так что возможно параметр отвечает только за URL.
здесь foo создан с параметром "yandex-use-internal-ip", а bar - без него
NAME ACTIVE DRIVER STATE URL SWARM DOCKER ERRORS
foo - yandex Running tcp://192.168.49.28:2376 v19.03.9
bar - yandex Running tcp://84.201.130.201:2376 v19.03.9
Возможно надо использовать --yandex-userdata
, но к сожалению этот параметр не смог разобрать.
We need the ability to use a service account bound to master VM to create virtual docker-machines in the cloud.
I tried using a wrapper for docker-machine
#!/bin/bash
yc_token=$(curl -s -H 'Metadata-Flavor: Google' 'http://169.254.169.254/computeMetadata/v1/instance/service-accounts/default/token' | sed -r -e 's/.*"access_token": ?"([^"]+)".*/\1/')
set -- $(echo $@ | sed -r -e "s/__YC_TOKEN__/$yc_token/")
exec $(dirname $0)/true-docker-machine $@
but it doesn't work for deletion of the docker-machine VM after 12 hours, since iam token is saved in the docker-machine metadata and it isn't updated.
How to specify the security group during the creation of docker-machine?
As far as I understand change of security group after creation is not allowed.
Хотелось бы использовать docker-machine для сборки образов, но при попытке доступа к docker registry получаю ошибку доступа. посмотрел созданную вм, там не указан соответственно сервисный аккаунт, хотя ключ указывал, видимо он использовался чисто для создания вм. подскажите как лучше быть в такой ситуации, получится ли доработать функционал.
Encountered this yesterday, any thoughts on how to avoid it? @GennadySpb
~ » go get -u github.com/yandex-cloud/docker-machine-driver-yandex
go: downloading github.com/yandex-cloud/docker-machine-driver-yandex v0.0.0-20210210140807-f5330e228f46
go: downloading github.com/yandex-cloud/go-genproto v0.0.0-20201102102956-0c505728b6f0
go: downloading github.com/yandex-cloud/go-sdk v0.0.0-20201109103511-a86298d3fea5
go: downloading github.com/yandex-cloud/go-sdk v0.0.0-20210211095836-1e646debd48a
go: downloading github.com/yandex-cloud/go-genproto v0.0.0-20210301094436-7f3b899d605e
go get: github.com/Sirupsen/logrus@none updating to
github.com/Sirupsen/[email protected]: parsing go.mod:
module declares its path as: github.com/sirupsen/logrus
but was required as: github.com/Sirupsen/logrus
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.