O slideshow foi denunciado.
Seu SlideShare está sendo baixado. ×

Deployment Automation with Docker

Anúncio
Anúncio
Anúncio
Anúncio
Anúncio
Anúncio
Anúncio
Anúncio
Anúncio
Anúncio
Anúncio
Anúncio
Carregando em…3
×

Confira estes a seguir

1 de 22 Anúncio

Mais Conteúdo rRelacionado

Diapositivos para si (20)

Quem viu também gostou (20)

Anúncio

Semelhante a Deployment Automation with Docker (20)

Mais recentes (20)

Anúncio

Deployment Automation with Docker

  1. 1. Deployment Automation Egor Pushkin egor@glympse.com Platform Architect Glympse, Inc.
  2. 2. Docker is AWESOME
  3. 3. Docker is not intended to solve EVERYTHING
  4. 4. Problem Source Code Build Config Environment Dependencies Runtime Config Compute Instance
  5. 5. Terminology Docker Registry Docker Image Docker Daemon Docker Instance Docker Image Docker Container * * 1 1 1 * Storage backend Local volume, S3, etc. Registry Instance Docker Client Docker Client
  6. 6. Installation Docker Daemon Linux Docker Client MacOS Docker Client Docker Daemon VM running Linux $DOCKER_HOST
  7. 7. Flow Docker Registrypush image_x dev. box / Jenkins / CD InstanceSource Code Env / Deps Configuration Instance pull image_x Docker Image run image_x 1 2 3
  8. 8. Image Anatomy Base Image Updates Dependencies Application Base Image Updates Dependencies Application Images bootfs Base Image Image Image Image r/o r/o r/o r/o r/o App I/O r/w Container Union file system Union mount Parent
  9. 9. Linux Containers (LXC) OS Kernel ... Container Container Container Docker daemon Multi CPU/core box cgroups Resource isolation ● CPU ● memory ● disk I/O Namespace isolation ● process tree ● network ● user ids ● mounted file systems OS Kernel Docker ... Container Container Container There is no virtualization involved when software runs within containers. (2007)
  10. 10. Docker Registry Docker Registry Docker Image dev / test / staging / production *1 Storage backend Local volume, S3, etc.TCP-based API REST API REST API Docker Daemon Jenkins/CD/ automation software Containers Containers Containers
  11. 11. Registry Options Docker Hub Docker daemon Public Images Private Images Private Registry Private Cloud default
  12. 12. Private Registry Registry container nginx container Docker Hub Not secure / unauthenticated pull registry pull nginx SSL Basic Auth InternetVPC Docker Instance S3 Bucket
  13. 13. Starting Registry docker run --restart=always -e SETTINGS_FLAVOR=s3 -e AWS_BUCKET= registry.docker.enterprise.glympse.com -e STORAGE_PATH= /storage -e AWS_KEY= AKIA... -e AWS_SECRET= OEJ0... -e SEARCH_BACKEND=sqlalchemy -p 5000:5000 -d registry Registry container Docker Instance S3 Bucket docker pull registry :5000 :5000
  14. 14. Detailed Flow Image build Source Code Registry Image Container tag push pull run rm rmi start Daemon ps images ... stop
  15. 15. FROM ubuntu:14.04 # Install Python Setuptools RUN apt-get install -y python-setuptools # Install pip RUN easy_install pip # Bundle app source COPY . /src # Add and install Python modules RUN pip install -r /src/requirements.txt # Set default container command ENTRYPOINT ["python"] # Run the app CMD ["/src/server.py"] Dockerfile /project requirements.txt server.py Dockerfile /usr/user /src req-s.txt server.py ubuntu python-setuptools pip requirements Project source code docker build -t image_x . image_x Image Storage <none> IMAGE CHARACTERISTICS Deterministic Independent docker run ... image_x /usr/user /src req-s.txt server.py ubuntu ... <none> <none> <none> Container r/w layer Running Container
  16. 16. Walkthrough docker build -t IMAGE_NAME . docker tag IMAGE_ID REGISTRY_URL:PORT/IMAGE_NAME:TAG docker push REGISTRY_URL:PORT/IMAGE_NAME:TAG docker pull REGISTRY_URL:PORT/IMAGE_NAME:TAG docker run --restart=always -d -p HOST_PORT:CONTAINER_PORT IMAGE_NAME:TAG Build image from source Tag image appropriately Push image to the registry Pull image from the registry Run container based on the image Dev box Jenkins CD Prod Staging Test
  17. 17. Container Configuration Docker Instance Container Container portHost port /src/dir Host FS Container FS /opt/dir Configure port mapping docker run ... -p HOST_PORT:CONTAINER_PORT docker run ... -v HOST_DIR:CONTAINER_DIR Mount a host directory as a data volume
  18. 18. Instance En Route Deployment Demo Admin Console web app Backend App api servers LB Instance App LB Instance Instance ... DB
  19. 19. feature/ec2_demo user name user@email Logout Admin Console ip:pid API Servers /any/thing http://169.254.169.254/ latest/meta-data/public-ipv4 OM { ... box: { ip: IP, pid: PID } } os.getPid()
  20. 20. Instance Template Dockerized Application App PORT -> Instance PORT Instance Docker daemon Container Configuration environment variables Registry pull image aws ec2 run-instances ... EC2Connection.run_instances(... CloudFormationConnection. create_stack(... { "Parameters" : { ... }, "Resources" : { ... }, "Outputs" : { ... } } AWS CLI AWS SDK AWS SDK CloudFormatio n
  21. 21. Cluster Operations Load Balancer App Instance App Instance App Instance App Instance App Instance api - tracking - engine web - tracking - admin type NS app cluster_create cluster_delete cluster_details cluster_launch_instance cluster_terminate_instance cluster_register_instance cluster_deregister_instance Cluster Structure Clusters Operations https://github.com/Glympse/CommonTools/tree/master/Docker Cluster management scripts can be found here
  22. 22. Next ● Orchestration ● SSL / Authentication ● Configuration (identity, networking) ● Monitoring (health checks) ● Continuous delivery

×