Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Workshop-Build e deploy avançado com Openshift e Kubernetes

208 views

Published on

Personalizando o ambiente para sua aplicação, editando parâmetros de build e deploy para melhor se adequar a sua aplicação.

Published in: Technology
  • Be the first to comment

Workshop-Build e deploy avançado com Openshift e Kubernetes

  1. 1. João Brito @juniorjbn
  2. 2. Conceitos
  3. 3. Criando uma aplicação de teste
  4. 4. Hacking
  5. 5. S2i + OC = ➔Assenble ➔Run
  6. 6. BuildConfig ➔Build Binário ➔Build Incremental
  7. 7. $ oc describe bc/site 1. Name: site 2. Namespace: workshop 3. Created: 4 days ago 4. Labels: app=site i. template=site 5. Annotations: openshift.io/generated-by=GetupCloudWebConsole 6. Latest Version: 6 7. Strategy: Source 8. URL: git@bitbucket.org:juniorjbn/php-test.git 9. Ref: master 10. ContextDir: / 11. From Image: ImageStreamTag openshift/php:5.6 12. Output to: ImageStreamTag site:latest 13. Build Run Policy: Serial 14. Triggered by: ImageChange, Config 15. Webhook Generic: a. URL: https://api.getupcloud.com:443/oapi/v1/namespaces/workshop/buildconfigs/site/webhooks/42be0bdf5222c84b50854 e98/generic 16. Webhook GitHub: a. URL: https://api.getupcloud.com:443/oapi/v1/namespaces/workshop/buildconfigs/site/webhooks/9ac2640292ebe215c9b6f 120/github 17. Build Status Duration Creation Time 18. site-3 complete 1m34s 2016-12-08 20:37:39 -0200 BRST
  8. 8. $ oc describe bc/site 1. Name: site 2. Namespace: workshop 3. Created: 4 days ago 4. Labels: app=site i. template=site 5. Annotations: openshift.io/generated-by=GetupCloudWebConsole 6. Latest Version: 6 7. Strategy: Source 8. URL: git@bitbucket.org:juniorjbn/php-test.git 9. Ref: master 10. ContextDir: / 11. From Image: ImageStreamTag openshift/php:5.6 12. Output to: ImageStreamTag site:latest 13. Build Run Policy: Serial 14. Triggered by: ImageChange, Config 15. Webhook Generic: a. URL: https://api.getupcloud.com:443/oapi/v1/namespaces/workshop/buildconfigs/site/webhooks/42be0bdf5222c84b50854 e98/generic 16. Webhook GitHub: a. URL: https://api.getupcloud.com:443/oapi/v1/namespaces/workshop/buildconfigs/site/webhooks/9ac2640292ebe215c9b6f 120/github 17. Build Status Duration Creation Time 18. site-3 complete 1m34s 2016-12-08 20:37:39 -0200 BRST
  9. 9. $ oc describe bc/site 1. Name: site 2. Namespace: workshop 3. Created: 4 days ago 4. Labels: app=site i. template=site 5. Annotations: openshift.io/generated-by=GetupCloudWebConsole 6. Latest Version: 6 7. Strategy: Source 8. URL: git@bitbucket.org:juniorjbn/php-test.git 9. Ref: master 10. ContextDir: / 11. From Image: ImageStreamTag openshift/php:5.6 12. Output to: ImageStreamTag site:latest 13. Build Run Policy: Serial 14. Triggered by: ImageChange, Config 15. Webhook Generic: a. URL: https://api.getupcloud.com:443/oapi/v1/namespaces/workshop/buildconfigs/site/webhooks/42be0bdf5222c84b50854 e98/generic 16. Webhook GitHub: a. URL: https://api.getupcloud.com:443/oapi/v1/namespaces/workshop/buildconfigs/site/webhooks/9ac2640292ebe215c9b6f 120/github 17. Build Status Duration Creation Time 18. site-3 complete 1m34s 2016-12-08 20:37:39 -0200 BRST
  10. 10. $ oc describe bc/site 1. Name: site 2. Namespace: workshop 3. Created: 4 days ago 4. Labels: app=site i. template=site 5. Annotations: openshift.io/generated-by=GetupCloudWebConsole 6. Latest Version: 6 7. Strategy: Source 8. URL: git@bitbucket.org:juniorjbn/php-test.git 9. Ref: master 10. ContextDir: / 11. From Image: ImageStreamTag openshift/php:5.6 12. Output to: ImageStreamTag site:latest 13. Build Run Policy: Serial 14. Triggered by: ImageChange, Config 15. Webhook Generic: a. URL: https://api.getupcloud.com:443/oapi/v1/namespaces/workshop/buildconfigs/site/webhooks/42be0bdf5222c84b508 54e98/generic 16. Webhook GitHub: a. URL: https://api.getupcloud.com:443/oapi/v1/namespaces/workshop/buildconfigs/site/webhooks/9ac2640292ebe215c9b 6f120/github 17. Build Status Duration Creation Time 18. site-3 complete 1m34s 2016-12-08 20:37:39 -0200 BRST
  11. 11. Build Binário $ oc edit bc/app spec.source: type: Binary Agora posso usar o cod local $ oc start-build site --from-dir=.
  12. 12. $ oc describe bc/site 1. Name: site 2. Namespace: workshop 3. Created: 4 days ago 4. Labels: app=site i. template=site 5. Annotations: openshift.io/generated-by=GetupCloudWebConsole 6. Latest Version: 6 7. Strategy: Source 8. URL: git@bitbucket.org:juniorjbn/php-test.git 9. Ref: master 10. ContextDir: / 11. From Image: ImageStreamTag openshift/php:5.6 12. Output to: ImageStreamTag site:latest 13. Build Run Policy: Serial 14. Triggered by: ImageChange, Config 15. Webhook Generic: a. URL: https://api.getupcloud.com:443/oapi/v1/namespaces/workshop/buildconfigs/site/webhooks/42be0bdf5222c84b50854 e98/generic 16. Webhook GitHub: a. URL: https://api.getupcloud.com:443/oapi/v1/namespaces/workshop/buildconfigs/site/webhooks/9ac2640292ebe215c9b6f 120/github 17. Build Status Duration Creation Time 18. site-3 complete 1m34s 2016-12-08 20:37:39 -0200 BRST
  13. 13. $ oc describe bc/site 1. Name: site 2. Namespace: workshop 3. Created: 6 days ago 4. Labels: app=site 5. template=site 6. Annotations: openshift.io/generated-by=GetupCloudWebConsole 7. Latest Version: 8 8. Strategy: Source 9. Binary: provided on build 10. From Image: ImageStreamTag openshift/php:5.6 11. Output to: ImageStreamTag site:latest 12. Build Run Policy: Serial 13. Triggered by: ImageChange, Config 14. Webhook Generic: 15. URL: https://api.getupcloud.com:443/oapi/v1/namespaces/workshop/buildconfigs/site/webhooks/42be0bdf5222c84b50854e98/generic 16. AllowEnv: false 17. Webhook GitHub: 18. URL: https://api.getupcloud.com:443/oapi/v1/namespaces/workshop/buildconfigs/site/webhooks/9ac2640292ebe215c9b6f120/github 19. Build Status Duration Creation Time 20. site-8 failed 3s 2016-12-13 10:37:47 -0200 BRST
  14. 14. Build Binário $ oc edit bc/app spec.source: type: Binary Agora posso usar o cod local $ oc start-build site --from-dir=.
  15. 15. Build Incremental .s2i/bin/save-artifacts #!/bin/bash # tar cf - .composer composer.lock vendor $ oc edit bc/site #spec: # strategy: # sourceStrategy: # incremental: true .s2i/bin/assemble #!/bin/bash # if [ -d /tmp/artifacts/ ]; then # echo "---> Restoring build artifacts from /tmp/artifacts..." # shopt -s dotglob # mv -v /tmp/artifacts/* ./ # shopt -u dotglob # fi
  16. 16. Build Incremental .s2i/bin/save-artifacts #!/bin/bash # tar cf - .composer composer.lock vendor $ oc edit bc/site #spec: # strategy: # sourceStrategy: # incremental: true .s2i/bin/assemble #!/bin/bash # if [ -d /tmp/artifacts/ ]; then # echo "---> Restoring build artifacts from /tmp/artifacts..." # shopt -s dotglob # mv -v /tmp/artifacts/* ./ # shopt -u dotglob # fi
  17. 17. Build Incremental .s2i/bin/save-artifacts #!/bin/bash # tar cf - .composer composer.lock vendor $ oc edit bc/site #spec: # strategy: # sourceStrategy: # incremental: true .s2i/bin/assemble #!/bin/bash # if [ -d /tmp/artifacts/ ]; then # echo "---> Restoring build artifacts from /tmp/artifacts..." # shopt -s dotglob # mv -v /tmp/artifacts/* ./ # shopt -u dotglob # fi
  18. 18. Build Incremental .s2i/bin/save-artifacts #!/bin/bash # tar cf - .composer composer.lock vendor $ oc edit bc/site #spec: # strategy: # sourceStrategy: # incremental: true .s2i/bin/assemble #!/bin/bash # if [ -d /tmp/artifacts/ ]; then # echo "---> Restoring build artifacts from /tmp/artifacts..." # shopt -s dotglob # mv -v /tmp/artifacts/* ./ # shopt -u dotglob # fi
  19. 19. DeploymentConfig ➔Recreate ➔Rolling ➔Blue/Green ➔A/B
  20. 20. $ oc describe dc/site 1. Name: site 2. Namespace: workshop 3. Created: 6 days ago 4. Labels: app=site i. template=site 5. Annotations: iconClass=icon-php i. openshift.io/generated-by=GetupCloudWebConsole 6. Latest Version: 6 7. Selector: deploymentconfig=site 8. Replicas: 1 9. Triggers: Image(site@latest, auto=true), Config 10.Strategy: Recreate 11.Template: 12. Labels: app=site i. deploymentconfig=site
  21. 21. 1. Containers: 2. php: 3. Image: 172.30.34.145:5000/workshop/site@sha256:84f1195cb9fb30ae5bdd8eba5c27f2f2db0da60b26b92838417659130e aa 4. Port: 8080/TCP 5. Limits: 6. cpu: 366m 7. memory: 512Mi 8. Requests: 9. cpu: 10m 10. memory: 128Mi 11. Volume Mounts: <none> 12. Environment Variables: 13. PATH: /opt/app-root/src/bin:/opt/app- root/bin:/usr/local/sbin:/usr/local/bin:/usr/bin:/sbin:/bin:/opt/rh/rh-php56/root/usr/bin 14. STI_SCRIPTS_URL: image:///usr/libexec/s2i 15. STI_SCRIPTS_PATH: /usr/libexec/s2i 16. HOME: /opt/app-root/src 17. BASH_ENV: /opt/app-root/etc/scl_enable 18. ENV: /opt/app-root/etc/scl_enable 19. PROMPT_COMMAND: . /opt/app-root/etc/scl_enable 20. PHP_VERSION: 5.6 21. No volumes.
  22. 22. DeploymentConfig ➔Recreate ➔Rolling ➔Blue/Green ➔A/B
  23. 23. 1. type: Recreate 2. recreateParams: 3. mid: 4. execNewPod: 5. command: 6. - ./migrate-db 7. containerName: php 8. env: 9. - name: DATABASE_SERVICE_NAME 10. value: mysql 11. - name: DATABASE_NAME 12. value: site 13. - name: DATABASE_USER 14. value: admin 15. - name: DATABASE_PASSWORD 16. value: password 17. failurePolicy: Abort
  24. 24. DeploymentConfig ➔Recreate ➔Rolling ➔Blue/Green ➔A/B
  25. 25. 1. strategy: 2. type: Rolling 3. resources: {} 4. rollingParams: 5. intervalSeconds: 1 6. maxSurge: 25% 7. maxUnavailable: 25% 8. timeoutSeconds: 600 9. updatePeriodSeconds: 1
  26. 26. DeploymentConfig ➔Recreate ➔Rolling ➔Blue/Green ➔A/B
  27. 27. 1. kind: Route 2. metadata: 3. annotations: 4. haproxy.router.openshift.io/balance: roundrobin 5. openshift.io/generated-by: GetupCloudWebConsole 6. labels: 7. app: site 8. getup.io/component-name: site 9. name: siteab-workshop-getup-io 10. namespace: workshop 11.spec: 12. alternateBackends: 13. - kind: Service 14. name: siteb 15. weight: 30 16. host: siteab-workshop.getup.io 17. to: 18. kind: Service 19. name: site 20. weight: 70 21.status: 22. host: siteab-workshop.getup.io 23. routerName: router
  28. 28. 1. kind: Route 2. metadata: 3. annotations: 4. haproxy.router.openshift.io/balance: roundrobin 5. openshift.io/generated-by: GetupCloudWebConsole 6. labels: 7. app: site 8. getup.io/component-name: site 9. name: siteab-workshop-getup-io 10. namespace: workshop 11.spec: 12. alternateBackends: 13. - kind: Service 14. name: siteb 15. weight: 30 16. host: siteab-workshop.getup.io 17. to: 18. kind: Service 19. name: site 20. weight: 70 21.status: 22. host: siteab-workshop.getup.io 23. routerName: router
  29. 29. DeploymentConfig ➔Recreate ➔Rolling ➔Blue/Green ➔A/B
  30. 30. 1. spec: 2. host: site-workshop.getup.io 3. port: 4. targetPort: 8080-tcp 5. tls: 6. insecureEdgeTerminationPolicy: Allow 7. termination: edge 8. to: 9. kind: Service 10. name: siteb 11. weight: 100 12.status: 13. ingress: 14. - conditions: 15. - lastTransitionTime: 2016-12-08T21:44:51Z 16. status: "True" 17. type: Admitted 18. host: site-workshop.getup.io 19. routerName: router
  31. 31. Scaling VS
  32. 32. Scaling VS
  33. 33. Scaling VS
  34. 34. Application Healing
  35. 35. Application Healing - Readiness - Liveness

×