0% found this document useful (0 votes)
14 views

practale

mcqs

Uploaded by

bc200202399
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
14 views

practale

mcqs

Uploaded by

bc200202399
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 6

Fall 2024

IT601P – System and Network Administration (Practical)


Assignment No. 2

BC200202399 Hamza imdad


________________________________________________________________________________

# Assignment Solution

## Task 1: Container-based Environment Recommendation

### Comparison: VMs vs. Containers

**Virtual Machines (VMs):**

- Each VM requires a separate operating system, consuming significant resources.

- Start-up times are longer compared to containers.

- Resource utilization is less efficient as each VM carries its own OS overhead.

**Containers:**

- Containers share the host OS kernel, leading to lower resource overhead.

- Faster start-up times and better resource utilization.

- Ideal for microservices architecture and environments requiring high scalability.

**Recommendation:**

A container-based environment is better for this scenario as it allows:

- Efficient resource utilization across 10 web servers.

- Scalability to handle increased traffic.

- Easy management of dependencies using container images.

## Task 2: Container Image Requirements

### Number of Container Image Files Required


- **Web Server Image:** 1 container image to host the web application.

- **Database Server Image:** 1 container image for MariaDB.

### Scripts for Creating Container Image Files

**Web Server Container Image (Dockerfile):**

```dockerfile

# Web Server Dockerfile

FROM nginx:latest

COPY ./webapp /usr/share/nginx/html

EXPOSE 80

CMD ["nginx", "-g", "daemon off;"]

```

**MariaDB Container Image (Dockerfile):**

```dockerfile

# Database Server Dockerfile

FROM mariadb:latest

ENV MYSQL_ROOT_PASSWORD=my-secret-pw

ENV MYSQL_DATABASE=mydb

COPY ./init.sql /docker-entrypoint-initdb.d/

EXPOSE 3306

CMD ["mysqld"]

```

**Required Configuration Files:**

- `webapp` directory: Contains the web application files.

- `init.sql`: Script to initialize the MariaDB database.


## Task 3: IP Addressing Plan

### IP Addressing

Given the network prefix `192.16.x.0/24` (with `x = 9`):

- **Load Balancer:** 192.16.9.1

- **Web Servers:** 192.16.9.2 - 192.16.9.11

- **Database Servers:** 192.16.9.12, 192.16.9.13

- **Subnet Mask:** 255.255.255.0

- **Gateway:** 192.16.9.254

### Network Diagram

## Task 4: Deployment File

**Docker Compose File (`docker-compose.yml`):**

```yaml

version: '3.8'

services:

load-balancer:
image: nginx:latest

volumes:

- ./nginx.conf:/etc/nginx/nginx.conf

ports:

- "443:443"

depends_on:

- web

web:

image: custom-webapp

build:

context: ./web

dockerfile: Dockerfile

deploy:

replicas: 10

update_config:

parallelism: 2

delay: 10s

restart_policy:

condition: on-failure

networks:

- app-network

ports:

- "80"

db:

image: custom-mariadb

build:

context: ./db
dockerfile: Dockerfile

environment:

MYSQL_ROOT_PASSWORD: my-secret-pw

MYSQL_DATABASE: mydb

volumes:

- db_data:/var/lib/mysql

networks:

- app-network

networks:

app-network:

driver: bridge

volumes:

db_data:

```

### Load Balancer Configuration (`nginx.conf`):

```nginx

http {

upstream backend {

ip_hash; # Ensures session persistence

server 192.16.9.2;

server 192.16.9.3;

server 192.16.9.4;

server 192.16.9.5;

server 192.16.9.6;

server 192.16.9.7;

server 192.16.9.8;
server 192.16.9.9;

server 192.16.9.10;

server 192.16.9.11;

server {

listen 443 ssl;

server_name localhost;

ssl_certificate /etc/nginx/ssl/nginx.crt;

ssl_certificate_key /etc/nginx/ssl/nginx.key;

location / {

proxy_pass http://backend;

proxy_set_header Host $host;

proxy_set_header X-Real-IP $remote_addr;

proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

You might also like