Skip to content

Commit

Permalink
static-pods: move to own package and include in kubernetes-*
Browse files Browse the repository at this point in the history
  • Loading branch information
jmt-lab committed Apr 18, 2024
1 parent e54e518 commit 6ed54fa
Show file tree
Hide file tree
Showing 23 changed files with 104 additions and 20 deletions.
1 change: 1 addition & 0 deletions packages/kubernetes-1.23/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ glibc = { path = "../glibc" }
[dependencies]
aws-signing-helper = { path = "../aws-signing-helper" }
ecr-credential-provider = { path = "../ecr-credential-provider" }
static-pods = { path = "../static-pods" }
# `conntrack-tools`, `containerd` and `findutils` are only needed at runtime,
# and are pulled in by `release`.
# conntrack-tools = { path = "../conntrack-tools" }
Expand Down
1 change: 1 addition & 0 deletions packages/kubernetes-1.23/kubernetes-1.23.spec
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ Requires: %{_cross_os}containerd
Requires: %{_cross_os}findutils
Requires: %{_cross_os}ecr-credential-provider
Requires: %{_cross_os}aws-signing-helper
Requires: %{_cross_os}static-pods

%description -n %{_cross_os}kubelet-1.23
%{summary}.
Expand Down
1 change: 1 addition & 0 deletions packages/kubernetes-1.24/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ glibc = { path = "../glibc" }
[dependencies]
aws-signing-helper = { path = "../aws-signing-helper" }
ecr-credential-provider = { path = "../ecr-credential-provider" }
static-pods = { path = "../static-pods" }
# `conntrack-tools`, `containerd` and `findutils` are only needed at runtime,
# and are pulled in by `release`.
# conntrack-tools = { path = "../conntrack-tools" }
Expand Down
1 change: 1 addition & 0 deletions packages/kubernetes-1.24/kubernetes-1.24.spec
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ Requires: %{_cross_os}containerd
Requires: %{_cross_os}findutils
Requires: %{_cross_os}ecr-credential-provider
Requires: %{_cross_os}aws-signing-helper
Requires: %{_cross_os}static-pods

%description -n %{_cross_os}kubelet-1.24
%{summary}.
Expand Down
1 change: 1 addition & 0 deletions packages/kubernetes-1.25/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ glibc = { path = "../glibc" }
[dependencies]
aws-signing-helper = { path = "../aws-signing-helper" }
ecr-credential-provider = { path = "../ecr-credential-provider" }
static-pods = { path = "../static-pods" }
# `conntrack-tools`, `containerd` and `findutils` are only needed at runtime,
# and are pulled in by `release`.
# conntrack-tools = { path = "../conntrack-tools" }
Expand Down
1 change: 1 addition & 0 deletions packages/kubernetes-1.25/kubernetes-1.25.spec
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ Requires: %{_cross_os}containerd
Requires: %{_cross_os}findutils
Requires: %{_cross_os}ecr-credential-provider
Requires: %{_cross_os}aws-signing-helper
Requires: %{_cross_os}static-pods

%description -n %{_cross_os}kubelet-1.25
%{summary}.
Expand Down
1 change: 1 addition & 0 deletions packages/kubernetes-1.26/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ glibc = { path = "../glibc" }
[dependencies]
aws-signing-helper = { path = "../aws-signing-helper" }
ecr-credential-provider = { path = "../ecr-credential-provider" }
static-pods = { path = "../static-pods" }
# `conntrack-tools`, `containerd` and `findutils` are only needed at runtime,
# and are pulled in by `release`.
# conntrack-tools = { path = "../conntrack-tools" }
Expand Down
1 change: 1 addition & 0 deletions packages/kubernetes-1.26/kubernetes-1.26.spec
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ Requires: %{_cross_os}containerd
Requires: %{_cross_os}findutils
Requires: %{_cross_os}ecr-credential-provider
Requires: %{_cross_os}aws-signing-helper
Requires: %{_cross_os}static-pods

%description -n %{_cross_os}kubelet-1.26
%{summary}.
Expand Down
1 change: 1 addition & 0 deletions packages/kubernetes-1.27/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ glibc = { path = "../glibc" }
[dependencies]
aws-signing-helper = { path = "../aws-signing-helper" }
ecr-credential-provider-1_27 = { path = "../ecr-credential-provider-1.27" }
static-pods = { path = "../static-pods" }
# `conntrack-tools`, `containerd` and `findutils` are only needed at runtime,
# and are pulled in by `release`.
# conntrack-tools = { path = "../conntrack-tools" }
Expand Down
1 change: 1 addition & 0 deletions packages/kubernetes-1.27/kubernetes-1.27.spec
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ Requires: %{_cross_os}containerd
Requires: %{_cross_os}findutils
Requires: %{_cross_os}ecr-credential-provider-1.27
Requires: %{_cross_os}aws-signing-helper
Requires: %{_cross_os}static-pods

%description -n %{_cross_os}kubelet-1.27
%{summary}.
Expand Down
1 change: 1 addition & 0 deletions packages/kubernetes-1.28/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ glibc = { path = "../glibc" }
[dependencies]
aws-signing-helper = { path = "../aws-signing-helper" }
ecr-credential-provider-1_27 = { path = "../ecr-credential-provider-1.27" }
static-pods = { path = "../static-pods" }
# `conntrack-tools`, `containerd` and `findutils` are only needed at runtime,
# and are pulled in by `release`.
# conntrack-tools = { path = "../conntrack-tools" }
Expand Down
1 change: 1 addition & 0 deletions packages/kubernetes-1.28/kubernetes-1.28.spec
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ Requires: %{_cross_os}containerd
Requires: %{_cross_os}findutils
Requires: %{_cross_os}ecr-credential-provider-1.27
Requires: %{_cross_os}aws-signing-helper
Requires: %{_cross_os}static-pods

%description -n %{_cross_os}kubelet-1.28
%{summary}.
Expand Down
1 change: 1 addition & 0 deletions packages/kubernetes-1.29/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ glibc = { path = "../glibc" }
[dependencies]
aws-signing-helper = { path = "../aws-signing-helper" }
ecr-credential-provider-1_29 = { path = "../ecr-credential-provider-1.29" }
static-pods = { path = "../static-pods" }
# `conntrack-tools`, `containerd` and `findutils` are only needed at runtime,
# and are pulled in by `release`.
# conntrack-tools = { path = "../conntrack-tools" }
Expand Down
1 change: 1 addition & 0 deletions packages/kubernetes-1.29/kubernetes-1.29.spec
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ Requires: %{_cross_os}containerd
Requires: %{_cross_os}findutils
Requires: %{_cross_os}ecr-credential-provider-1.29
Requires: %{_cross_os}aws-signing-helper
Requires: %{_cross_os}static-pods

%description -n %{_cross_os}kubelet-1.29
%{summary}.
Expand Down
1 change: 1 addition & 0 deletions packages/kubernetes-1.30/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ glibc = { path = "../glibc" }
[dependencies]
aws-signing-helper = { path = "../aws-signing-helper" }
ecr-credential-provider-1_29 = { path = "../ecr-credential-provider-1.29" }
static-pods = { path = "../static-pods" }
# `conntrack-tools`, `containerd` and `findutils` are only needed at runtime,
# and are pulled in by `release`.
# conntrack-tools = { path = "../conntrack-tools" }
Expand Down
1 change: 1 addition & 0 deletions packages/kubernetes-1.30/kubernetes-1.30.spec
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ Requires: %{_cross_os}findutils
# TODO: update to ecr-credential-provider-1.30
Requires: %{_cross_os}ecr-credential-provider-1.29
Requires: %{_cross_os}aws-signing-helper
Requires: %{_cross_os}static-pods

%description -n %{_cross_os}kubelet-1.30
%{summary}.
Expand Down
18 changes: 0 additions & 18 deletions packages/os/os.spec
Original file line number Diff line number Diff line change
Expand Up @@ -108,10 +108,6 @@ Requires: %{_cross_os}updog
Requires: %{_cross_os}pluto
%endif

%if %{with k8s_runtime}
Requires: %{_cross_os}static-pods
%endif

%if %{with aws_platform}
Requires: %{_cross_os}shibaken
Requires: %{_cross_os}cfsignal
Expand Down Expand Up @@ -244,13 +240,6 @@ Summary: Dynamic setting generator for kubernetes
%{summary}.
%endif

%if %{with k8s_runtime}
%package -n %{_cross_os}static-pods
Summary: Manages user-defined K8S static pods
%description -n %{_cross_os}static-pods
%{summary}.
%endif

%if %{with aws_platform}
%package -n %{_cross_os}shibaken
Summary: Run tasks reliant on IMDS
Expand Down Expand Up @@ -384,7 +373,6 @@ echo "** Output from non-static builds:"
-p bloodhound \
-p xfscli \
%{?with_aws_platform: -p shibaken} \
%{?with_k8s_runtime: -p static-pods} \
%{?with_nvidia_flavor: -p driverdog} \
%{nil}

Expand Down Expand Up @@ -418,7 +406,6 @@ for p in \
ghostdog bootstrap-containers \
shimpei bloodhound bottlerocket-checks \
%{?with_aws_platform: shibaken} \
%{?with_k8s_runtime: static-pods} \
%{?with_nvidia_flavor: driverdog} \
; do
install -p -m 0755 ${HOME}/.cache/%{__cargo_target}/release/${p} %{buildroot}%{_cross_bindir}
Expand Down Expand Up @@ -699,11 +686,6 @@ install -p -m 0644 %{S:400} %{S:401} %{S:402} %{buildroot}%{_cross_licensedir}
%{_cross_datadir}/eks/eni-max-pods
%endif

%if %{with k8s_runtime}
%files -n %{_cross_os}static-pods
%{_cross_bindir}/static-pods
%endif

%files -n %{_cross_os}shimpei
%{_cross_bindir}/shimpei
%{_cross_templatedir}/oci-default-hooks-json
Expand Down
14 changes: 14 additions & 0 deletions packages/static-pods/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
[package]
name = "static-pods"
version = "0.1.0"
edition = "2021"
publish = false
build = "../build.rs"

[lib]
path = "../packages.rs"

[build-dependencies]
glibc = { path = "../glibc" }

[dependencies]
15 changes: 15 additions & 0 deletions packages/static-pods/static-pods-toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
[required-extensions]
kubernetes = "v1"
std = { version = "v1", helpers = ["if_not_null"] }
+++
{{#if_not_null settings.kubernetes.static-pods}}
{{#each settings.kubernetes.static-pods}}
["{{@key}}"]
{{#if_not_null this.enabled}}
enabled = {{this.enabled}}
{{/if_not_null}}
{{#if_not_null this.manifest}}
manifest = "{{{this.manifest}}}"
{{/if_not_null}}
{{/each}}
{{/if_not_null}}
38 changes: 38 additions & 0 deletions packages/static-pods/static-pods.spec
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
%global _cross_first_party 1
%undefine _debugsource_packages

Name: %{_cross_os}static-pods
Version: 0.0
Release: 0%{?dist}
Summary: Manages user-defined K*S static pods
License: Apache-2.0 OR MIT
URL: https://github.com/bottlerocket-os/bottlerocket

Source0: static-pods-toml

BuildRequires: %{_cross_os}glibc-devel

%description
%{summary}.

%prep
%setup -T -c
%cargo_prep

%build
mkdir bin

echo "** Compile static-pods agent"
%cargo_build --manifest-path %{_builddir}/sources/Cargo.toml \
-p static-pods

%install
install -d %{buildroot}%{_cross_bindir}
install -p -m 0755 ${HOME}/.cache/%{__cargo_target}/release/static-pods %{buildroot}%{_cross_bindir}

install -d %{buildroot}%{_cross_templatedir}
install -p -m 0644 %{S:0} %{buildroot}%{_cross_templatedir}

%files
%{_cross_bindir}/static-pods
%{_cross_templatedir}/static-pods-toml
2 changes: 1 addition & 1 deletion sources/api/static-pods/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ use std::process;
use std::str::FromStr;
use tempfile::{NamedTempFile, TempDir};

const DEFAULT_CONFIG_PATH: &str = "/etc/kubernetes/static-pods.toml";
const DEFAULT_CONFIG_PATH: &str = "/etc/kubernetes/static-pods-manifest.toml";
const STATIC_POD_DIR: &str = "/etc/kubernetes/static-pods";
const ETC_KUBE_DIR: &str = "/etc/kubernetes";

Expand Down
6 changes: 5 additions & 1 deletion sources/models/shared-defaults/kubernetes-services.toml
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,12 @@ path = "/etc/kubernetes/kubelet/credential-provider-config.yaml"
template-path = "/usr/share/templates/credential-provider-config-yaml"
mode = "0600"

[configuration-files.static-pods-toml]
path = "/etc/kubernetes/static-pods-manifest.toml"
template-path = "/usr/share/templates/static-pods-toml"

[services.static-pods]
configuration-files = []
configuration-files = ["static-pods-toml"]
restart-commands = ["/usr/bin/static-pods"]

[metadata.settings.kubernetes.static-pods]
Expand Down
15 changes: 15 additions & 0 deletions variants/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 6ed54fa

Please sign in to comment.