João Brito @juniorjbn
Conceitos
Criando uma aplicação de teste
Hacking
S2i + OC = ➔ Assenble➔ Run
BuildConfig➔ Build Binário➔ Build Incremental
$ oc describe bc/site1. Name: site2. Namespace: workshop3. Created: 4 days ago4. Labels: app=site
i. template=site5. Annotations: openshift.io/generated-by=GetupCloudWebConsole6. Latest Version: 67. Strategy: Source8. URL: [email protected]:juniorjbn/php-test.git9. Ref: master10. ContextDir: /11. From Image: ImageStreamTag openshift/php:5.612. Output to: ImageStreamTag site:latest13. Build Run Policy: Serial14. Triggered by: ImageChange, Config15. Webhook Generic:
a. URL: https://api.getupcloud.com:443/oapi/v1/namespaces/workshop/buildconfigs/site/webhooks/42be0bdf5222c84b50854e98/generic
16. Webhook GitHub:a. URL: https://api.getupcloud.com:443/oapi/v1/namespaces/workshop/buildconfigs/site/webhooks/
9ac2640292ebe215c9b6f120/github17. Build Status Duration Creation Time18. site-3 complete 1m34s 2016-12-08 20:37:39 -0200 BRST
$ oc describe bc/site1. Name: site2. Namespace: workshop3. Created: 4 days ago4. Labels: app=site
i. template=site5. Annotations: openshift.io/generated-by=GetupCloudWebConsole6. Latest Version: 67. Strategy: Source8. URL: [email protected]:juniorjbn/php-test.git9. Ref: master10. ContextDir: /11. From Image: ImageStreamTag openshift/php:5.612. Output to: ImageStreamTag site:latest13. Build Run Policy: Serial14. Triggered by: ImageChange, Config15. Webhook Generic:
a. URL: https://api.getupcloud.com:443/oapi/v1/namespaces/workshop/buildconfigs/site/webhooks/42be0bdf5222c84b50854e98/generic
16. Webhook GitHub:a. URL: https://api.getupcloud.com:443/oapi/v1/namespaces/workshop/buildconfigs/site/webhooks/
9ac2640292ebe215c9b6f120/github17. Build Status Duration Creation Time18. site-3 complete 1m34s 2016-12-08 20:37:39 -0200 BRST
$ oc describe bc/site1. Name: site2. Namespace: workshop3. Created: 4 days ago4. Labels: app=site
i. template=site5. Annotations: openshift.io/generated-by=GetupCloudWebConsole6. Latest Version: 67. Strategy: Source8. URL: [email protected]:juniorjbn/php-test.git9. Ref: master10. ContextDir: /11. From Image: ImageStreamTag openshift/php:5.612. Output to: ImageStreamTag site:latest13. Build Run Policy: Serial14. Triggered by: ImageChange, Config15. Webhook Generic:
a. URL: https://api.getupcloud.com:443/oapi/v1/namespaces/workshop/buildconfigs/site/webhooks/42be0bdf5222c84b50854e98/generic
16. Webhook GitHub:a. URL: https://api.getupcloud.com:443/oapi/v1/namespaces/workshop/buildconfigs/site/webhooks/
9ac2640292ebe215c9b6f120/github17. Build Status Duration Creation Time18. site-3 complete 1m34s 2016-12-08 20:37:39 -0200 BRST
$ oc describe bc/site1. Name: site2. Namespace: workshop3. Created: 4 days ago4. Labels: app=site
i. template=site5. Annotations: openshift.io/generated-by=GetupCloudWebConsole6. Latest Version: 67. Strategy: Source8. URL: [email protected]:juniorjbn/php-test.git9. Ref: master10. ContextDir: /11. From Image: ImageStreamTag openshift/php:5.612. Output to: ImageStreamTag site:latest13. Build Run Policy: Serial14. Triggered by: ImageChange, Config15. Webhook Generic:
a. URL: https://api.getupcloud.com:443/oapi/v1/namespaces/workshop/buildconfigs/site/webhooks/42be0bdf5222c84b50854e98/generic
16. Webhook GitHub:a. URL: https://api.getupcloud.com:443/oapi/v1/namespaces/workshop/buildconfigs/site/
webhooks/9ac2640292ebe215c9b6f120/github17. Build Status Duration Creation Time18. site-3 complete 1m34s 2016-12-08 20:37:39 -0200 BRST
Build Binário$ oc edit bc/app spec.source: type: Binary
Agora posso usar o cod local$ oc start-build site --from-dir=.
$ oc describe bc/site1. Name: site2. Namespace: workshop3. Created: 4 days ago4. Labels: app=site
i. template=site5. Annotations: openshift.io/generated-by=GetupCloudWebConsole6. Latest Version: 67. Strategy: Source8. URL: [email protected]:juniorjbn/php-test.git9. Ref: master10. ContextDir: /11. From Image: ImageStreamTag openshift/php:5.612. Output to: ImageStreamTag site:latest13. Build Run Policy: Serial14. Triggered by: ImageChange, Config15. Webhook Generic:
a. URL: https://api.getupcloud.com:443/oapi/v1/namespaces/workshop/buildconfigs/site/webhooks/42be0bdf5222c84b50854e98/generic
16. Webhook GitHub:a. URL: https://api.getupcloud.com:443/oapi/v1/namespaces/workshop/buildconfigs/site/webhooks/
9ac2640292ebe215c9b6f120/github17. Build Status Duration Creation Time18. site-3 complete 1m34s 2016-12-08 20:37:39 -0200 BRST
$ oc describe bc/site1. Name: site2. Namespace: workshop3. Created: 6 days ago4. Labels: app=site5. template=site6. Annotations: openshift.io/generated-by=GetupCloudWebConsole7. Latest Version: 88. Strategy: Source9. Binary: provided on build10. From Image: ImageStreamTag openshift/php:5.611. Output to: ImageStreamTag site:latest12. Build Run Policy: Serial13. Triggered by: ImageChange, Config14. Webhook Generic:15. URL: https://api.getupcloud.com:443/oapi/v1/namespaces/workshop/
buildconfigs/site/webhooks/42be0bdf5222c84b50854e98/generic16. AllowEnv: false17. Webhook GitHub:18. URL: https://api.getupcloud.com:443/oapi/v1/namespaces/workshop/buildconfigs/site/
webhooks/9ac2640292ebe215c9b6f120/github19. Build Status Duration Creation Time20. site-8 failed 3s 2016-12-13 10:37:47 -0200 BRST
Build Binário$ oc edit bc/app spec.source: type: Binary
Agora posso usar o cod local$ oc start-build site --from-dir=.
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
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
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
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
DeploymentConfig➔ Recreate ➔ Rolling
➔ Blue/Green➔ A/B
$ oc describe dc/site1. Name: site2. Namespace: workshop3. Created: 6 days ago4. Labels: app=site
i. template=site5. Annotations: iconClass=icon-php
i. openshift.io/generated-by=GetupCloudWebConsole6. Latest Version: 67. Selector: deploymentconfig=site8. Replicas: 19. Triggers: Image(site@latest, auto=true), Config10.Strategy: Recreate11.Template:12. Labels: app=site
i. deploymentconfig=site
1. Containers:2. php:3. Image:
172.30.34.145:5000/workshop/site@sha256:84f1195cb9fb30ae5bdd8eba5c27f2f2db0da60b26b92838417659130eaa
4. Port: 8080/TCP5. Limits:6. cpu: 366m7. memory: 512Mi8. Requests:9. cpu: 10m10. memory: 128Mi11. 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/bin14. STI_SCRIPTS_URL: image:///usr/libexec/s2i15. STI_SCRIPTS_PATH: /usr/libexec/s2i16. HOME: /opt/app-root/src17. BASH_ENV: /opt/app-root/etc/scl_enable18. ENV: /opt/app-root/etc/scl_enable19. PROMPT_COMMAND: . /opt/app-root/etc/scl_enable20. PHP_VERSION: 5.621. No volumes.
DeploymentConfig➔ Recreate ➔ Rolling
➔ Blue/Green➔ A/B
1. type: Recreate 2. recreateParams:3. mid: 4. execNewPod: 5. command:6. - ./migrate-db7. containerName: php 8. env:9. - name: DATABASE_SERVICE_NAME10. value: mysql11. - name: DATABASE_NAME12. value: site13. - name: DATABASE_USER14. value: admin15. - name: DATABASE_PASSWORD16. value: password17. failurePolicy: Abort
DeploymentConfig➔ Recreate ➔ Rolling
➔ Blue/Green➔ A/B
1. strategy:2. type: Rolling3. resources: {}4. rollingParams:5. intervalSeconds: 1 6. maxSurge: 25% 7. maxUnavailable: 25% 8. timeoutSeconds: 600 9. updatePeriodSeconds: 1
DeploymentConfig➔ Recreate ➔ Rolling
➔ Blue/Green➔ A/B
1. kind: Route2. metadata:3. annotations:4. haproxy.router.openshift.io/balance: roundrobin5. openshift.io/generated-by: GetupCloudWebConsole6. labels:7. app: site8. getup.io/component-name: site9. name: siteab-workshop-getup-io10. namespace: workshop11.spec:12. alternateBackends:13. - kind: Service14. name: siteb15. weight: 3016. host: siteab-workshop.getup.io17. to:18. kind: Service19. name: site20. weight: 7021.status:22. host: siteab-workshop.getup.io23. routerName: router
1. kind: Route2. metadata:3. annotations:4. haproxy.router.openshift.io/balance: roundrobin5. openshift.io/generated-by: GetupCloudWebConsole6. labels:7. app: site8. getup.io/component-name: site9. name: siteab-workshop-getup-io10. namespace: workshop11.spec:12. alternateBackends:13. - kind: Service14. name: siteb15. weight: 3016. host: siteab-workshop.getup.io17. to:18. kind: Service19. name: site20. weight: 7021.status:22. host: siteab-workshop.getup.io23. routerName: router
DeploymentConfig➔ Recreate ➔ Rolling
➔ Blue/Green
➔ A/B
1. spec:2. host: site-workshop.getup.io3. port:4. targetPort: 8080-tcp5. tls:6. insecureEdgeTerminationPolicy: Allow7. termination: edge8. to:9. kind: Service10. name: siteb11. weight: 10012.status:13. ingress:14. - conditions:15. - lastTransitionTime: 2016-12-08T21:44:51Z16. status: "True"17. type: Admitted18. host: site-workshop.getup.io19. routerName: router
Scaling
VS
Scaling
VS
Scaling
VS
Application Healing
Application Healing
- Readiness- Liveness
Recommended