This repository has been archived by the owner on Aug 1, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 66
PMM-7925: Add SystemD service with podman to run PMM #355
Open
denisok
wants to merge
7
commits into
main
Choose a base branch
from
PMM-7925-podman-support
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
dcff6ec
adding systemd service to run podman
a2975df
add user service
a3b0e90
fix user service
971b939
fix duplicate env
1f25ea9
add package dependencies
1c8eacc
Skip healthchecks for pmm-server-user.service
cezmunsta 5a1d16e
Merge branch 'main' into PMM-7925-podman-support
denisok File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
[Unit] | ||
Description=pmm-server | ||
Wants=network-online.target | ||
After=network-online.target | ||
After=nss-user-lookup.target nss-lookup.target | ||
After=time-sync.target | ||
|
||
[Service] | ||
Type=simple | ||
|
||
# set environment for this unit | ||
Environment=PMM_PUBLIC_PORT=8443 | ||
Environment=PMM_VOLUME_NAME=%N | ||
Environment=PMM_TAG=2.27.0 | ||
Environment=PMM_IMAGE=docker.io/percona/pmm-server | ||
Environment=PMM_ENV_FILE=%h/.config/pmm-server/pmm-server.env | ||
|
||
# optional env file that could overide previous env settings for this unit | ||
EnvironmentFile=-%h/.config/pmm-server/env | ||
|
||
ExecStartPre=/usr/bin/bash -c '/usr/bin/podman stop -t 10 %N; /usr/bin/podman rm -f %N || true' | ||
ExecStart=/usr/bin/podman run --rm --name %N -p ${PMM_PUBLIC_PORT}:443/tcp --ulimit=host --volume=${PMM_VOLUME_NAME}:/srv --env-file=${PMM_ENV_FILE} --health-cmd=none --health-interval=disable ${PMM_IMAGE}:${PMM_TAG} | ||
ExecStop=/usr/bin/podman stop -t 10 %N | ||
ExecStopPost=/usr/bin/podman stop -t 10 `%N` | ||
Restart=on-failure | ||
RestartSec=20 | ||
|
||
[Install] | ||
WantedBy=default.target |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
# env file passed to the container | ||
# full list of environment variables: | ||
# https://www.percona.com/doc/percona-monitoring-and-management/2.x/setting-up/server/docker.html#environment-variables | ||
|
||
# keep updates disabled | ||
# do image replacement instead (update the tag and restart the service) | ||
DISABLE_UPDATES=1 | ||
|
||
# Enable DBaaS feature | ||
#ENABLE_DBAAS=1 | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
[Unit] | ||
Description=pmm-server | ||
Wants=network-online.target | ||
After=network-online.target | ||
After=nss-user-lookup.target nss-lookup.target | ||
After=time-sync.target | ||
|
||
[Service] | ||
Type=simple | ||
User=pmm-server | ||
Group=pmm | ||
|
||
# set environment for this unit | ||
Environment=PMM_PUBLIC_PORT=8443 | ||
Environment=PMM_VOLUME_NAME=%N | ||
Environment=PMM_TAG=2.27.0 | ||
Environment=PMM_IMAGE=docker.io/percona/pmm-server | ||
Environment=PMM_ENV_FILE=%E/pmm-server/pmm-server.env | ||
|
||
# optional env file that could overide previous env settings for this unit | ||
EnvironmentFile=-%E/pmm-server/env | ||
|
||
ExecStartPre=/usr/bin/bash -c '/usr/bin/podman stop -t 10 %N; /usr/bin/podman rm -f %N || true' | ||
ExecStart=/usr/bin/podman run --rm --name %N -p ${PMM_PUBLIC_PORT}:443/tcp --ulimit=host --volume=${PMM_VOLUME_NAME}:/srv --env-file=${PMM_ENV_FILE} ${PMM_IMAGE}:${PMM_TAG} | ||
ExecStop=/usr/bin/podman stop -t 10 %N | ||
ExecStopPost=/usr/bin/podman stop -t 10 `%N` | ||
Restart=on-failure | ||
RestartSec=20 | ||
|
||
[Install] | ||
WantedBy=multi-user.target |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,15 +10,15 @@ | |
%define release 26 | ||
%define rpm_release %{release}.%{build_timestamp}.%{shortcommit}%{?dist} | ||
|
||
Name: %{repo} | ||
Version: %{version} | ||
Release: %{rpm_release} | ||
Summary: Percona Monitoring and Management Server | ||
Name: %{repo} | ||
Version: %{version} | ||
Release: %{rpm_release} | ||
Summary: Percona Monitoring and Management Server | ||
|
||
License: AGPLv3 | ||
URL: https://%{provider} | ||
Source0: https://%{provider}/archive/%{commit}/%{repo}-%{shortcommit}.tar.gz | ||
Source1: https://%{pmm_provider}/archive/%{pmm_commit}/%{pmm_repo}-%{pmm_shortcommit}.tar.gz | ||
License: AGPLv3 | ||
URL: https://%{provider} | ||
Source0: https://%{provider}/archive/%{commit}/%{repo}-%{shortcommit}.tar.gz | ||
Source1: https://%{pmm_provider}/archive/%{pmm_commit}/%{pmm_repo}-%{pmm_shortcommit}.tar.gz | ||
|
||
BuildArch: noarch | ||
BuildRequires: openssl | ||
|
@@ -27,6 +27,22 @@ BuildRequires: openssl | |
Percona Monitoring and Management (PMM) Server. | ||
See the PMM docs for more information. | ||
|
||
%package systemd | ||
Version: %{version} | ||
Release: %{rpm_release} | ||
Summary: SystemD service for Percona Monitoring and Management Server | ||
|
||
License: AGPLv3 | ||
URL: https://%{provider} | ||
|
||
BuildArch: noarch | ||
Requires: podman systemd shadow-utils | ||
BuildRequires: systemd-rpm-macros | ||
|
||
%description systemd | ||
SystemD service to run Percona Monitoring and Management (PMM) Server. | ||
It runs podman to manage PMM. | ||
See the PMM docs for more information. | ||
|
||
%prep | ||
%setup -q -n %{repo}-%{commit} | ||
|
@@ -51,6 +67,32 @@ cp -pav ./installation-wizard/build %{buildroot}%{_datadir}/%{name}/installation | |
cp -pav ./%{pmm_repo}-%{pmm_commit}/api/swagger %{buildroot}%{_datadir}/%{name}/swagger | ||
rm -rf %{pmm_repo}-%{pmm_commit} | ||
|
||
# pmm-server-systemd package | ||
install -D -m 0644 pmm-server.service %{buildroot}/%{_unitdir}/pmm-server.service | ||
install -D -p -m 0644 pmm-server.env %{buildroot}/%{_sysconfdir}/%{repo}/pmm-server.env | ||
|
||
%pre systemd | ||
|
||
# use newusers util to create user and group to assign subuid/subguid | ||
# newusers pw_name:pw_passwd:pw_uid:pw_gid:pw_gecos:pw_dir:pw_shel | ||
getent passwd pmm-server >/dev/null >/dev/null || echo "pmm-server:::pmm::/home/pmm-server:/bin/false" | %{_sbindir}/newusers | ||
%{_bindir}/loginctl enable-linger pmm-server | ||
|
||
%post systemd | ||
%systemd_post pmm-server.service | ||
%{_bindir}/systemctl enable pmm-server >/dev/null 2>&1 || true | ||
|
||
%preun systemd | ||
%systemd_preun pmm-server.service | ||
|
||
%postun systemd | ||
%systemd_postun_with_restart pmm-server.service | ||
if [ $1 == 0 ]; then | ||
# This is a yum remove. | ||
%{_bindir}/loginctl terminate-user pmm-server || true | ||
getent passwd pmm-server >/dev/null && %{_sbindir}/userdel pmm-server | ||
getent group pmm >/dev/null && %{_sbindir}/groupdel pmm | ||
fi | ||
|
||
%files | ||
%license LICENSE | ||
|
@@ -59,8 +101,18 @@ rm -rf %{pmm_repo}-%{pmm_commit} | |
%{_sysconfdir}/alertmanager.yml | ||
%{_datadir}/%{name} | ||
|
||
%files systemd | ||
%license LICENSE | ||
%doc README.md CHANGELOG.md | ||
%{_sysconfdir}/%{repo} | ||
%config(noreplace) %{_sysconfdir}/%{repo}/pmm-server.env | ||
%{_unitdir}/pmm-server.service | ||
|
||
%changelog | ||
|
||
* Tue May 31 2022 Denys Kondratenko <denys.kondratenko@percona.com> - 2.29.0-2 | ||
- PMM-7925 add systemd service with podman support | ||
|
||
* Mon May 16 2022 Nikita Beletskii <nikita.beletskii@percona.com> - 2.29.0-1 | ||
- PMM-10027 remove useless packages | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why do we use this spec? We use this spec for internal pmm-server package (it contains some js files) and I'm not sure that we need systemd service in container :) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. it was easier for PoC to use existing spec. And actually it fits it well in term that is a part of pmm-server. We don't need it in container for sure, but probably after build we need to sync it into some repo that available for everyone. |
||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we split environment variables between this file and service?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
service has environment for systemd/podman and env file is passed to pmm.
It is not split, it just another file to pass to env to pmm