OpenShift Origin è la Platform-as-a-Service opensource di riferimento. Basata su Kubernetes e Docker, contiene features aggiuntive e integrazioni con altri componenti che semplificano le pratiche di DevOps.
Dopo una breve introduzione ad Openshift ed alla sua architettura, questa presentazione mostra come:
* fare il setup di applicazioni su OpenShift
* utilizzare OpenShift come tool di DevOps
* implementare application promotion e strategie di deployment avanzate utilizzando l'integrazione con Git e Jenkins
============
English version
============
OpenShift Origin is the most important opensource Platform-as-a-Service. Based on Kubernetes and Docker, it contains a lot of add-ons and integrations with other software components that simplify the DevOps practices.
After an introduction on OpenShift and its architecture, this presentation describes:
* how to setup an application on OpenShift
* how to use OpenShift as a DevOps tool
* how to implement application promotion and advanced deployment strategies using the native integration with Git and Jenkins
Presentation language: Italian
VictoriaMetrics Q1 Meet Up '24 - Community & News Update
DevOps of Python applications using OpenShift (Italian version)
1. DevOps di applicazioni Python
(e non solo) su OpenShift
Francesco Fiore, System Architect
PyCon Nove, 20 aprile 2018
2. 2
Agenda
• Cos’è OpenShift
• Cenni sull’architettura
• Setup di una semplice applicazione
• OpenShift per applicazioni Python: source-to-image
• Dietro le quinte: API objects
• Parametrizzare il setup di applicazioni usando i Template
• Git, OpenShift e Jenkins: integrazione nativa per la CI/CD
• Application lifecycle management
• Application promotion
• Strategie di deployment
3. 3
OpenShift overview
• Platform as a Service di Red Hat
• OpenShift Origin è un progetto opensource
• Basato su:
– Kubernetes (CaaS)
– Docker
– Atomic
• Add-on rispetto a k8s
– API objects
– Web console
– Software Defined Network
– Docker registry
– logging centralizzato
• Focus su application lifecycle management e automation
• Red Hat OpenShift Container Platform
4. 4
OpenShift vs Kubernetes
Source to
Image (S2I)
Integrated
Registry
Build
Configuration
Image Stream
Deployment
Configuration
Persistent
Volume Claims
Replication
Controller
Replica Sets Daemon Sets
Persistent
Volumes
Secrets Config Maps Services Routes
Software
Defined
Network (SDN)
Web console
Users and
Groups
Projects Namespaces
OpenShift Kubernetes
12. 12
Setup di una applicazione: API objects
• BuildConfig
– Build
• ImageStream
– ImageStreamTag
• DeploymentConfig
– ReplicationController
• Pod
• Service
apiVersion: v1
kind: Service
metadata:
annotations:
openshift.io/generated-by: OpenShiftNewApp
labels:
app: flask-sample
name: flask-sample
namespace: demo
spec:
clusterIP: 172.30.82.11
ports:
- name: 8080-tcp
port: 8080
protocol: TCP
targetPort: 8080
selector:
app: flask-sample
deploymentconfig: flask-sample
type: ClusterIP
13. 13
Creare un Template
• Aggiungere altri API object
– ConfigMap
– Secret
– PersistentVolumeClaim
– ...
• Personalizzare gli oggetti
– consumare ConfigMap, Secret, PVC, ecc.
– creare legami tra componenti applicativi (es. applicazione + database)
• Parametrizzare gli oggetti
• Riutilizzare il tutto
– su project/ambienti diversi
– per applicazioni diverse
15. 15
Automatizzare con Jenkins
• BuildConfig possono avere strategy jenkinsPipelineStrategy
– jenkinsfile
– webhook per il triggering da Git
• OpenShift si aspetta di trovare una istanza di Jenkins
– creazione della pipeline in Jenkins
– creazione di un Build
• In alternativa, jenkins-ephemeral
• Jenkins
– autoconfigurazione al primo deploy
• puntamenti a Kubernetes
• provisioning pipeline esistenti
– openshift jenkins plugin (deprecato da OpenShift 3.7)
– openshift jenkins client plugin (GA da OpenShift 3.7)
• Parametrizzare usando Template
– automatic setup e CI/CD
17. 17
Lifecycle management e software promotion
git
push/merge
•git flow/gitlab flow/...
•github/generic webhook
build
•build applicazione
•unit test (postCommit)
•build image
deploy DEV
•setup/update database (pre)
•deploy applicazione
•functional/integration test (post)
deploy
STAGING
•setup/update database (pre)
•deploy applicazione
•smoke test (post)
deploy
PRODUCTION
•setup/update database (pre)
•deploy applicazione
•smoke test (post)
18. 18
Rolling deployment
• Rimpiazzare le istanze della vecchia
versione con la nuova
– readiness check
– canary deployment
– rollback automatico
• builtin in OpenShift
• quando:
– no downtime
– N-1 compatibility
• lifecycle hooks
– pre
– post
pre hook
scale in
old rc
scale out
new rc
repeat
scaling
post hook
git push
build
deploy
19. 19
Recreate deployment
• Rimpiazzare tutte le istanze della
vecchia versione con la nuova
– readiness check
– rollback automatico
• builtin in OpenShift
• quando:
– migrazione dati
– no N-1 compatibility
– RWO volume
• downtime
• lifecycle hooks
– pre
– mid
– post
pre hook
scale in
to 0
mid hook
scale out
to N
post hook
git push
build
deploy
20. 20
Blue-green deployment
• Obiettivo: testing prima dello switch
del traffico
– smoke test
– integration test
• 2 versioni dell’applicazione
– production
– internal (release candidate)
• ‘internal’ può essere pubblica o
privata
• 2 service
• 2 deployment configuration
• switch gestito da Jenkins
• alternativa, API manager
– <public, staging, private> URL
• N-1 compatibility
git push
build
deploy
test
go live
23. 23
Canary deployment
• Obiettivo: ridurre il rischio di deploy
di una nuova versione
• come blue/green, ma entrambe
versioni online
• 1 service
• 2 deployment configuration
• molteplici shard
• proxy shard
– scale out/in deployment configs ->
traffic splitter (%)
• N-1 compatibility
• gestito da Jenkins
git push
build
deploy
go live
test
scale
out/in