Skip to content

Деплой в закрытом контуре

Варианты развертывания ALT Orchestra в закрытом контуре:

  • Организовать локальный контур с сервером сетевой загрузки в одной подсети с узлами кластера. У сервера сетевой загрузки должен быть доступ в интернет, либо на нем надо локально разместить заранее скачанные образы (ядро, initramfs и скрипт ipxe). Далее необходимо выполнять установку по ipxe.
  • Развернуть локальный реестр образов с доступом в интернет, скачать в его хранилище необходимые образы с image factory, далее при генерации конфига для инсталляции ALT Orchestra указывать путь к образам в локальном реестре.

Подготовка Стенда

Установка Необходимых Пакетов

console
# apt-get install -y dhcp-server \
bind \
bind-utils \
chrony \
podman \
docker-registry \
containers-common \
net-tools \
curl \
jq \
podman \
grpcurl \
git \
talosctl \
wget \
yq \
kubernetes1.33-client \
discovery-service-rs \
trivy \
helm

Настройка DHCP

Создать каталог для конфигурации сетевого интерфейса ens20:

console
IFACE="ens20" && mkdir -p /etc/net/ifaces/${IFACE}

Назначить статический IPv4-адрес и маску подсети для интерфейса:

console
# echo 192.168.1.1/24 > /etc/net/ifaces/${IFACE}/ipv4address

Настроить параметры интерфейса (тип, протокол, автозагрузка):

console
# cat > /etc/net/ifaces/${IFACE}/options <<EOF
TYPE=eth
CONFIG_WIRELESS=no
BOOTPROTO=static
SYSTEMD_BOOTPROTO=static
CONFIG_IPV4=yes
DISABLED=no
NM_CONTROLLED=no
SYSTEMD_CONTROLLED=no
ONBOOT=yes
EOF

Перезапустить сетевую службу и проверить назначенные адреса:

console
# systemctl restart network && ip a

Создать конфигурацию DHCP-сервера с диапазоном адресов и параметрами:

console
# cat > /etc/dhcp/dhcpd.conf << EOF
option space altlinux;
option altlinux.keydata code 2 = string;
vendor-option-space altlinux;
subnet 192.168.1.0 netmask 255.255.255.0 {
    next-server 192.168.1.1;
    option routers 192.168.1.1;
    option domain-name-servers 192.168.1.1;
    option ntp-servers 192.168.1.1;
    default-lease-time 3600;
    max-lease-time 3600;
    range 192.168.1.2 192.168.1.254;
}
EOF

Включить автозапуск DHCP-сервера, запустить его и проверить статус:

console
# systemctl enable --now dhcpd && sleep 5; systemctl status dhcpd --no-pager -l

Настройка DNS

Настроить подсети для прослушивания DNS-запросов:

console
# sed -i 's|listen-on {.*|listen-on { 127.0.0.1; 192.168.1.0/24; };|g' /etc/bind/options.conf

Добавить зоны прямого и обратного просмотра в конфигурацию BIND:

console
# cat >> /etc/bind/local.conf <<'EOF'
zone "internal.local" {
    type master;
    file "/etc/bind/zone/db.internal.local";
    allow-update { 192.168.1.0/24; };
};

zone "1.168.192.in-addr.arpa" {
    type master;
    file "/etc/bind/zone/db.192.168.1";
    allow-update { 192.168.1.0/24; };
};
EOF

Создать файл зоны прямого просмотра (A-записи):

console
# cat > /etc/bind/zone/db.internal.local <<'EOF'
$TTL 604800
@       IN      SOA     ns1.internal.local. admin.internal.local. (
                                2025010101 ; Serial
                                604800     ; Refresh
                                86400      ; Retry
                                2419200    ; Expire
                                604800     ; Negative Cache TTL
                                )
        IN      NS      ns1.internal.local.
ns1     IN      A       192.168.1.1
EOF

Создать файл зоны обратного просмотра (PTR-записи):

console
# cat > /etc/bind/zone/db.192.168.1 <<'EOF'
$TTL 604800
@       IN      SOA     ns1.internal.local. admin.internal.local. (
                                2025010101 ; Serial
                                604800     ; Refresh
                                86400      ; Retry
                                2419200    ; Expire
                                604800     ; Negative Cache TTL
                                )
        IN      NS      ns1.internal.local.
EOF

Включить автозапуск BIND, запустить службу и проверить статус:

console
# systemctl enable --now bind && sleep 5; systemctl status bind --no-pager -l

Настройка NTP

Настроить разрешение доступа для всех клиентов и указать NTP-пулы:

console
# cat >> /etc/chrony.conf <<'EOF'
allow all
pool pool.ntp.org iburst
EOF

Включить автозапуск службы Chrony:

console
# systemctl enable chronyd

Перезапустить службу Chrony и проверить её статус:

console
# systemctl restart chronyd && sleep 5; systemctl status chronyd --no-pager -l

Настройка Прокси И Кэша Для Необходимых Образов

registry.altlinux.org (по умолчанию)

Настроить клиент Podman:

console
# cat >> /etc/containers/registries.conf <<'EOF'
[[registry]]
prefix = "registry.altlinux.org"
location = "registry.altlinux.org"

[[registry.mirror]]
prefix = "registry.altlinux.org"
location = "localhost:5000"
insecure = true
EOF

Настроить Docker Registry:

console
# cat > /etc/docker-registry/config.yml << 'EOF'
version: 0.1
log:
  fields:
    service: registry
storage:
  cache:
    blobdescriptor: inmemory
  filesystem:
    rootdirectory: /var/lib/docker-registry
http:
  addr: :5000
  headers:
    X-Content-Type-Options: [nosniff]
proxy:
  remoteurl: https://registry.altlinux.org
EOF

Перезагрузить конфигурацию systemd:

console
# systemctl daemon-reload

Включить автозапуск Docker Registry, запустить службу и проверить статус:

console
# systemctl enable --now docker-registry.service && sleep 5; systemctl status docker-registry.service --no-pager -l

Проверить работу сервиса на порту 5000:

console
# netstat -nlpt | grep 5000

Протестировать прокси-кэш (дополнительные проверки):

console
$ podman pull --tls-verify=false registry.altlinux.org/p11/kube-apiserver && \
$ curl http://localhost:5000/v2/_catalog | jq && \
$ curl http://localhost:5000/v2/p11/kube-apiserver/tags/list | jq && \
$ podman pull --tls-verify=false localhost:5000/p11/kube-apiserver
altlinux.space

Настроить клиент Podman на использование Docker-Registry https://altlinux.space:

console
# cat >> /etc/containers/registries.conf <<'EOF'
[[registry]]
prefix = "altlinux.space"
location = "altlinux.space"

[[registry.mirror]]
prefix = "altlinux.space"
location = "localhost:5001"
insecure = true
EOF

Настроить сервер Docker-Registry для https://altlinux.space:

console
# cat > /etc/docker-registry/config-altlinux.yml << 'EOF'
version: 0.1
log:
  fields:
    service: registry
storage:
  cache:
    blobdescriptor: inmemory
  filesystem:
    rootdirectory: /var/lib/docker-registry
http:
  addr: :5001
  headers:
    X-Content-Type-Options: [nosniff]
proxy:
  remoteurl: https://altlinux.space
EOF

Настроить systemd-сервис:

console
# cp /lib/systemd/system/docker-registry.service /lib/systemd/system/docker-registry-altlinux.service
# sed -i 's|config.yml|config-altlinux.yml|g' /lib/systemd/system/docker-registry-altlinux.service

Применить изменения и запустить сервис:

console
# systemctl daemon-reload
# systemctl enable --now docker-registry-altlinux.service && sleep 5; systemctl status docker-registry-altlinux.service --no-pager -l

Проверить работу Docker-Registry:

console
$ netstat -nlpt | grep 5001
$ curl -s http://localhost:5001/v2/_catalog | jq

ghcr.io

Настроить клиент Podman на использование Docker-Registry https://ghcr.io:

console
# cat >> /etc/containers/registries.conf <<'EOF'
[[registry]]
prefix = "ghcr.io"
location = "ghcr.io"

[[registry.mirror]]
prefix = "ghcr.io"
location = "localhost:5002"
insecure = true
EOF

Настроить сервер Docker-Registry для https://ghcr.io:

console
# cat > /etc/docker-registry/config-ghcr.yml << 'EOF'
version: 0.1
log:
  fields:
    service: registry
storage:
  cache:
    blobdescriptor: inmemory
  filesystem:
    rootdirectory: /var/lib/docker-registry
http:
  addr: :5002
  headers:
    X-Content-Type-Options: [nosniff]
proxy:
  remoteurl: https://ghcr.io
EOF

Настроить systemd-сервис:

console
# cp /lib/systemd/system/docker-registry.service /lib/systemd/system/docker-registry-ghcr.service
# sed -i 's|config.yml|config-ghcr.yml|g' /lib/systemd/system/docker-registry-ghcr.service

Применить изменения и запустить сервис:

console
# systemctl daemon-reload
# systemctl enable --now docker-registry-ghcr.service && sleep 5; systemctl status docker-registry-ghcr.service --no-pager -l

Проверить работу Docker-Registry:

console
$ netstat -nlpt | grep 5002
$ curl -s http://localhost:5002/v2/_catalog | jq

registry.k8s.io

Настроить клиент Podman на использование Docker-Registry https://registry.k8s.io:

console
# cat >> /etc/containers/registries.conf <<'EOF'
[[registry]]
prefix = "registry.k8s.io"
location = "registry.k8s.io"

[[registry.mirror]]
prefix = "registry.k8s.io"
location = "localhost:5003"
insecure = true
EOF

Настроить сервер Docker-Registry для https://registry.k8s.io:

console
# cat > /etc/docker-registry/config-k8s.yml << 'EOF'
version: 0.1
log:
  fields:
    service: registry
storage:
  cache:
    blobdescriptor: inmemory
  filesystem:
    rootdirectory: /var/lib/docker-registry
http:
  addr: :5003
  headers:
    X-Content-Type-Options: [nosniff]
proxy:
  remoteurl: https://registry.k8s.io
EOF

Настроить systemd-сервис:

console
# cp /lib/systemd/system/docker-registry.service /lib/systemd/system/docker-registry-k8s.service
# sed -i 's|config.yml|config-k8s.yml|g' /lib/systemd/system/docker-registry-k8s.service

Применить изменения и запустить сервис:

console
# systemctl daemon-reload
# systemctl enable --now docker-registry-k8s.service && sleep 5; systemctl status docker-registry-k8s.service --no-pager -l

Проверить работу Docker-Registry:

console
$ netstat -nlpt | grep 5003
$ curl -s http://localhost:5003/v2/_catalog | jq

docker.io

Настроить клиент Podman на использование Docker-Registry https://docker.io:

console
# cat >> /etc/containers/registries.conf <<'EOF'
[[registry]]
prefix = "docker.io"
location = "docker.io"

[[registry.mirror]]
prefix = "docker.io"
location = "localhost:5004"
insecure = true
EOF

Настроить сервер Docker-Registry для https://docker.io:

console
# cat > /etc/docker-registry/config-docker.yml << 'EOF'
version: 0.1
log:
  fields:
    service: registry
storage:
  cache:
    blobdescriptor: inmemory
  filesystem:
    rootdirectory: /var/lib/docker-registry
http:
  addr: :5004
  headers:
    X-Content-Type-Options: [nosniff]
proxy:
  remoteurl: https://registry-1.docker.io
EOF

Настроить systemd-сервис:

console
# cp /lib/systemd/system/docker-registry.service /lib/systemd/system/docker-registry-docker.service
# sed -i 's|config.yml|config-docker.yml|g' /lib/systemd/system/docker-registry-docker.service

Применить изменения и запустить сервис:

console
# systemctl daemon-reload
# systemctl enable --now docker-registry-docker.service && sleep 5; systemctl status docker-registry-docker.service --no-pager -l

Проверить работу Docker-Registry:

console
$ netstat -nlpt | grep 5004
$ curl -s http://localhost:5004/v2/_catalog | jq

factory.altlinux.space

Настроить клиент Podman на использование Docker-Registry https://factory.altlinux.space:

console
# cat >> /etc/containers/registries.conf <<'EOF'
[[registry]]
prefix = "factory.altlinux.space"
location = "factory.altlinux.space"

[[registry.mirror]]
prefix = "factory.altlinux.space"
location = "localhost:5005"
insecure = true
EOF

Настроить сервер Docker-Registry для https://factory.altlinux.space:

console
# cat > /etc/docker-registry/config-factory.yml << 'EOF'
version: 0.1
log:
  fields:
    service: registry
storage:
  cache:
    blobdescriptor: inmemory
  filesystem:
    rootdirectory: /var/lib/docker-registry
http:
  addr: :5005
  headers:
    X-Content-Type-Options: [nosniff]
proxy:
  remoteurl: https://factory.altlinux.space
EOF

Настроить systemd-сервис:

console
# cp /lib/systemd/system/docker-registry.service /lib/systemd/system/docker-registry-factory.service
# sed -i 's|config.yml|config-factory.yml|g' /lib/systemd/system/docker-registry-factory.service

Применить изменения и запустить сервис:

console
# systemctl daemon-reload
# systemctl enable --now docker-registry-factory.service && sleep 5; systemctl status docker-registry-factory.service --no-pager -l

Проверить работу Docker-Registry:

console
$ netstat -nlpt | grep 5005
$ curl -s http://localhost:5005/v2/_catalog | jq

Настройка Discovery Service RS

Запустить сервис:

console
# systemctl enable --now discovery-service-rs.service && sleep 5; systemctl status discovery-service-rs.service --no-pager -l

Проверить, что порты прослушиваются:

console
$ netstat -tulnp | grep '[32]000'

Сервис запущен на портах 3000 / 2000:

text
tcp        0      0 0.0.0.0:2000                0.0.0.0:*                   LISTEN      1790/discovery-serv
tcp        0      0 0.0.0.0:3000                0.0.0.0:*                   LISTEN      1790/discovery-serv

Выполнить тестирование запросом Hello:

console
$ mkdir -p proto
$ cat > proto/cluster_grpc.proto << 'EOF'
syntax = "proto3";
package sidero.discovery.server;
import "google/protobuf/duration.proto";
service Cluster {
rpc Hello(HelloRequest) returns (HelloResponse);
rpc AffiliateUpdate(AffiliateUpdateRequest) returns (AffiliateUpdateResponse);
rpc AffiliateDelete(AffiliateDeleteRequest) returns (AffiliateDeleteResponse);
rpc List(ListRequest) returns (ListResponse);
rpc Watch(WatchRequest) returns (stream WatchResponse);
}
message Affiliate {
string id = 1;
bytes data = 2;
repeated bytes endpoints = 3;
}
message HelloRequest {
string cluster_id = 1;
string client_version = 2;
}
message RedirectMessage {
string endpoint = 1;
}
message HelloResponse {
optional RedirectMessage redirect = 1;
bytes client_ip = 2;
}
message AffiliateUpdateRequest {
string cluster_id = 1;
string affiliate_id = 2;
optional bytes affiliate_data = 3;
repeated bytes affiliate_endpoints = 4;
google.protobuf.Duration ttl = 5;
}
message AffiliateUpdateResponse {
}
message AffiliateDeleteRequest {
string cluster_id = 1;
string affiliate_id = 2;
}
message AffiliateDeleteResponse {
}
message ListRequest {
string cluster_id = 1;
}
message ListResponse {
repeated Affiliate affiliates = 1;
}
message WatchRequest {
string cluster_id = 1;
}
message WatchResponse {
repeated Affiliate affiliates = 1;
bool deleted = 2;
}
EOF
$ grpcurl -proto cluster_grpc.proto -import-path ./proto -plaintext -d '{"clusterId": "abc", "clientVersion": "v11.0"}' -H 'X-Real-IP: 1.2.3.4' 192.168.1.1:3000 sidero.discovery.server.Cluster/Hello

Примерный вывод:

text
{
  "redirect": {},
  "clientIp": "AQIDBA=="
}

Далее переходим к настройке кластера

Опубликовано под лицензией GPL-3.0+. Содержание доступно по лицензии CC BY-SA 4.0, если не указано иное. Разработано участниками ALT Orchestra.