Skip to content

Commit 1f31a42

Browse files
authored
Refactored compose environment (#7)
* Refactored compose environment for running local with full cluster including pulp3 primary and secondary. Now `make demo`. Signed-off-by: Geoff Wilson <geoff@gr-oss.io>
1 parent 33b9131 commit 1f31a42

31 files changed

+1163
-435
lines changed

.devcontainer/docker-compose.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ services:
1515
DB_USER: pulp-manager
1616
DB_PASSWORD: pulp-manager
1717
JWT_SECRET: test_secret
18-
PULP_MANAGER_CONFIG_PATH: /workspace/local_config.ini
19-
PULP_SYNC_CONFIG_PATH: /workspace/local_pulp_config.yml
18+
PULP_MANAGER_CONFIG_PATH: /workspace/demo/config.ini
19+
PULP_SYNC_CONFIG_PATH: /workspace/demo/pulp-config.yml
2020
Is_local: "true"
2121
networks:
2222
- pulp-devcontainer-net

.devcontainer/test_config.ini

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
[database]
2+
user=pulp-manager
3+
password=pulp-manager
4+
host=mariadb
5+
port=3306
6+
db_name=pulp_manager
7+
8+
[auth]
9+
method=ldap
10+
use_ssl=false
11+
ldap_servers=server:389
12+
base_dn=ou=people,dc=pulpproject,dc=com
13+
default_domain=pulpproject.com
14+
jwt_algorithm=HS256
15+
jwt_token_lifetime_mins=480
16+
admin_group=pulpmaster-rw
17+
require_jwt_auth=false
18+
19+
[pulp]
20+
deb_signing_service=pulp_deb
21+
banned_package_regex=bannedexample|another
22+
internal_domains=pulp-primary,pulp-secondary
23+
git_repo_config=https://github.com/example/repo-config.git
24+
git_repo_config_dir=repo_config
25+
password=password
26+
internal_package_prefix=int_
27+
package_name_replacement_pattern=
28+
package_name_replacement_rule=
29+
remote_tls_validation=true
30+
use_https_for_sync=false
31+
32+
[redis]
33+
host=redis-manager
34+
port=6379
35+
db=0
36+
max_page_size=24
37+
38+
[remotes]
39+
sock_connect_timeout=120.0
40+
sock_read_timeout=600.0
41+
42+
[paging]
43+
default_page_size=50
44+
max_page_size=20000
45+
46+
[vault]
47+
repo_secret_namespace=test-namespace
48+
enabled=false
49+
url=http://localhost:8200
50+
vault_addr=http://localhost:8200

.dockerignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
demo/assets/keys/gpg/
2+
demo/assets/certs/
3+
.claude/
4+
.coverage
5+
venv/
6+
__pycache__/

.gitignore

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,13 @@
11
__pycache__
22
venv
3+
4+
# Demo environment runtime files
5+
demo/assets/certs/*
6+
!demo/assets/certs/.gitkeep
7+
demo/assets/keys/gpg/
8+
demo/assets/keys/*.pem
9+
demo/assets/keys/*.key
10+
11+
# Other runtime files
12+
.coverage
13+
.claude/

Dockerfile

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ RUN mkdir -p /pulp_manager \
1111
&& groupadd pulp_manager \
1212
&& useradd -u 10001 pulp_manager -g pulp_manager -d /pulp_manager/ \
1313
&& apt-get update \
14-
&& apt-get install -y python3-venv netcat \
14+
&& apt-get install -y python3-venv netcat-openbsd \
1515
&& python3 -m venv /opt/venv
1616

1717
WORKDIR /pulp_manager
@@ -33,20 +33,14 @@ RUN /opt/venv/bin/pip install --upgrade pip \
3333
FROM base as final
3434

3535
# Install runtime dependencies including Git and make
36-
RUN apt-get update && apt-get install -y netcat git make python3-dev libsasl2-dev libldap2-dev libssl-dev default-libmysqlclient-dev build-essential && rm -rf /var/lib/apt/lists/*
36+
RUN apt-get update && apt-get install -y netcat-openbsd git make python3-dev libsasl2-dev libldap2-dev libssl-dev default-libmysqlclient-dev build-essential && rm -rf /var/lib/apt/lists/*
3737

3838
# Copy virtual environment from builder stage
3939
COPY --from=builder /opt/venv /opt/venv
4040
# Copy requirements file
4141
COPY --from=builder /pulp_manager/requirements.txt ./
42-
# Copy application code and other necessary files
43-
COPY alembic.ini pylint.rc pytest.ini wait_db.sh *.yml ./
44-
ADD alembic ./alembic/.
45-
ADD Makefile .
46-
ADD local_config.ini .
47-
ADD local_pulp_config.yml ./local_pulp_config.yml
48-
ADD pulp-manager.sh .
49-
ADD pulp_manager ./pulp_manager/.
42+
# Copy the entire project
43+
COPY . .
5044

5145
# Ensure correct permissions
5246
RUN chown -R pulp_manager:pulp_manager /pulp_manager \

Makefile

Lines changed: 29 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,59 +1,62 @@
1-
.DEFAULT_GOAL:=all
1+
.DEFAULT_GOAL:=h
22

33
ROOT_DIR := $(dir $(lastword $(MAKEFILE_LIST)))
44
PKG_NAME := pulp_manager
55

6-
.PHONY : all
7-
all:
6+
.PHONY : h help
7+
h help:
88
@printf "%s\n" "Usage: make <target>"
99
@printf "\n%s\n" "Targets:"
1010
@printf " %-22s%s\n" \
11+
"h|help" "Print this help" \
1112
"t|test" "Run all tests" \
1213
"l|lint" "Run lint" \
1314
"c|cover" "Run coverage for all tests" \
1415
"venv" "Create virtualenv" \
15-
"bdist" "Create wheel file" \
1616
"clean" "Clean workspace" \
17-
"h|help" "Print this help"
18-
"run-pulp3" "Start Pulp 3 locally with Docker Compose"
19-
20-
21-
.PHONY : h help
22-
h help: all
17+
"demo" "Run demo environment"
2318

2419
.PHONY : l lint
2520
l lint: venv
2621
@echo "# pylint"; \
2722
./venv/bin/pylint --rcfile ./pylint.rc pulp_manager/
2823

24+
check-devcontainer:
25+
@if [ -z "$$Is_local" ] && [ -z "$$DEVCONTAINER" ]; then \
26+
echo "ERROR: Tests must be run in devcontainer environment!"; \
27+
echo ""; \
28+
echo "To run tests:"; \
29+
echo " 1. Open VS Code"; \
30+
echo " 2. Use Command Palette (Cmd/Ctrl+Shift+P)"; \
31+
echo " 3. Select 'Dev Containers: Reopen in Container'"; \
32+
echo " 4. Wait for container to build"; \
33+
echo " 5. Run: make t"; \
34+
echo ""; \
35+
exit 1; \
36+
fi
37+
2938
.PHONY : t test
30-
t test: venv
39+
t test: venv check-devcontainer
3140
@./venv/bin/pytest -v
3241

3342
.PHONY : c cover
34-
c cover: venv
43+
c cover: venv check-devcontainer
3544
@. venv/bin/activate; \
3645
coverage erase; \
3746
coverage run --source=. --omit=pulp_manager/tests/unit/mock_repository.py -m pytest -v && coverage report --fail-under=90; \
3847
coverage html
3948

49+
.PHONY : venv
4050
venv: requirements.txt
4151
@python3 -m venv venv
4252
@. venv/bin/activate; \
4353
pip install --upgrade pip; \
4454
pip install -r requirements.txt
4555

46-
run-pulp-manager: setup-network
47-
@echo "Starting local Docker Compose environment..."
48-
docker compose -f dockercompose-local.yml up --build
49-
50-
.PHONY : run-pulp3
51-
run-pulp3: setup-network
52-
@echo "Starting Pulp 3 locally with Docker Compose..."
53-
docker compose -f ./dockercompose-pulp3.yml up --build
54-
55-
setup-network:
56-
@echo "Creating or verifying network..."
57-
docker network inspect pulp-net >/dev/null 2>&1 || \
58-
docker network create pulp-net
59-
@echo "Network setup completed."
56+
.PHONY : demo
57+
demo: venv
58+
@echo "Setting up demo environment..."
59+
@. venv/bin/activate && \
60+
pip install -q ansible 'pulp-glue>=0.29.0' 'pulp-glue-deb>=0.3.0,<0.4' && \
61+
ansible-galaxy collection install pulp.squeezer 2>&1 | grep -v 'Installing' && \
62+
ansible-playbook -i localhost, demo/ansible/playbook.yml

README.md

Lines changed: 26 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,15 @@
77

88
The Pulp Manager application is used to coordinate common Pulp
99
workflows and provide additional reporting capabilities about a
10-
cluster of Pulp servers. It is designed to work with Pulp3.
10+
cluster of Pulp servers. It is designed to work with Pulp3 servers in
11+
a primary/secondary setup.
1112

12-
## About the Project
13+
## Why Pulp Manager?
1314

14-
We recommend that Pulp be operated in a primary/secondary setup. There
15-
is a single Pulp instance known as the Pulp Primary which syncs repos
16-
from the Internet and can also have custom or internal packages
17-
uploaded to it. Secondaries are then configured to sync these
18-
snapshots and internal repos.
15+
Pulp Manager provides centralized orchestration of a clustger of Pulp3
16+
instances and is particularly usfeful for organizations with
17+
multi-tiered or multi-zone deployments who need coordinated syncs
18+
between primary and secondary servers.
1919

2020
Pulp3 doesn't provide a method to schedule the synchronisation of
2121
repos, and in some repository types (deb) may require multiple steps
@@ -26,7 +26,8 @@ or Jenkins.
2626

2727
## Core Team
2828

29-
This project is maintained by G-Research. For details on our team and
29+
This project originated at [G-Research](https://github.com/G-Research)
30+
but is now owned by the Pulp project. For details on our team and
3031
roles, please see the [MAINTAINERS.md](MAINTAINERS.md) file.
3132

3233
## Documentation Index
@@ -128,17 +129,22 @@ components:
128129

129130
## Quick Start
130131

131-
1. **Using DevContainers (Recommended)**
132+
1. **For Development (running tests, exploring APIs, etc) **
132133
```bash
133-
# Open in VS Code and select "Reopen in Container"
134-
# Or use the CLI:
134+
# Open in VS Code and select action "Dev Containers: Reopen in Container"
135+
# Or use the Dev Container CLI:
135136
devcontainer up --workspace-folder .
136137
```
138+
139+
From a terminal in the devcontainer, 'make t' will run the tests.
140+
137141

138-
2. **Manual Setup**
142+
2. **For Demo cluster, use the make target to setup a complete Docker Compose environment**
139143
```bash
140-
make run-pulp-manager
144+
make demo
141145
```
146+
147+
When startup is finished, `docker ps` will show you the components, and all APIs will be listening.
142148

143149
For detailed development setup, see the [Development
144150
Info](#development-info) section.
@@ -168,6 +174,7 @@ default_domain=example.com
168174
jwt_algorithm=HS256
169175
jwt_token_lifetime_mins=480
170176
admin_group=pulpmaster-rw
177+
require_jwt_auth=true
171178
172179
[pulp]
173180
deb_signing_service=pulp_deb
@@ -180,6 +187,7 @@ internal_package_prefix=corp_
180187
package_name_replacement_pattern=
181188
package_name_replacement_rule=
182189
remote_tls_validation=true
190+
use_https_for_sync=true
183191
184192
[redis]
185193
host=redis
@@ -220,6 +228,9 @@ Defines authentication allowed against the API
220228
- `jwt_token_lifetime_mins`: Number of minutes JWT is valid for
221229
- `admin_group`: Directory group user must be a member of to carry out
222230
priveldged actions agains the API
231+
- `require_jwt_auth`: Boolean whether to require JWT authentication for
232+
protected API endpoints. Set to false for local development environments
233+
where authentication is not needed. Defaults to true
223234

224235
### pulp
225236

@@ -239,6 +250,8 @@ Settings to apply to all pulp servers
239250
the pulp repo config
240251
- `remote_tls_validation`: Boolean whether to require TLS validation
241252
of remote hosts
253+
- `use_https_for_sync`: Boolean whether to use HTTPS for repository sync URLs.
254+
Set to false for local HTTP-only development environments. Defaults to true.
242255

243256
### redis
244257

0 commit comments

Comments
 (0)