Skip to content

Commit e51596d

Browse files
authored
Merge pull request #7 from ruby-no-kai/kea-2-7-5
install kea from official repo
2 parents 8804bcc + 837a2b0 commit e51596d

File tree

5 files changed

+129
-6
lines changed

5 files changed

+129
-6
lines changed

kea/Dockerfile

Lines changed: 45 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,21 @@ RUN --mount=type=cache,dst=/build/stork/tools \
3434

3535
###
3636

37+
FROM $BASE as bundler
38+
RUN apt-get update \
39+
&& DEBIAN_FRONTEND=noninteractive apt-get install -y \
40+
ruby \
41+
ruby-bundler
42+
COPY Gemfile* /app/
43+
ENV BUNDLE_GEMFILE /app/Gemfile
44+
ENV BUNDLE_PATH /app/vendor/bundle
45+
ENV BUNDLE_DEPLOYMENT 1
46+
ENV BUNDLE_JOBS 16
47+
ENV BUNDLE_WITHOUT development:test
48+
RUN bundle install
49+
50+
###
51+
3752
FROM --platform=$BUILDPLATFORM $BASE as config
3853
RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y jsonnet
3954
WORKDIR /app
@@ -44,22 +59,46 @@ RUN jsonnet /tmp/kea-ctrl-agent.jsonnet > /app/kea-ctrl-agent.json
4459

4560
FROM $BASE
4661

47-
RUN mkdir -p /run/kea /app
62+
RUN mkdir -p /run/kea /app /etc/apt/keyrings
63+
RUN rm -fv /etc/apt/apt.conf.d/docker-clean
4864
VOLUME /run/kea
4965

50-
RUN apt-get update \
66+
RUN --mount=type=cache,target=/var/cache/apt --mount=type=cache,target=/var/lib/apt/lists apt-get update \
5167
&& DEBIAN_FRONTEND=noninteractive apt-get install -y \
68+
curl \
5269
ca-certificates \
5370
dumb-init \
54-
ruby \
71+
ruby ruby-bundler \
5572
iproute2 \
56-
kea \
57-
mysql-client \
58-
&& apt-get clean && rm -rf /var/lib/apt/lists/*
73+
mysql-client
74+
75+
ARG kea_version 2.7.6-isc20250128083638
76+
COPY kea-dev.asc /etc/apt/keyrings/kea-dev.asc
77+
RUN echo "deb [signed-by=/etc/apt/keyrings/kea-dev.asc] https://dl.cloudsmith.io/public/isc/kea-dev/deb/ubuntu noble main" > /etc/apt/sources.list.d/kea.list
78+
RUN echo "Package: src:isc-kea\nPin: version ${kea_version}\nPin-Priority: 999" > /etc/apt/preferences.d/pin-kea
79+
RUN --mount=type=cache,target=/var/cache/apt --mount=type=cache,target=/var/lib/apt/lists apt-get update \
80+
&& DEBIAN_FRONTEND=noninteractive apt-get install -y \
81+
isc-kea-dhcp4-server \
82+
isc-kea-mysql \
83+
isc-kea-ctrl-agent \
84+
isc-kea-admin \
85+
isc-kea-hooks
5986

6087
COPY --from=build-healthz /app/bin/healthz /app/healthzd
6188
COPY --from=build-stork /build/go/bin/stork-agent /app/stork-agent
89+
90+
COPY Gemfile* /app/
91+
COPY --from=bundler /app/vendor/bundle /app/vendor/bundle
92+
ENV BUNDLE_GEMFILE /app/Gemfile
93+
ENV BUNDLE_PATH /app/vendor/bundle
94+
ENV BUNDLE_DEPLOYMENT 1
95+
ENV BUNDLE_JOBS 16
96+
ENV BUNDLE_WITHOUT development:test
97+
98+
RUN ln -s /usr/lib/$(uname -m)-linux-gnu/kea/hooks /app/kea-hooks
99+
62100
COPY run.sh /app/run.sh
101+
COPY db-upgrade.rb /app/db-upgrade.rb
63102
COPY choose_dhcp_server_id.rb /app/choose_dhcp_server_id.rb
64103
COPY --from=config /app/kea-ctrl-agent.json /app/kea-ctrl-agent.json
65104

kea/Gemfile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
source 'https://rubygems.org'
2+
gem 'aws-sdk-rds'
3+
gem 'rexml'

kea/Gemfile.lock

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
GEM
2+
remote: https://rubygems.org/
3+
specs:
4+
aws-eventstream (1.3.2)
5+
aws-partitions (1.1065.0)
6+
aws-sdk-core (3.220.1)
7+
aws-eventstream (~> 1, >= 1.3.0)
8+
aws-partitions (~> 1, >= 1.992.0)
9+
aws-sigv4 (~> 1.9)
10+
base64
11+
jmespath (~> 1, >= 1.6.1)
12+
aws-sdk-rds (1.272.0)
13+
aws-sdk-core (~> 3, >= 3.216.0)
14+
aws-sigv4 (~> 1.5)
15+
aws-sigv4 (1.11.0)
16+
aws-eventstream (~> 1, >= 1.0.2)
17+
base64 (0.2.0)
18+
jmespath (1.6.2)
19+
rexml (3.4.1)
20+
21+
PLATFORMS
22+
ruby
23+
24+
DEPENDENCIES
25+
aws-sdk-rds
26+
rexml
27+
28+
BUNDLED WITH
29+
2.6.3

kea/db-upgrade.rb

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
#!/usr/bin/env ruby
2+
require 'bundler/setup'
3+
require 'aws-sdk-rds'
4+
require 'open-uri'
5+
require 'resolv'
6+
7+
REGION = ENV.fetch('AWS_REGION')
8+
File.write '/app/rds-ca-bundle.pem', URI.open("https://truststore.pki.rds.amazonaws.com/#{REGION}/#{REGION}-bundle.pem", 'r', &:read)
9+
@auth = Aws::RDS::AuthTokenGenerator.new(credentials: Aws::CredentialProviderChain.new.resolve)
10+
11+
def run(host:, name:)
12+
actual_host = Resolv::DNS.new.getresource(host, Resolv::DNS::Resource::IN::CNAME).name.to_s rescue host
13+
user_name = ENV.fetch('KEA_ADMIN_DB_USER')
14+
token = @auth.generate_auth_token(region: REGION, endpoint: "#{actual_host}:3306", expires_in: 900, user_name: user_name)
15+
ENV['KEA_ADMIN_DB_PASSWORD'] = token
16+
puts ">>>> kea-admin db-upgrade mysql -n #{name} -h #{actual_host}"
17+
system(
18+
*%w(kea-admin db-upgrade mysql),
19+
'-h', actual_host,
20+
'-u', user_name,
21+
'-n', name,
22+
'-x', "--enable-cleartext-plugin --ssl-ca /app/rds-ca-bundle.pem",
23+
exception: true
24+
)
25+
end
26+
27+
run(host: ENV.fetch('LEASE_DATABASE_HOST'), name: ENV.fetch('LEASE_DATABASE_NAME'))
28+
run(host: ENV.fetch('HOSTS_DATABASE_HOST'), name: ENV.fetch('HOSTS_DATABASE_NAME'))

kea/kea-dev.asc

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
-----BEGIN PGP PUBLIC KEY BLOCK-----
2+
3+
mQGNBGY+M8YBDADAXYjQZhp0g7VfmetzQl+Bk4KW6KvGK3btt1mMvnZHO6GFvNnF
4+
7UFgfW637h3DR4SMQDFpcGisqCfDC8lQMiLJHdTDt8SJDZhFCME69QxP/++esj1a
5+
ey+jln7YaOPfCkvPjAx0Hesdzbqb2hdBUmRJV7V5PMvI293Yzr7qeTptwfacQF9x
6+
ROFi5ZTQLEcCznqKBFpdo73uRcmfAwCSt8td1Qxf86ORW1uAvEBLMDco8c6PBQvx
7+
E3VTyEg08aToawSHy8Eqzkib9UWhWlm8v5pAgVm8gECg3ZhdKHCymbBE5usPbc4V
8+
iGS3zrXxCgUK4YPNjsRP1djIQ43KQIJCE8W8ud4jB1WyUkOhaMVvSEmTy0jcX4x/
9+
WVsVvx0Ow5HYbwaaaTjnbOq4tYJPDEaB8G//57cj9Jb1cNRyKCKm3OXOcxvKbDOC
10+
mL85IAeI4uMlE9Zrw3tV3b0t4JcCAU/zycnGhx3ZAe6nNlNdVuteLJd9gfeOX3YK
11+
HyZIGL0vWyJXm6UAEQEAAbQ4Q2xvdWRzbWl0aCBQYWNrYWdlIChpc2Mva2VhLWRl
12+
dikgPHN1cHBvcnRAY2xvdWRzbWl0aC5pbz6JAc4EEwEIADgWIQSRetkKdbDgvWcS
13+
onGYy1lOwOxtOgUCZj4zxgIbLwULCQgHAwUVCgkICwUWAgMBAAIeAQIXgAAKCRCY
14+
y1lOwOxtOqQJDACNoFvdUgdxHLIpbmOhJtAvfAEU3SxxAE94asLyWxJA26Yi7WGt
15+
XN8Ibrn82hS72AhNrAEwQBQ1YMzw/bYkNOJlsXHw19xKCpm4o6XItA7dXGvVlGY4
16+
Gmr7FDErBK3c6m+MnlWHI5/nCM1uL7ipwBK7QyU+jwITj9Sh0r0mDGzKr/u9Ezk7
17+
PPIeEmadMcfCtKN7ewyt/fpuu/yuiLlN8hBWfKS3dCTkzhiQ4ey9sNvy0HSvRfBw
18+
/GSsgu/016Kr2LomFpZGVHAqQSj4p0g2zCj6YTxTg6maecZFTfJAQZrFgnxsY0KI
19+
VF4Tvwch2VlttHARd+dOzBUsqlF+iXqIsFp5fcR8uMiJIRH3jHj7WmZ1oRxNuwWz
20+
t20jJ/5ecrNvhd+7Mg6qlkl5eW/Td17CPG4qmlNCPX61YYHKXTFkYiP2M8DzfLTf
21+
zix3xlJaMy33PZUpIDKo6PkNC97Wjo42QjwtrNVZgJxyMt8wP25ikjouF/xtJLWH
22+
h/TV/q2XXSAJf6k=
23+
=CXSr
24+
-----END PGP PUBLIC KEY BLOCK-----

0 commit comments

Comments
 (0)