Skip to content

Commit 3d863b3

Browse files
AMBARI-26544: Setting up docker images for Ambari for easy installation and testing
1 parent 9b5e1a7 commit 3d863b3

34 files changed

+8725
-0
lines changed

docker/README.md

Lines changed: 288 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,288 @@
1+
# Apache Ambari Docker Setup
2+
3+
This directory contains Docker configurations for Apache Ambari, providing containerized environments for development, testing, and production deployment.
4+
5+
## Quick Start
6+
7+
### Prerequisites
8+
- Docker 20.10+
9+
- Docker Compose 2.0+
10+
- At least 8GB RAM available for Docker
11+
12+
### Development Environment
13+
```bash
14+
# Clone and build Ambari
15+
git clone https://github.com/apache/ambari.git
16+
cd ambari
17+
18+
# Start development environment
19+
docker-compose -f docker/docker-compose.dev.yml up -d
20+
21+
# Access Ambari Web UI
22+
open http://localhost:8080
23+
# Default credentials: admin/admin
24+
```
25+
26+
### Production Deployment
27+
```bash
28+
# Start production stack
29+
docker-compose -f docker/docker-compose.prod.yml up -d
30+
31+
# Scale agents
32+
docker-compose -f docker/docker-compose.prod.yml up -d --scale ambari-agent=3
33+
```
34+
35+
## Available Images
36+
37+
### Base Images
38+
- `apache/ambari-base`: Common runtime dependencies
39+
- `apache/ambari-build`: Build environment with Maven, JDK, Node.js
40+
41+
### Service Images
42+
- `apache/ambari-server`: Ambari Server
43+
- `apache/ambari-agent`: Ambari Agent
44+
- `apache/ambari-metrics`: Metrics Collector with embedded HBase
45+
- `apache/ambari-dev`: Development environment
46+
47+
### Supporting Images
48+
- `apache/ambari-database`: PostgreSQL with Ambari schema
49+
- `apache/ambari-grafana`: Grafana with Ambari Metrics datasource
50+
51+
## Build Instructions
52+
53+
### Build All Images
54+
```bash
55+
# Build all images
56+
./docker/build.sh
57+
58+
# Build specific image
59+
./docker/build.sh ambari-server
60+
61+
# Build with custom tag
62+
./docker/build.sh ambari-server --tag myregistry/ambari-server:latest
63+
```
64+
65+
### Development Build
66+
```bash
67+
# Build development image with current source
68+
docker build -f docker/Dockerfile.dev -t ambari-dev .
69+
70+
# Run development container
71+
docker run -it --rm \
72+
-v $(pwd):/workspace \
73+
-p 8080:8080 \
74+
-p 8441:8441 \
75+
ambari-dev
76+
```
77+
78+
## Configuration
79+
80+
### Environment Variables
81+
82+
#### Ambari Server
83+
- `AMBARI_DB_HOST`: Database hostname (default: ambari-db)
84+
- `AMBARI_DB_PORT`: Database port (default: 5432)
85+
- `AMBARI_DB_NAME`: Database name (default: ambari)
86+
- `AMBARI_DB_USER`: Database user (default: ambari)
87+
- `AMBARI_DB_PASSWORD`: Database password (default: bigdata)
88+
- `AMBARI_SERVER_HTTPS`: Enable HTTPS (default: false)
89+
- `JAVA_OPTS`: JVM options
90+
91+
#### Ambari Agent
92+
- `AMBARI_SERVER_HOST`: Ambari Server hostname (default: ambari-server)
93+
- `AMBARI_SERVER_PORT`: Ambari Server port (default: 8080)
94+
- `AGENT_HOSTNAME`: Agent hostname (auto-detected if not set)
95+
96+
#### Ambari Metrics
97+
- `AMS_HBASE_ROOTDIR`: HBase root directory (default: /var/lib/ambari-metrics-collector/hbase)
98+
- `AMS_COLLECTOR_PORT`: Collector port (default: 6188)
99+
- `AMS_GRAFANA_ENABLED`: Enable Grafana (default: true)
100+
101+
### Volume Mounts
102+
103+
#### Persistent Data
104+
- `/var/lib/ambari-server`: Server data and configurations
105+
- `/var/lib/ambari-agent`: Agent data and logs
106+
- `/var/lib/ambari-metrics-collector`: Metrics data
107+
- `/var/log/ambari-*`: Log directories
108+
109+
#### Development
110+
- `/workspace`: Source code mount point
111+
- `/root/.m2`: Maven repository cache
112+
113+
## Docker Compose Configurations
114+
115+
### Development (docker-compose.dev.yml)
116+
- Single-node setup with all services
117+
- Source code mounted for live development
118+
- Debug ports exposed
119+
- Automatic rebuilding enabled
120+
121+
### Production (docker-compose.prod.yml)
122+
- Multi-container production setup
123+
- Separate database container
124+
- Health checks and restart policies
125+
- Resource limits configured
126+
127+
### Testing (docker-compose.test.yml)
128+
- Automated testing environment
129+
- Includes test databases and mock services
130+
- CI/CD friendly configuration
131+
132+
## Networking
133+
134+
### Default Network
135+
- Network: `ambari-network` (bridge)
136+
- Subnet: `172.20.0.0/16`
137+
138+
### Service Discovery
139+
Services are accessible by their container names:
140+
- `ambari-server`: Ambari Server
141+
- `ambari-db`: PostgreSQL Database
142+
- `ambari-metrics`: Metrics Collector
143+
- `ambari-grafana`: Grafana Dashboard
144+
145+
## Health Checks
146+
147+
All services include health checks:
148+
- **Server**: HTTP check on `/api/v1/clusters`
149+
- **Agent**: Process and heartbeat check
150+
- **Metrics**: HTTP check on `/ws/v1/timeline/metrics`
151+
- **Database**: Connection check
152+
153+
## Troubleshooting
154+
155+
### Common Issues
156+
157+
#### Container Won't Start
158+
```bash
159+
# Check logs
160+
docker-compose logs ambari-server
161+
162+
# Check container status
163+
docker-compose ps
164+
165+
# Restart specific service
166+
docker-compose restart ambari-server
167+
```
168+
169+
#### Database Connection Issues
170+
```bash
171+
# Verify database is running
172+
docker-compose exec ambari-db pg_isready
173+
174+
# Check database logs
175+
docker-compose logs ambari-db
176+
177+
# Reset database
178+
docker-compose down -v
179+
docker-compose up -d ambari-db
180+
```
181+
182+
#### Memory Issues
183+
```bash
184+
# Check resource usage
185+
docker stats
186+
187+
# Increase memory limits in docker-compose.yml
188+
services:
189+
ambari-server:
190+
mem_limit: 4g
191+
```
192+
193+
### Debug Mode
194+
195+
#### Enable Debug Logging
196+
```bash
197+
# Set environment variable
198+
export AMBARI_DEBUG=true
199+
docker-compose up -d
200+
201+
# Or in docker-compose.yml
202+
environment:
203+
- AMBARI_DEBUG=true
204+
```
205+
206+
#### Remote Debugging
207+
```bash
208+
# Server debug port: 5005
209+
# Agent debug port: 5006
210+
211+
# Connect with IDE to localhost:5005
212+
```
213+
214+
## Security Considerations
215+
216+
### Production Deployment
217+
1. Change default passwords
218+
2. Use external database with proper credentials
219+
3. Enable HTTPS/TLS
220+
4. Configure firewall rules
221+
5. Use secrets management
222+
6. Regular security updates
223+
224+
### Network Security
225+
```yaml
226+
# Example secure configuration
227+
services:
228+
ambari-server:
229+
environment:
230+
- AMBARI_DB_PASSWORD_FILE=/run/secrets/db_password
231+
secrets:
232+
- db_password
233+
234+
secrets:
235+
db_password:
236+
external: true
237+
```
238+
239+
## Performance Tuning
240+
241+
### Resource Allocation
242+
```yaml
243+
# Recommended production resources
244+
services:
245+
ambari-server:
246+
mem_limit: 4g
247+
cpus: 2.0
248+
249+
ambari-metrics:
250+
mem_limit: 2g
251+
cpus: 1.0
252+
```
253+
254+
### JVM Tuning
255+
```bash
256+
# Server JVM options
257+
JAVA_OPTS="-Xmx2g -Xms1g -XX:+UseG1GC"
258+
259+
# Metrics JVM options
260+
AMS_JAVA_OPTS="-Xmx1g -Xms512m"
261+
```
262+
263+
## Contributing
264+
265+
### Adding New Services
266+
1. Create Dockerfile in `docker/services/`
267+
2. Add to appropriate docker-compose file
268+
3. Update documentation
269+
4. Add health checks
270+
5. Test thoroughly
271+
272+
### Testing Changes
273+
```bash
274+
# Run test suite
275+
./docker/test.sh
276+
277+
# Specific test
278+
./docker/test.sh integration
279+
280+
# Clean test environment
281+
./docker/test.sh clean
282+
```
283+
284+
## Support
285+
286+
- **Documentation**: [Apache Ambari Docs](https://ambari.apache.org/)
287+
- **Issues**: [GitHub Issues](https://github.com/apache/ambari/issues)
288+
- **Community**: [Apache Ambari Mailing Lists](https://ambari.apache.org/mail-lists.html)

0 commit comments

Comments
 (0)