Traditional Deployment Issues
- Physical Servers: Running apps on physical servers led to resource allocation problems.
- No defined resource boundaries caused one app to dominate resources, impacting others.
- Solution: Run each app on a separate server, but this was unscalable, underutilized resources, and costly.
Virtualization
- Definition: Creating virtual versions of OS, servers, storage, or network resources without physical existence.
- Uses software to simulate hardware, enabling multiple OS and apps on one server.
- Types:
- Network Virtualization: Divides bandwidth into secure, assignable channels for improved speed, availability, and security.
- Storage Virtualization: Pools multiple storage devices into a single, centrally managed device.
- Benefits: Appears local, combines small volumes into one, enhances reliability/performance, supports all OS, offers high availability, disaster recovery.
- Data Virtualization: Aggregates data from various sources into a single virtual view.
- Benefits: Abstracts technical details (location, structure), connects multiple sources, federates data, delivers as needed.
- Desktop Virtualization: Isolates desktop OS from endpoint, supports remote access, includes shared hosted desktops (e.g., Microsoft Remote Desktop Services).
- Application Virtualization: Runs apps separately from devices, simplifying IT management (install, patch, update once).
- Hardware Virtualization: Creates virtual machines (VMs) acting as real computers with their own OS.
- Example: A Windows machine hosting a VM running Ubuntu Linux.
Docker Swarm
- Definition: A container orchestration engine for managing multiple Docker Engines across hosts.
- Built using SwarmKit, secure by default, allows declaring apps as stacks of services.
- Swarm Structure:
- Nodes: Instances of Docker Engine in the swarm.
- Manager Node: Dispatches tasks, manages orchestration, and cluster state; elects a leader.
- Worker Node: Executes tasks assigned by managers, reports task status via an agent.
- Services: Define tasks to run on nodes, specify container image and commands.
- Tasks: Atomic units carrying a container and commands, assigned to nodes, non-migratory.
- Features:
- Integrated cluster management, decentralized design, declarative service model.
- Supports scaling, desired state reconciliation, multi-host networking, service discovery, load balancing, secure by default, rolling updates.
- Swarm Setup:
- Requires Docker Engine 1.12+.
- Ports: TCP 2371 (cluster management), TCP/UDP 7946 (node communication), UDP 4789 (overlay network).
- Commands:
- Initialize swarm:
docker swarm init --advertise-addr <MANAGER-IP>
- Check swarm status:
docker info
- List nodes:
docker node ls
- Get worker join token:
docker swarm join-token worker
- Join swarm:
docker swarm join --token <token>
- Overlay Network:
- Built on host networks, enables secure container communication.
- Created on swarm initialization: ingress (load balancing) and docker_gwbridge (connects overlay to daemon’s network).
Service Management
- Service: Defines tasks for nodes, supports declarative model, scaling, discovery, updates, load balancing, internal DNS.
- Commands:
- Create service:
docker service create --replicas <no> --name <name> -p <port> <image> <command>
- List services:
docker service ls
- Inspect service:
docker service inspect <service>
- List nodes running service:
docker service ps <service>
- Scale service:
docker service scale <service>=<scale>
- Update service:
docker service update --image <image> <service>
- Delete service:
docker service rm <service>
Key Points for Docker (from Previous Notes)
- Generic Commands:
- List:
docker <object> ls
- Inspect:
docker <object> inspect <name/id>
- Remove:
docker <object> rm <name/id>
- Prune:
docker <object> prune
- Images:
- Pull:
docker image pull <image-name>
- Build custom image:
docker image build -t <image-name> <context>
- Push to Docker Hub:
docker image push <username>/<image-name>
- Containers:
- Run:
docker container run -d -i -t --name <name> -p <host-port>:<container-port> -v <volume>:<path> <image>
- Exec command:
docker container exec <name/id> <command>
- Terminal:
docker container exec -it <name/id> bash
- Volumes:
- Create:
docker volume create <volume-name>
- Remove:
docker volume rm <volume-name>
- Prune:
docker volume prune
Notes for Revision