Package your Java EE Application using Docker and Kubernetes - Comment
Package your Java EE Application using Docker and Kubernetes. Topics covered in this presentation slides: 1. Package your Java EE applications using Docker and Kubernetes Arun Gupta, @arungupta Red Hat 2. Arun Gupta Director, Developer Advocacy @arungupta blog.arungupta.me arungupta@redhat.com 3. What is Docker? 4. What is Docker? • Open source project and company 5. What is Docker? • Open source project and company • Used to create containers for software applications 6. What is Docker? • Open source project and company • Used to create containers for software applications • Package Once Deploy Anywhere (PODA) 7. Advantages 8. Advantages • Faster deployments 9. Advantages • Faster deployments • Isolation 10. Advantages • Faster deployments • Isolation • Portability - “it works on my machine” 11. Advantages • Faster deployments • Isolation • Portability - “it works on my machine” • Snapshotting 12. Advantages • Faster deployments • Isolation • Portability - “it works on my machine” • Snapshotting • Security sandbox 13. Advantages • Faster deployments • Isolation • Portability - “it works on my machine” • Snapshotting • Security sandbox • Limit resource usage 14. Advantages • Faster deployments • Isolation • Portability - “it works on my machine” • Snapshotting • Security sandbox • Limit resource usage • Simplified dependency 15. Advantages • Faster deployments • Isolation • Portability - “it works on my machine” • Snapshotting • Security sandbox • Limit resource usage • Simplified dependency • Sharing 16. Underlying Technology 17. Underlying Technology • Written in Go 18. Underlying Technology • Written in Go • Uses several Linux features 19. Underlying Technology • Written in Go • Uses several Linux features • Namespaces to provide isolation 20. Underlying Technology • Written in Go • Uses several Linux features • Namespaces to provide isolation • Control groups to share/limit hardware resources 21. Underlying Technology • Written in Go • Uses several Linux features • Namespaces to provide isolation • Control groups to share/limit hardware resources • Union File System makes it light and fast 22. Underlying Technology • Written in Go • Uses several Linux features • Namespaces to provide isolation • Control groups to share/limit hardware resources • Union File System makes it light and fast • libcontainer defines container format 23. Is it only Linux? 24. Is it only Linux? • Natively supported in Linux 25. Is it only Linux? • Natively supported in Linux • Can be installed on Mac or Windows using boot2docker 26. Is it only Linux? • Natively supported in Linux • Can be installed on Mac or Windows using boot2docker • Tiny Core Linux VM 27. • Image defined in text-based Dockerfile 28. • Image defined in text-based Dockerfile • List of commands to build the image FROM fedora:latest CMD echo “Hello world” 29. • Image defined in text-based Dockerfile • List of commands to build the image • docker build or pull FROM fedora:latest CMD echo “Hello world” 30. • Images shared using registry 31. • Images shared using registry • Docker Hub is public SaaS 32. • Images shared using registry • Docker Hub is public SaaS • Private registries can be setup inside firewall 33. • Images shared using registry • Docker Hub is public SaaS • Private registries can be setup inside firewall • docker push or pull 34. • Container built from the image 35. • Container built from the image • Runtime representation of the image 36. • Container built from the image • Runtime representation of the image • Self contained execution environment 37. • Container built from the image • Runtime representation of the image • Self contained execution environment • docker run 38. Docker commands • docker ps: List running containers • docker stop: Stop a running container • docker rm: Remove a running container • docker rmi: Remove an image • … https://docs.docker.com/reference/commandline/cli/ 39. Docker Hub Docker Host DaemonDocker Client Docker Workflow 40. Docker Hub Docker Host DaemonDocker Client docker run docker … Docker Workflow 41. Docker Hub Docker Host DaemonDocker Client docker run docker … Docker Workflow 42. Docker Hub Image 1 Image 2 Image 3 Image M Docker Host DaemonDocker Client docker run docker … Docker Workflow 43. Docker Hub Image 1 Image 2 Image 3 Image M Docker Host Image 1 Image 2 Image 3 Image N DaemonDocker Client docker run docker … Docker Workflow 44. Docker Hub Image 1 Image 2 Image 3 Image M Docker Host Image 1 Image 2 Image 3 Image N Daemon Container 1 Container 2 Container O Docker Client docker run docker … Docker Workflow 45. Recipe #1.1 FROM jboss/wildfly RUN curl -L https://github.com/javaee-samples/javaee7-hol/raw/master/solution/ movieplex7-1.0-SNAPSHOT.war -o /opt/jboss/wildfly/standalone/deployments/ movieplex7-1.0-SNAPSHOT.war docker run -it -p 8080:8080 arungupta/javaee7-hol Host Application Server Database 46. Recipe #1.2 Host Application Server Database http://blog.arungupta.me/wildfly-javaee7-mysql-link-two-docker-container-techtip65/ data-source add --name=mysqlDS --driver-name=mysql --jndi-name=java:jboss/ datasources/ExampleMySQLDS --connection-url=jdbc:mysql://$DB_PORT_3306_TCP_ADDR: $DB_PORT_3306_TCP_PORT/sample?useUnicode=true&characterEncoding=UTF-8 -- user-name=mysql --password=mysql --use-ccm=false --max-pool-size=25 --blocking- timeout-wait-millis=5000 --enabled=true 47. Recipe #1.3 Host Application Server Database http://blog.arungupta.me/docker-orchestration-fig-techtip67/ 48. Recipe #1.4 Host Application Server http://blog.arungupta.me/docker-container-linking-across-multiple-hosts-techtip69/ Host Database 49. Recipe #1.4 Host Application Server http://blog.arungupta.me/docker-container-linking-across-multiple-hosts-techtip69/ Host Database 50. Recipe #1.4 Host Application Server http://blog.arungupta.me/docker-container-linking-across-multiple-hosts-techtip69/ Host Database 51. Recipe #1.4 Host Application Server http://blog.arungupta.me/docker-container-linking-across-multiple-hosts-techtip69/ Host Database 52. Arquillian Cube • Controls the lifecycle of Docker images as part of test cycle - automatically or manually • Uses Docker REST API to talk to container • Talk using WildFly remote adapter (in container) • Try it out http://blog.arungupta.me/run-javaee-tests-wildfly-docker-arquillian-cube/ 53. Docker: Pros and Cons 54. Docker: Pros and Cons • PROS • Extreme application portability • Very easy to create and work with derivative • Fast boot on containers 55. Docker: Pros and Cons • PROS • Extreme application portability • Very easy to create and work with derivative • Fast boot on containers • CONS • Host-centric solution • No higher-level provisioning • No usage tracking/reporting 56. Application Operating Environment 57. Kubernetes 58. Kubernetes • Open source orchestration system for Docker containers 59. Kubernetes • Open source orchestration system for Docker containers • Provide declarative primitives for the “desired state” • Self-healing • Auto-restarting • Schedule across hosts • Replicating 60. Concepts 61. Concepts • Pods: collocated group of Docker containers that share an IP and storage volume Docker Pod 1 Pod 2 C1 C2 C3 62. Concepts • Pods: collocated group of Docker containers that share an IP and storage volume • Service: Single, stable name for a set of pods, also acts as LB Docker Pod 1 Pod 2 C1 C2 C3 Pod 1 JBoss Pod 2 JBoss Service “web” port 8080 port 8080 63. Concepts • Pods: collocated group of Docker containers that share an IP and storage volume • Service: Single, stable name for a set of pods, also acts as LB • Replication Controller: manages the lifecycle of pods and ensures specified number are running Docker Pod 1 Pod 2 C1 C2 C3 Pod 1 JBoss Pod 2 JBoss Service “web” port 8080 port 8080 64. Concepts • Pods: collocated group of Docker containers that share an IP and storage volume • Service: Single, stable name for a set of pods, also acts as LB • Replication Controller: manages the lifecycle of pods and ensures specified number are running • Label: used to organize and select group of objects Docker Pod 1 Pod 2 C1 C2 C3 Pod 1 JBoss Pod 2 JBoss Service “web” port 8080 port 8080 65. kubectl 66. kubectl • Controls the Kubernetes cluster manager 67. kubectl • Controls the Kubernetes cluster manager • kubectl get pods or minions 68. kubectl • Controls the Kubernetes cluster manager • kubectl get pods or minions • kubectl create -f 69. kubectl • Controls the Kubernetes cluster manager • kubectl get pods or minions • kubectl create -f • kubectl update or delete 70. kubectl • Controls the Kubernetes cluster manager • kubectl get pods or minions • kubectl create -f • kubectl update or delete • kubectl resize —replicas=3 replicationcontrollers 71. export KUBERNETES_PROVIDER=vagrant ./cluster/kube-up.sh Mac OS X Kubernetes (Vagrant) Master Minion 72. Recipe #2.1 Mac OS X Kubernetes (Vagrant) Master Minion Pod Docker (WildFly) http://blog.arungupta.me/javaee7-wildfly-kubernetes-mac-vagrant/ 73. Services • Abstract a set of pods as a single IP and port • Simple TCP/UDP load balancing • Creates environment variables in other pods • Like “Docker links” but across hosts • Stable endpoint for pods to reference • Allows list of pods to change dynamically 74. Recipe #2.2 Minion Pod Docker (WildFly) Pod Docker (MySQL) MySQL Service http://blog.arungupta.me/mysql-kubernetes-service-access-wildfly-pod-techtip72/ 75. Minion 2 Recipe #2.3 Minion 1 Pod Docker (WildFly) Pod Docker (MySQL) MySQL Service 76. Replication Controller 77. Replication Controller • Ensures specified number of pod “replicas” are running 78. Replication Controller • Ensures specified number of pod “replicas” are running • Pod templates are cookie cutters 79. Replication Controller • Ensures specified number of pod “replicas” are running • Pod templates are cookie cutters • Rescheduling 80. Replication Controller • Ensures specified number of pod “replicas” are running • Pod templates are cookie cutters • Rescheduling • Manual or auto-scale replicas 81. Replication Controller • Ensures specified number of pod “replicas” are running • Pod templates are cookie cutters • Rescheduling • Manual or auto-scale replicas • Rolling updates 82. Recipe #2.4 83. Recipe #2.4 84. Recipe #2.4 Minion 2 Minion 1 Pod Docker (WildFly) Pod Docker (MySQL) MySQL Service Pod Docker (WildFly) WildFly Service 85. Recipe #2.4 Minion 2 Minion 1 Pod Docker (WildFly) Pod Docker (MySQL) MySQL Service Pod Docker (WildFly) WildFly Service 86. Kubernetes: Pros and Cons • PROS • Manage related Docker containers as a unit • Container communication across hosts • Availability and scalability through automated deployment and monitoring of pods and their replicas, across hosts 87. Kubernetes: Pros and Cons • CONS • Lifecycle of applications - build, deploy, manage, promote • Port existing source code to run in Kubernetes • DevOps: Dev -> Test -> Production • No multi-tenancy • On-premise (available on GCE) • Assumes inter-pod networking as part of infrastructure • Requires explicit load balancer 88. Pod 7 ActiveMQ Pod 8 ActiveMQ “mq” port 8161 port 8161 Pod 1 Apache Pod 2 Apache “web” port 80 port 80 Pod 5 MySQL Pod 6 MySQL “db” port 3306 port 3306 Pod 3 JBoss Pod 4 JBoss “javaee” port 8080 port 8080 89. Pod 7 ActiveMQ Pod 8 ActiveMQ “mq” port 8161 port 8161 Pod 1 Apache Pod 2 Apache “web” port 80 port 80 Pod 5 MySQL Pod 6 MySQL “db” port 3306 port 3306 Pod 3 JBoss Pod 4 JBoss “javaee” port 8080 port 8080 90. Container Host Container Cluster Management User Experience 91. OpenShift 3 Features 92. OpenShift 3 Features • Push to production - full DevOps 93. OpenShift 3 Features • Push to production - full DevOps • Client tools for building web applications 94. OpenShift 3 Features • Push to production - full DevOps • Client tools for building web applications • Centralized administration and management of application component libraries 95. OpenShift 3 Features • Push to production - full DevOps • Client tools for building web applications • Centralized administration and management of application component libraries • Team and user isolation of containers, builds, and network communication in an easy multi-tenancy system 96. Recipe #3.1 • Start OpenShift as Docker container • Or run natively • Use osc (OpenShift Client) instead of kubectl with Kubernetes configuration file 97. Recipe #3.2 • (Alpha) tools generate project JSON configuration file that provide build/deployment 98. 40 99. Recipe #3.3 • Integration with JBoss Developer Studio (cooking) 100. Summary • Container runtime and image distribution • Roll your own solutions for everything • Runtime and operational management of containers • Lifecycle of applications - build, deploy, manage, promote • Manage tens of thousands of applications with teams 101. References • blog.arungupta.me/topics/containers/ • github.com/openshift/origin |
|||
Posted by : peter88 | Post date : 2020-01-06 15:27 | ||
Category : Technology | Views : 395 | ||
New Comment