Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Scaling WordPress with containers - WPHooked June 2017

Scaling WordPress with containers - WPHooked June 2017

craigwillis85

June 14, 2017
Tweet

More Decks by craigwillis85

Other Decks in Programming

Transcript

  1. https://en.wikipedia.org/wiki/Scalability Scalability is the capability of a system, network, or

    process to handle a growing amount of work, or its potential to be enlarged to accommodate that growth
  2. What is a container? Lightweight, stand-alone, executable package Includes everything

    it needs to run Runtime, system tools, libraries, settings Built on top of facilities of linux kernel Does not include / require a separate operating system
  3. version: '2' services: database: image: mysql:5.6 environment: MYSQL_USER: 'root' MYSQL_DATABASE:

    'wphookeddemo' MYSQL_ALLOW_EMPTY_PASSWORD: 'true' ON_CREATE_DB: 'wphookeddemo' ports: - "3306:3306" demoapp: image: craigwillis85/wp-demo:latest volumes: - "./public:/var/www/html" - "./public/wp-config-dev.php:/var/www/html/wp-config.php" ports: - "80:80"
  4. version: '2' services: database: image: mysql:5.6 environment: MYSQL_USER: 'root' MYSQL_DATABASE:

    'wphookeddemo' MYSQL_ALLOW_EMPTY_PASSWORD: 'true' ON_CREATE_DB: 'wphookeddemo' ports: - "3306:3306" demoapp: image: craigwillis85/wp-demo:latest volumes: - "./public:/var/www/html" - "./public/wp-config-dev.php:/var/www/html/wp-config.php" ports: - "80:80"
  5. version: '2' services: database: image: mysql:5.6 environment: MYSQL_USER: 'root' MYSQL_DATABASE:

    'wphookeddemo' MYSQL_ALLOW_EMPTY_PASSWORD: 'true' ON_CREATE_DB: 'wphookeddemo' ports: - "3306:3306" demoapp: image: craigwillis85/wp-demo:latest volumes: - "./public:/var/www/html" - "./public/wp-config-dev.php:/var/www/html/wp-config.php" ports: - "80:80"
  6. version: '2' services: database: image: mysql:5.6 environment: MYSQL_USER: 'root' MYSQL_DATABASE:

    'wphookeddemo' MYSQL_ALLOW_EMPTY_PASSWORD: 'true' ON_CREATE_DB: 'wphookeddemo' ports: - "3306:3306" demoapp: image: craigwillis85/wp-demo:latest volumes: - "./public:/var/www/html" - "./public/wp-config-dev.php:/var/www/html/wp-config.php" ports: - "80:80"
  7. $ docker ps CONTAINER ID IMAGE PORTS NAMES f41a217b93aa mysql:5.6

    0.0.0.0:3306->3306/tcp wphookedwordpress_database 8ad8f1ad3a1c craigwillis85/wp-demo:latest 0.0.0.0:80->80/tcp wphookedwordpress_demoapp
  8. A Pod is a collection of containers sharing a network

    and mount namespace and is the basic unit of deployment in Kubernetes. All containers in a pod are scheduled on the same node.
  9. A Service is an abstraction for pods, providing a stable,

    virtual IP (VIP) address allowing clients to reliably connect to the containers by forwarding traffic to one or more pods
  10. apiVersion: v1 kind: Service metadata: name: wordpress spec: ports: -

    name: http port: 80 protocol: TCP targetPort: http selector: name: wordpress type: LoadBalancer
  11. A deployment is a supervisor for pods and replica sets,

    giving you fine-grained control over how and when a new pod version is rolled out as well as rolled back to a previous state.
  12. apiVersion: extensions/v1beta1 kind: Deployment metadata: name: wordpress labels: name: wordpress

    spec: replicas: 5 template: metadata: labels: name: wordpress ………………..
  13. spec: containers: - name: wordpress image: craigwillis85/wp-demo:latest imagePullPolicy: Always env:

    - name: GET_HOSTS_FROM value: dns ports: - containerPort: 80 name: http protocol: TCP imagePullSecrets: - name: docker restartPolicy: Always
  14. A ReplicaSet is a supervisor for long-running pods. An RC

    will launch a specified number of pods called replicas and makes sure that they keep running, for example when a node fails or something inside of a pod, that is, in one of its containers goes wrong.
  15. kops create cluster $NAME \ --node-count 2 \ --zones $ZONES

    \ --node-size $NODE_SIZE \ --master-size $MASTER_SIZE \ --master-zones $ZONES \ --networking weave \ --topology private \ --bastion="true" \ --yes
  16. $ kubectl get nodes NAME STATUS AGE VERSION ip-172-20-50-31…. Ready,master

    1h v1.6.2 ip-172-20-55-31…. Ready,node 1h v1.6.2 ip-172-20-56-48…. Ready,node 1h v1.6.2