This repository was archived by the owner on Aug 1, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 65
PMM-8306 migrate ami ova to docker #343
Open
nikita-b
wants to merge
32
commits into
main
Choose a base branch
from
PMM-8306-migrate-ami-ova-to-docker
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
32 commits
Select commit
Hold shift + click to select a range
47acb9d
PMM-8306 migrate AMI/OVA to Docker container
nikita-b ab24578
PMM-8306 Migrate AMI to Docker container
nikita-b 44d9c5b
add variables and disk
nikita-b dc9092e
Update packer/ansible/roles/lvm-init/tasks/main.yml
nikita-b 4892770
comments from Alex
nikita-b 5b22e80
Merge branch 'PMM-8306-migrate-ami-ova-to-docker' of github.com:perco…
nikita-b f2892b6
fix
nikita-b e1935f5
fix disk size and AMI setup
nikita-b 4865806
add ovf and banner
nikita-b 604324d
change makefile
nikita-b 6ef0346
add admin to docker
nikita-b fe874e4
fix parameters
nikita-b 71578ff
Merge branch 'main' of github.com:percona/pmm-server into PMM-8306-mi…
nikita-b a5fd553
fix
nikita-b 2013c6a
fix
nikita-b c2493b8
use oraclelinux
nikita-b 2d4b981
fix
nikita-b 297ec1c
fix
nikita-b 7af4c82
fix
nikita-b afb8270
fix
nikita-b 2a2120d
fix
nikita-b a1befb8
fix
nikita-b d45f921
gix
nikita-b 2ad5108
fix
nikita-b 427fd80
fix
nikita-b 9cf76e1
rollback
nikita-b b32bdeb
add OVF again
nikita-b 5f9848b
fix
nikita-b 69a1db2
fix
nikita-b d8110e2
fix
nikita-b 220a411
fix
nikita-b 449c375
fix
nikita-b 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 hidden or 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
File renamed without changes.
This file contains hidden or 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,6 @@ | ||
| { | ||
| "experimental": true, | ||
| "max-concurrent-downloads": 9, | ||
| "max-concurrent-uploads": 15, | ||
| "storage-driver": "overlay2" | ||
| } |
File renamed without changes.
This file contains hidden or 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,207 @@ | ||
| --- | ||
| - name: Create PMM2 image | ||
| hosts: default | ||
| become: yes | ||
| become_user: root | ||
| roles: | ||
| - lvm-init | ||
| tasks: | ||
| - name: Install packages | ||
| package: | ||
| name: | ||
| - docker | ||
| - python3-pip | ||
| - python3 | ||
| - lvm2 | ||
| - jq | ||
|
|
||
| - name: Install docker Python API | ||
| pip: | ||
| name: docker | ||
|
|
||
| - name: Enable Docker service | ||
| systemd: | ||
| name: docker.service | ||
| state: started | ||
| enabled: yes | ||
|
|
||
| - name: Add admin user | ||
| user: | ||
| name: admin | ||
| comment: PMM User | ||
| groups: wheel,adm,systemd-journal,docker | ||
| shell: /bin/bash | ||
|
|
||
| - name: Add sudo for admin user | ||
| copy: | ||
| content: | | ||
| admin ALL=(ALL) NOPASSWD: ALL | ||
| dest: /etc/sudoers.d/90-admin-user | ||
| mode: 0440 | ||
|
|
||
| - name: change cloud user | Change cloud user | ||
| replace: | ||
| dest: /etc/cloud/cloud.cfg | ||
| regexp: 'name: ec2-user' | ||
| replace: 'name: admin' | ||
|
|
||
| - name: Turn off swap | ||
| sysctl: | ||
| name: vm.swappiness | ||
| value: 0 | ||
| state: present | ||
|
|
||
| - name: Increase dirty ratio | ||
| sysctl: | ||
| name: vm.dirty_ratio | ||
| value: 80 | ||
| state: present | ||
|
|
||
| - name: Decrease dirty_background_ratio | ||
| sysctl: | ||
| name: vm.dirty_background_ratio | ||
| value: 5 | ||
|
|
||
| - name: Increase dirty_expire_centisecs | ||
| sysctl: | ||
| name: vm.dirty_expire_centisecs | ||
| value: 12000 #120 sec | ||
|
|
||
| - name: Increase net.core.somaxconn | ||
| sysctl: | ||
| name: net.core.somaxconn | ||
| value: 1024 | ||
|
|
||
| - name: Increase net.core.netdev_max_backlog | ||
| sysctl: | ||
| name: net.core.netdev_max_backlog | ||
| value: 5000 | ||
|
|
||
| - name: Increase net.core.rmem_max | ||
| sysctl: | ||
| name: net.core.rmem_max | ||
| value: 16777216 | ||
|
|
||
| - name: Increase net.core.wmem_max | ||
| sysctl: | ||
| name: net.core.wmem_max | ||
| value: 16777216 | ||
|
|
||
| - name: Increase net.ipv4.tcp_wmem | ||
| sysctl: | ||
| name: net.ipv4.tcp_wmem | ||
| value: 4096 12582912 16777216 | ||
|
|
||
| - name: Increase net.ipv4.tcp_rmem | ||
| sysctl: | ||
| name: net.ipv4.tcp_rmem | ||
| value: 4096 12582912 16777216 | ||
|
|
||
| - name: Increase net.ipv4.tcp_max_syn_backlog | ||
| sysctl: | ||
| name: net.ipv4.tcp_max_syn_backlog | ||
| value: 8192 | ||
|
|
||
| - name: Disable net.ipv4.tcp_slow_start_after_idle | ||
| sysctl: | ||
| name: net.ipv4.tcp_slow_start_after_idle | ||
| value: 0 | ||
|
|
||
| - name: Enable net.ipv4.tcp_tw_reuse | ||
| sysctl: | ||
| name: net.ipv4.tcp_tw_reuse | ||
| value: 1 | ||
|
|
||
| - name: Change net.ipv4.ip_local_port_range | ||
| sysctl: | ||
| name: net.ipv4.ip_local_port_range | ||
| value: 10240 65535 | ||
|
|
||
| - name: Change TCP Congestion Control Algorithm (net.ipv4.tcp_congestion_control) | ||
| sysctl: | ||
| name: net.ipv4.tcp_congestion_control | ||
| value: bbr | ||
|
|
||
| - name: Change net.ipv4.tcp_syn_retries | ||
| sysctl: | ||
| name: net.ipv4.tcp_syn_retries | ||
| value: 2 | ||
|
|
||
| - name: Change BBR algoritm | ||
| sysctl: | ||
| name: net.core.default_qdisc | ||
| value: fq | ||
|
|
||
| - name: Increase kernel.perf_event_max_stack | ||
| sysctl: | ||
| name: kernel.perf_event_max_stack | ||
| value: 1023 | ||
|
|
||
| - name: Increase fs.xfs.xfssyncd_centisecs | ||
| sysctl: | ||
| name: fs.xfs.xfssyncd_centisecs | ||
| value: 9000 | ||
|
|
||
| - name: Increase fs.inotify.max_user_watches | ||
| sysctl: | ||
| name: fs.inotify.max_user_watches | ||
| value: 1048576 | ||
|
|
||
| - name: pull the PMM image | ||
| docker_image: | ||
| name: "{{ pmm_server_image_name }}" | ||
| source: pull | ||
|
|
||
| - name: get srv directory path | ||
| shell: docker image inspect {{ pmm_server_image_name }} | jq -r .[0].GraphDriver.Data.UpperDir | ||
| register: image_path | ||
|
|
||
| - name: | ||
| copy: | ||
| src: "{{ image_path.stdout }}/srv/" | ||
| dest: /srv/ | ||
| mode: preserve | ||
| remote_src: yes | ||
|
|
||
| - name: Copy content of 'srv' directory from image | ||
| synchronize: | ||
| src: "{{ image_path.stdout }}/srv/" | ||
| dest: /srv/ | ||
| recursive: yes | ||
| delegate_to: "{{ inventory_hostname }}" | ||
|
|
||
| - name: Set AMI distribution | ||
| copy: | ||
| content: | | ||
| ami | ||
| dest: /srv/pmm-distribution | ||
|
|
||
| - name: Add script which show PMM URL | ||
| copy: | ||
| src: pmm/show-url | ||
| dest: /opt/show-url | ||
| mode: 0755 | ||
|
|
||
| - name: Add Service for script which show PMM URL | ||
| copy: | ||
| src: banner.service | ||
| dest: /etc/systemd/system/banner.service | ||
| mode: 0755 | ||
|
|
||
| - name: Enable PMM URL Service | ||
| systemd: | ||
| name: banner | ||
| state: started | ||
| enabled: yes | ||
|
|
||
| - name: Copy systemd service file to image | ||
| template: | ||
| src: pmm2.service | ||
| dest: /etc/systemd/system | ||
| owner: root | ||
| group: root | ||
|
|
||
| - name: Enable PMM2 container | ||
| systemd: | ||
| name: pmm2 | ||
| enabled: yes |
This file contains hidden or 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,52 @@ | ||
| --- | ||
| - name: Wait until disk is ready | ||
| wait_for: | ||
| path: /dev/sdb | ||
|
|
||
| - name: Create Volume Group | ||
| lvg: | ||
| vg: DataVG | ||
| pvs: /dev/sdb | ||
|
|
||
| - name: Create Thin Pool | ||
| register: thin_pool | ||
| failed_when: "thin_pool is failed and 'Sorry, no shrinking of DataLV to 0 permitted' not in thin_pool.msg" | ||
| lvol: | ||
| lv: DataLV | ||
| vg: DataVG | ||
| size: 100%FREE | ||
| opts: --thinpool ThinPool -V 1G | ||
|
|
||
| - name: Format LVM | ||
| filesystem: | ||
| fstype: xfs | ||
| dev: /dev/DataVG/DataLV | ||
| opts: -L DATA | ||
|
|
||
| - name: Mount | ||
| mount: | ||
| name: "/srv" | ||
| src: LABEL=DATA | ||
| fstype: xfs | ||
| opts: defaults | ||
| state: mounted | ||
|
|
||
| - name: Create dirs | Create dirs | ||
| file: path={{ item }} state=directory | ||
| with_items: | ||
| - /var/lib/cloud/scripts/per-boot | ||
|
|
||
| - name: Data partition | Auto resize LVM | ||
| template: | ||
| src: resize-xfs-lvm | ||
| dest: /var/lib/cloud/scripts/per-boot/resize-xfs | ||
| mode: 0755 | ||
|
|
||
| - name: Cron tasks | Add resize task to cron | ||
| cron: | ||
| name: "resize data partition" | ||
| minute: "*/5" | ||
| user: root | ||
| job: "/var/lib/cloud/scripts/per-boot/resize-xfs" | ||
| cron_file: resizeXfs | ||
|
|
||
This file contains hidden or 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,7 @@ | ||
| #!/bin/sh | ||
|
|
||
| /usr/sbin/pvresize $(/usr/bin/ls /dev/sda /dev/sdb /dev/xvdb 2>/dev/null | /usr/bin/grep -v ^$(/usr/sbin/pvdisplay -c | /usr/bin/grep ':VolGroup00:' | /usr/bin/cut -d ':' -f 1 | /usr/bin/tr -d '[:space:]' | /usr/bin/sed 's/[0-9]$//')$ | /usr/bin/grep -v ^$(/usr/bin/findmnt -f -n -o SOURCE / | /usr/bin/sed 's/[0-9]$//')$ | /usr/bin/grep -v ^$(/usr/bin/findmnt -f -n -o SOURCE /mnt/resource | /usr/bin/sed 's/[0-9]$//')$) | ||
| /usr/sbin/lvextend -l '1%VG' /dev/DataVG/ThinPool_tmeta | ||
| /usr/sbin/lvextend -l '100%VG' /dev/DataVG/ThinPool | ||
| /usr/sbin/lvextend -l '80%PVS' /dev/DataVG/DataLV | ||
| /usr/sbin/xfs_growfs -d /srv |
This file contains hidden or 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,16 @@ | ||
| [Unit] | ||
| Description=PMM2 Docker container | ||
| After=docker.service | ||
| Requires=docker.service | ||
|
|
||
| [Service] | ||
| TimeoutStartSec=0 | ||
| Restart=always | ||
| ExecStartPre=-/usr/bin/docker exec pmm-server stop | ||
|
Contributor
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. shouldn't it be just |
||
| ExecStartPre=-/usr/bin/docker rm pmm-server | ||
|
Contributor
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 remove pmm-server on each start? Looks like if the user upgrades PMM using the UI button and then restart the service, the service might use an incorrect image. |
||
| ExecStart=/usr/bin/docker run --volume /srv/:/srv/ --rm --name pmm-server \ | ||
| --net host \ | ||
| {{ pmm_server_image_name }} | ||
|
|
||
| [Install] | ||
| WantedBy=default.target | ||
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.