KUBERNETES PATTERNS...One shot action before Pod starts Needs to be idempotent Has own resource...
Transcript of KUBERNETES PATTERNS...One shot action before Pod starts Needs to be idempotent Has own resource...
![Page 1: KUBERNETES PATTERNS...One shot action before Pod starts Needs to be idempotent Has own resource requirements Pod app containers init containers Container Container Container Container](https://reader030.fdocuments.net/reader030/viewer/2022041014/5ec568cc1d869250ba56ef86/html5/thumbnails/1.jpg)
"m " fo r menu , "? " fo r o the r sho r tcu ts
KUBERNETESPATTERNS
DevoxxMorocco, 2018-11-28,Marrakesh
RolandHuß,RedHat, @ro14nd
![Page 2: KUBERNETES PATTERNS...One shot action before Pod starts Needs to be idempotent Has own resource requirements Pod app containers init containers Container Container Container Container](https://reader030.fdocuments.net/reader030/viewer/2022041014/5ec568cc1d869250ba56ef86/html5/thumbnails/2.jpg)
AGENDA
KubernetesPatternsCategories:
FoundationalPatternsStructuralPatternsConfigurationalPatternsAdvancedPatterns
![Page 3: KUBERNETES PATTERNS...One shot action before Pod starts Needs to be idempotent Has own resource requirements Pod app containers init containers Container Container Container Container](https://reader030.fdocuments.net/reader030/viewer/2022041014/5ec568cc1d869250ba56ef86/html5/thumbnails/3.jpg)
![Page 4: KUBERNETES PATTERNS...One shot action before Pod starts Needs to be idempotent Has own resource requirements Pod app containers init containers Container Container Container Container](https://reader030.fdocuments.net/reader030/viewer/2022041014/5ec568cc1d869250ba56ef86/html5/thumbnails/4.jpg)
KUBERNETESOpenSourcecontainerorchestrationsystem
SchedulingSelf-healingHorizontalscalingServicediscoveryRolloutandRollbacks
Declarativeresource-centricRESTAPI
![Page 5: KUBERNETES PATTERNS...One shot action before Pod starts Needs to be idempotent Has own resource requirements Pod app containers init containers Container Container Container Container](https://reader030.fdocuments.net/reader030/viewer/2022041014/5ec568cc1d869250ba56ef86/html5/thumbnails/5.jpg)
DesignPatterns
M i c h a e l M a n d i b e rg , CC BY - SA 2 . 0 , h t t p s : / / fl i c . k r /p / 67Cb6 Jm
![Page 6: KUBERNETES PATTERNS...One shot action before Pod starts Needs to be idempotent Has own resource requirements Pod app containers init containers Container Container Container Container](https://reader030.fdocuments.net/reader030/viewer/2022041014/5ec568cc1d869250ba56ef86/html5/thumbnails/6.jpg)
DESIGNPATTERN
ADesignPatterndescribesarepeatablesolutiontoasoftwareengineeringproblem.
![Page 7: KUBERNETES PATTERNS...One shot action before Pod starts Needs to be idempotent Has own resource requirements Pod app containers init containers Container Container Container Container](https://reader030.fdocuments.net/reader030/viewer/2022041014/5ec568cc1d869250ba56ef86/html5/thumbnails/7.jpg)
![Page 8: KUBERNETES PATTERNS...One shot action before Pod starts Needs to be idempotent Has own resource requirements Pod app containers init containers Container Container Container Container](https://reader030.fdocuments.net/reader030/viewer/2022041014/5ec568cc1d869250ba56ef86/html5/thumbnails/8.jpg)
https://leanpub.com/k8spatterns
![Page 9: KUBERNETES PATTERNS...One shot action before Pod starts Needs to be idempotent Has own resource requirements Pod app containers init containers Container Container Container Container](https://reader030.fdocuments.net/reader030/viewer/2022041014/5ec568cc1d869250ba56ef86/html5/thumbnails/9.jpg)
STRUCTUREProblemPatterns:
NameSolution
http://www.martinfowler.com/articles/writingPatterns.html
![Page 10: KUBERNETES PATTERNS...One shot action before Pod starts Needs to be idempotent Has own resource requirements Pod app containers init containers Container Container Container Container](https://reader030.fdocuments.net/reader030/viewer/2022041014/5ec568cc1d869250ba56ef86/html5/thumbnails/10.jpg)
FOUNDATIONALPATTERNS
![Page 11: KUBERNETES PATTERNS...One shot action before Pod starts Needs to be idempotent Has own resource requirements Pod app containers init containers Container Container Container Container](https://reader030.fdocuments.net/reader030/viewer/2022041014/5ec568cc1d869250ba56ef86/html5/thumbnails/11.jpg)
AutomatableUnit
HowcanwecreateandmanageapplicationswithKubernetes?
Pods:AtomicunitofcontainersServices:EntrypointtopodsGroupingviaLabels,Annotations,Namespaces
![Page 12: KUBERNETES PATTERNS...One shot action before Pod starts Needs to be idempotent Has own resource requirements Pod app containers init containers Container Container Container Container](https://reader030.fdocuments.net/reader030/viewer/2022041014/5ec568cc1d869250ba56ef86/html5/thumbnails/12.jpg)
rhuss/log-sidecar:2.3
10.1.29.2 name:pong
version:1
rhuss/pong:1
POD
KubernetesAtomOneormorecontainerssharing:
IPandportsVolumes
EphemeralIPaddress
![Page 13: KUBERNETES PATTERNS...One shot action before Pod starts Needs to be idempotent Has own resource requirements Pod app containers init containers Container Container Container Container](https://reader030.fdocuments.net/reader030/viewer/2022041014/5ec568cc1d869250ba56ef86/html5/thumbnails/13.jpg)
PODDECLARATION apiVersion: v1 kind: Pod metadata: name: pong labels: name: pong version: "1" spec: containers: - image: "rhuss/pong:1" name: pong ports: - containerPort: 8080 - image: "rhuss/log-sidecar:2.3" name: log
![Page 14: KUBERNETES PATTERNS...One shot action before Pod starts Needs to be idempotent Has own resource requirements Pod app containers init containers Container Container Container Container](https://reader030.fdocuments.net/reader030/viewer/2022041014/5ec568cc1d869250ba56ef86/html5/thumbnails/14.jpg)
REPLICASETResponsibleformanagingPodsreplicas:NumberofPodcopiestokeepLabelselectorchoosesPodsHoldsatemplateforcreatingnewPods
![Page 15: KUBERNETES PATTERNS...One shot action before Pod starts Needs to be idempotent Has own resource requirements Pod app containers init containers Container Container Container Container](https://reader030.fdocuments.net/reader030/viewer/2022041014/5ec568cc1d869250ba56ef86/html5/thumbnails/15.jpg)
10.1.29.3
name:pong
version:1
10.1.29.4
name:pong
version:1
name:pong
version:1Selector:
ReplicaSet
10.1.29.2
name:pong
version:1
replicas: 3
![Page 16: KUBERNETES PATTERNS...One shot action before Pod starts Needs to be idempotent Has own resource requirements Pod app containers init containers Container Container Container Container](https://reader030.fdocuments.net/reader030/viewer/2022041014/5ec568cc1d869250ba56ef86/html5/thumbnails/16.jpg)
SERVICEEntrypointforasetofPodsPodschosenbyLabelselectorPermanentIPaddress
10.1.29.3
name:pong
version:1
10.1.29.4
name:pong
version:1
name:pongSelector:
10.1.29.2
name:pong
version:1
10.200.100.251
![Page 17: KUBERNETES PATTERNS...One shot action before Pod starts Needs to be idempotent Has own resource requirements Pod app containers init containers Container Container Container Container](https://reader030.fdocuments.net/reader030/viewer/2022041014/5ec568cc1d869250ba56ef86/html5/thumbnails/17.jpg)
CronJob
DaemonSet ReplicaSet StatefulSet JobReplication
Controller
Pod
ServiceHorizontalPod
Autoscaler
Container
(yourcode)
PodDisruption
BudgetIngress
Volume
ConfigMapPersistent
VolumeClaimSecret
Deployment
![Page 18: KUBERNETES PATTERNS...One shot action before Pod starts Needs to be idempotent Has own resource requirements Pod app containers init containers Container Container Container Container](https://reader030.fdocuments.net/reader030/viewer/2022041014/5ec568cc1d869250ba56ef86/html5/thumbnails/18.jpg)
PredictableDemands
Howcanwehandleresourcerequirementsdeterministically?
Requirementsshouldbedeclaredtohelpin:
MatchinginfrastructureservicesSchedulingdecisionsCapacityplanning
![Page 19: KUBERNETES PATTERNS...One shot action before Pod starts Needs to be idempotent Has own resource requirements Pod app containers init containers Container Container Container Container](https://reader030.fdocuments.net/reader030/viewer/2022041014/5ec568cc1d869250ba56ef86/html5/thumbnails/19.jpg)
RUNTIMEDEPENDENCIES
PersistentVolumesHostportsConfigurationviaConfigMapsandSecrets
![Page 20: KUBERNETES PATTERNS...One shot action before Pod starts Needs to be idempotent Has own resource requirements Pod app containers init containers Container Container Container Container](https://reader030.fdocuments.net/reader030/viewer/2022041014/5ec568cc1d869250ba56ef86/html5/thumbnails/20.jpg)
RESOURCEPROFILESResources:
CPU,Network(compressible)Memory(incompressible)
App:DeclarationofresourcerequestsandlimitsPlatform:Resourcequotasandlimitranges
![Page 21: KUBERNETES PATTERNS...One shot action before Pod starts Needs to be idempotent Has own resource requirements Pod app containers init containers Container Container Container Container](https://reader030.fdocuments.net/reader030/viewer/2022041014/5ec568cc1d869250ba56ef86/html5/thumbnails/21.jpg)
apiVersion: v1kind: Podmetadata: name: http-serverspec: containers: - image: nginx name: nginx resources: requests: cpu: 200m memory: 100Mi limits: cpu: 300m memory: 200Mi
![Page 22: KUBERNETES PATTERNS...One shot action before Pod starts Needs to be idempotent Has own resource requirements Pod app containers init containers Container Container Container Container](https://reader030.fdocuments.net/reader030/viewer/2022041014/5ec568cc1d869250ba56ef86/html5/thumbnails/22.jpg)
QOSCLASSESBestEffort
Norequestsorlimits
Burstablerequests<limits
Guaranteedrequests==limits
![Page 23: KUBERNETES PATTERNS...One shot action before Pod starts Needs to be idempotent Has own resource requirements Pod app containers init containers Container Container Container Container](https://reader030.fdocuments.net/reader030/viewer/2022041014/5ec568cc1d869250ba56ef86/html5/thumbnails/23.jpg)
DeclarativeDeployment
Howcanapplicationsbedeployedandupdated?
DeclarativeversusImperativedeploymentVariousupdatestrategies
![Page 24: KUBERNETES PATTERNS...One shot action before Pod starts Needs to be idempotent Has own resource requirements Pod app containers init containers Container Container Container Container](https://reader030.fdocuments.net/reader030/viewer/2022041014/5ec568cc1d869250ba56ef86/html5/thumbnails/24.jpg)
DEPLOYMENTHoldstemplateforPodCreatesReplicaSetontheflyAllowsrollbackUpdatestrategiesdeclarableInspiredbyDeploymentConfigfromOpenShift
![Page 25: KUBERNETES PATTERNS...One shot action before Pod starts Needs to be idempotent Has own resource requirements Pod app containers init containers Container Container Container Container](https://reader030.fdocuments.net/reader030/viewer/2022041014/5ec568cc1d869250ba56ef86/html5/thumbnails/25.jpg)
ROLLING
v1.0 v1.0 v1.0
Service
v1.1 v1.1
![Page 26: KUBERNETES PATTERNS...One shot action before Pod starts Needs to be idempotent Has own resource requirements Pod app containers init containers Container Container Container Container](https://reader030.fdocuments.net/reader030/viewer/2022041014/5ec568cc1d869250ba56ef86/html5/thumbnails/26.jpg)
FIXED
v1.0 v1.0 v1.0
Service
v1.1 v1.1 v1.1
![Page 27: KUBERNETES PATTERNS...One shot action before Pod starts Needs to be idempotent Has own resource requirements Pod app containers init containers Container Container Container Container](https://reader030.fdocuments.net/reader030/viewer/2022041014/5ec568cc1d869250ba56ef86/html5/thumbnails/27.jpg)
CANARY
v1.0 v1.0 v1.0
Service
v1.1
![Page 28: KUBERNETES PATTERNS...One shot action before Pod starts Needs to be idempotent Has own resource requirements Pod app containers init containers Container Container Container Container](https://reader030.fdocuments.net/reader030/viewer/2022041014/5ec568cc1d869250ba56ef86/html5/thumbnails/28.jpg)
BLUE-GREEN
v1.0 v1.0 v1.0
Service
v1.1 v1.1 v1.1
![Page 29: KUBERNETES PATTERNS...One shot action before Pod starts Needs to be idempotent Has own resource requirements Pod app containers init containers Container Container Container Container](https://reader030.fdocuments.net/reader030/viewer/2022041014/5ec568cc1d869250ba56ef86/html5/thumbnails/29.jpg)
SUMMARY
time
instances
time
instances
time
instances
time
instances
RollingDeployment RecreateDeployment
Blue-GreenRelease CanaryRelease
0…1capacity
2xcapacity
![Page 30: KUBERNETES PATTERNS...One shot action before Pod starts Needs to be idempotent Has own resource requirements Pod app containers init containers Container Container Container Container](https://reader030.fdocuments.net/reader030/viewer/2022041014/5ec568cc1d869250ba56ef86/html5/thumbnails/30.jpg)
STRUCTURALPATTERNS
![Page 31: KUBERNETES PATTERNS...One shot action before Pod starts Needs to be idempotent Has own resource requirements Pod app containers init containers Container Container Container Container](https://reader030.fdocuments.net/reader030/viewer/2022041014/5ec568cc1d869250ba56ef86/html5/thumbnails/31.jpg)
Initializer
HowcanIinitializemycontainerizedapplications?
Initcontainer:PartofaPodOneshotactionbeforePodstartsNeedstobeidempotentHasownresourcerequirements
![Page 32: KUBERNETES PATTERNS...One shot action before Pod starts Needs to be idempotent Has own resource requirements Pod app containers init containers Container Container Container Container](https://reader030.fdocuments.net/reader030/viewer/2022041014/5ec568cc1d869250ba56ef86/html5/thumbnails/32.jpg)
Pod
app containers
init containers
Container Container Container
Container Container
![Page 33: KUBERNETES PATTERNS...One shot action before Pod starts Needs to be idempotent Has own resource requirements Pod app containers init containers Container Container Container Container](https://reader030.fdocuments.net/reader030/viewer/2022041014/5ec568cc1d869250ba56ef86/html5/thumbnails/33.jpg)
Sidecar
HowcanIextendthefunctionalityofanexistingcontainer?
RuntimecollaborationofcontainersConnectedviasharedresources:
NetworkVolumes
![Page 34: KUBERNETES PATTERNS...One shot action before Pod starts Needs to be idempotent Has own resource requirements Pod app containers init containers Container Container Container Container](https://reader030.fdocuments.net/reader030/viewer/2022041014/5ec568cc1d869250ba56ef86/html5/thumbnails/34.jpg)
Pod
Sidecar
git
Main Container
node.js
Disk
![Page 35: KUBERNETES PATTERNS...One shot action before Pod starts Needs to be idempotent Has own resource requirements Pod app containers init containers Container Container Container Container](https://reader030.fdocuments.net/reader030/viewer/2022041014/5ec568cc1d869250ba56ef86/html5/thumbnails/35.jpg)
Ambassador
Howtodecoupleacontainer'saccesstotheoutsideworld?
AlsoknownasProxySpecializationofaSidecarE.g.infrastructureservices
CircuitbreakerTracing
![Page 36: KUBERNETES PATTERNS...One shot action before Pod starts Needs to be idempotent Has own resource requirements Pod app containers init containers Container Container Container Container](https://reader030.fdocuments.net/reader030/viewer/2022041014/5ec568cc1d869250ba56ef86/html5/thumbnails/36.jpg)
Pod
localhost
Container
memcached
Container
python
![Page 37: KUBERNETES PATTERNS...One shot action before Pod starts Needs to be idempotent Has own resource requirements Pod app containers init containers Container Container Container Container](https://reader030.fdocuments.net/reader030/viewer/2022041014/5ec568cc1d869250ba56ef86/html5/thumbnails/37.jpg)
Adapter
Howtodecoupleaccesstoacontainerfromtheoutsideworld?
OppositeofAmbassadorUniformaccesstoapplicationExamples:
MonitoringLogging
![Page 38: KUBERNETES PATTERNS...One shot action before Pod starts Needs to be idempotent Has own resource requirements Pod app containers init containers Container Container Container Container](https://reader030.fdocuments.net/reader030/viewer/2022041014/5ec568cc1d869250ba56ef86/html5/thumbnails/38.jpg)
Pod
Sidecar
monitoring
Main Container
java
Disk
![Page 39: KUBERNETES PATTERNS...One shot action before Pod starts Needs to be idempotent Has own resource requirements Pod app containers init containers Container Container Container Container](https://reader030.fdocuments.net/reader030/viewer/2022041014/5ec568cc1d869250ba56ef86/html5/thumbnails/39.jpg)
CONFIGURATIONALPATTERNS
![Page 40: KUBERNETES PATTERNS...One shot action before Pod starts Needs to be idempotent Has own resource requirements Pod app containers init containers Container Container Container Container](https://reader030.fdocuments.net/reader030/viewer/2022041014/5ec568cc1d869250ba56ef86/html5/thumbnails/40.jpg)
Howcanapplicationsbeconfiguredfordifferentenvironments?
![Page 41: KUBERNETES PATTERNS...One shot action before Pod starts Needs to be idempotent Has own resource requirements Pod app containers init containers Container Container Container Container](https://reader030.fdocuments.net/reader030/viewer/2022041014/5ec568cc1d869250ba56ef86/html5/thumbnails/41.jpg)
EnvVarConfigurationUniversalapplicableRecommendedbytheTwelveFactorAppmanifestoCanbeonlysetduringstartupofapplication
![Page 42: KUBERNETES PATTERNS...One shot action before Pod starts Needs to be idempotent Has own resource requirements Pod app containers init containers Container Container Container Container](https://reader030.fdocuments.net/reader030/viewer/2022041014/5ec568cc1d869250ba56ef86/html5/thumbnails/42.jpg)
kind: Podspec: containers: - env: - name: DB_HOST value: "prod-database.prod.intranet" - name: DB_PASSWORD valueFrom: secretKeyRef: name: "db-passwords" key: "monogdb.password" - name: DB_USER valueFrom: configMapKeyRef: name: "db-users" key: "mongodb.user" image: acme/bookmark-service:1.0.4
![Page 43: KUBERNETES PATTERNS...One shot action before Pod starts Needs to be idempotent Has own resource requirements Pod app containers init containers Container Container Container Container](https://reader030.fdocuments.net/reader030/viewer/2022041014/5ec568cc1d869250ba56ef86/html5/thumbnails/43.jpg)
ConfigurationResource
ConfigMapandSecret:IntrinisicK8sresourcesCanbeusedintwoways:
ReferenceforenvironmentvariablesFilesmappedtoavolume
![Page 44: KUBERNETES PATTERNS...One shot action before Pod starts Needs to be idempotent Has own resource requirements Pod app containers init containers Container Container Container Container](https://reader030.fdocuments.net/reader030/viewer/2022041014/5ec568cc1d869250ba56ef86/html5/thumbnails/44.jpg)
kind: ConfigMapmetadata: name: spring-boot-configdata: JAVA_OPTIONS: "-Xmx512m" application.properties: | welcome.message=Hello !!! server.port=8080
kind: Podspec: containers: - name: web volumeMounts: - name: config-volume mountPath: /etc/config # ... volumes: - name: config-volume configMap: name: spring-boot-config
![Page 45: KUBERNETES PATTERNS...One shot action before Pod starts Needs to be idempotent Has own resource requirements Pod app containers init containers Container Container Container Container](https://reader030.fdocuments.net/reader030/viewer/2022041014/5ec568cc1d869250ba56ef86/html5/thumbnails/45.jpg)
ConfigurationTemplate
ConfigMapnotsuitableforlargeconfigurationManagingsimilarconfigurationIngredients:
Init-containerwithtemplateprocessorandtemplatesParametersfromaConfigMapVolume
![Page 46: KUBERNETES PATTERNS...One shot action before Pod starts Needs to be idempotent Has own resource requirements Pod app containers init containers Container Container Container Container](https://reader030.fdocuments.net/reader030/viewer/2022041014/5ec568cc1d869250ba56ef86/html5/thumbnails/46.jpg)
CONFIGURATIONTEMPLATE
Pod
app container
init-container
Template Processor
Application
emptyDir volume
config-map volume
Configuration Files
Template ParametersConfiguration
Templates
![Page 47: KUBERNETES PATTERNS...One shot action before Pod starts Needs to be idempotent Has own resource requirements Pod app containers init containers Container Container Container Container](https://reader030.fdocuments.net/reader030/viewer/2022041014/5ec568cc1d869250ba56ef86/html5/thumbnails/47.jpg)
DISCUSSIONGoodforlarge,similarconfigurationsetsperenvironmentParameterisationviaConfigMapseasyMorecomplex
![Page 48: KUBERNETES PATTERNS...One shot action before Pod starts Needs to be idempotent Has own resource requirements Pod app containers init containers Container Container Container Container](https://reader030.fdocuments.net/reader030/viewer/2022041014/5ec568cc1d869250ba56ef86/html5/thumbnails/48.jpg)
ImmutableConfiguration
ConfigurationisputintoacontaineritselfConfigurationcontainerislinkedtoapplicationcontainerduringruntime
![Page 49: KUBERNETES PATTERNS...One shot action before Pod starts Needs to be idempotent Has own resource requirements Pod app containers init containers Container Container Container Container](https://reader030.fdocuments.net/reader030/viewer/2022041014/5ec568cc1d869250ba56ef86/html5/thumbnails/49.jpg)
CONTAINERVOLUMES
app container
Application
config container
Configuration Files
/config /configVolumemount
NotdirectlysupportedbyK8sdocker-flexvol:K8sFlexVolumedriverforDockervolumes
![Page 50: KUBERNETES PATTERNS...One shot action before Pod starts Needs to be idempotent Has own resource requirements Pod app containers init containers Container Container Container Container](https://reader030.fdocuments.net/reader030/viewer/2022041014/5ec568cc1d869250ba56ef86/html5/thumbnails/50.jpg)
kind: Podmetadata: name: nginxspec: containers: - name: nginx image: nginx volumeMounts: - name: test mountPath: /data ports: - containerPort: 80 volumes: - name: test flexVolume: driver: "dims.io/docker-flexvol" options: image: "my-container-image" name: "/data-store"
![Page 51: KUBERNETES PATTERNS...One shot action before Pod starts Needs to be idempotent Has own resource requirements Pod app containers init containers Container Container Container Container](https://reader030.fdocuments.net/reader030/viewer/2022041014/5ec568cc1d869250ba56ef86/html5/thumbnails/51.jpg)
INITIALIZER
Pod
app container init-container
Configuration ImageApplication
emptyDir volume
Configuration Files
/var/config /config
mount©mount&use
![Page 52: KUBERNETES PATTERNS...One shot action before Pod starts Needs to be idempotent Has own resource requirements Pod app containers init containers Container Container Container Container](https://reader030.fdocuments.net/reader030/viewer/2022041014/5ec568cc1d869250ba56ef86/html5/thumbnails/52.jpg)
Dockerfileforinitcontainer:
Buildconfigimage:
FROM busybox
ADD dev.properties /config-src/demo.properties# ... add more to /config-src
# Using a shell here in order to resolve wildcardsENTRYPOINT [ "sh", "-c", \ "cp /config-src/* $1", "--" ]
docker build -t k8spatterns/config-dev:1 .
![Page 53: KUBERNETES PATTERNS...One shot action before Pod starts Needs to be idempotent Has own resource requirements Pod app containers init containers Container Container Container Container](https://reader030.fdocuments.net/reader030/viewer/2022041014/5ec568cc1d869250ba56ef86/html5/thumbnails/53.jpg)
spec: initContainers: - image: k8spatterns/config-dev:1 name: init args: - "/config" volumeMounts: - mountPath: "/config" name: config-directory containers: - image: k8spatterns/demo:1 name: demo volumeMounts: - mountPath: "/config" name: config-directory volumes: - name: config-directory emptyDir: {}
![Page 54: KUBERNETES PATTERNS...One shot action before Pod starts Needs to be idempotent Has own resource requirements Pod app containers init containers Container Container Container Container](https://reader030.fdocuments.net/reader030/viewer/2022041014/5ec568cc1d869250ba56ef86/html5/thumbnails/54.jpg)
DISCUSSIONImmutableConfiguration...
canbeversionedcanbedistributedviaaregistryisimmutablecanbearbitrarylarge
ParameterisationviaOpenShiftTemplates
![Page 55: KUBERNETES PATTERNS...One shot action before Pod starts Needs to be idempotent Has own resource requirements Pod app containers init containers Container Container Container Container](https://reader030.fdocuments.net/reader030/viewer/2022041014/5ec568cc1d869250ba56ef86/html5/thumbnails/55.jpg)
ADVANCEDPATTERNS
![Page 56: KUBERNETES PATTERNS...One shot action before Pod starts Needs to be idempotent Has own resource requirements Pod app containers init containers Container Container Container Container](https://reader030.fdocuments.net/reader030/viewer/2022041014/5ec568cc1d869250ba56ef86/html5/thumbnails/56.jpg)
Controller
HowcanIextendtheplatformitselfwithoutchangingit?
WatchingresourcesbyregisteringforKuberneteseventsReactingonchangesinresourcedeclarations
![Page 57: KUBERNETES PATTERNS...One shot action before Pod starts Needs to be idempotent Has own resource requirements Pod app containers init containers Container Container Container Container](https://reader030.fdocuments.net/reader030/viewer/2022041014/5ec568cc1d869250ba56ef86/html5/thumbnails/57.jpg)
CONTROLLERManagedpodlisteningforKubernetesAPIeventsStateReconciliation:Makethecurrentstatelikethedeclareddesiredstate
![Page 58: KUBERNETES PATTERNS...One shot action before Pod starts Needs to be idempotent Has own resource requirements Pod app containers init containers Container Container Container Container](https://reader030.fdocuments.net/reader030/viewer/2022041014/5ec568cc1d869250ba56ef86/html5/thumbnails/58.jpg)
CATEGORIESExtensionController:ExtendtheKubernetesplatformitselfApplicationController:CombineKuberneteswithanapplicationspecificdomain
![Page 59: KUBERNETES PATTERNS...One shot action before Pod starts Needs to be idempotent Has own resource requirements Pod app containers init containers Container Container Container Container](https://reader030.fdocuments.net/reader030/viewer/2022041014/5ec568cc1d869250ba56ef86/html5/thumbnails/59.jpg)
Operator
HowcanIintroducedomainspecificresourcesandreactonthem?
CustomResourceDefinition(CRD)managedbyKubernetesAccessibleviatheKubernetesAPIWatchedbyControllers
![Page 60: KUBERNETES PATTERNS...One shot action before Pod starts Needs to be idempotent Has own resource requirements Pod app containers init containers Container Container Container Container](https://reader030.fdocuments.net/reader030/viewer/2022041014/5ec568cc1d869250ba56ef86/html5/thumbnails/60.jpg)
EXAMPLECRDapiVersion: apiextensions.k8s.io/v1beta1kind: CustomResourceDefinitionmetadata: name: prometheuses.monitoring.coreos.comspec: group: monitoring.coreos.com names: kind: Prometheus plural: prometheuses scope: Namespaced version: v1 validation: ....
![Page 61: KUBERNETES PATTERNS...One shot action before Pod starts Needs to be idempotent Has own resource requirements Pod app containers init containers Container Container Container Container](https://reader030.fdocuments.net/reader030/viewer/2022041014/5ec568cc1d869250ba56ef86/html5/thumbnails/61.jpg)
EXAMPLECRDapiVersion: monitoring.coreos.com/v1kind: Prometheusmetadata: name: prometheusspec: serviceMonitorSelector: matchLabels: team: frontend resources: requests: memory: 400Mi
![Page 62: KUBERNETES PATTERNS...One shot action before Pod starts Needs to be idempotent Has own resource requirements Pod app containers init containers Container Container Container Container](https://reader030.fdocuments.net/reader030/viewer/2022041014/5ec568cc1d869250ba56ef86/html5/thumbnails/62.jpg)
OPERATORFRAMEWORK
OperatorSDKScaffoldingforaGolangOperatorProjectHighlevelabstractionforobservingeventsMarshallingofcustomresources
OperatorLifecycleManagerOperatorMetering
![Page 63: KUBERNETES PATTERNS...One shot action before Pod starts Needs to be idempotent Has own resource requirements Pod app containers init containers Container Container Container Container](https://reader030.fdocuments.net/reader030/viewer/2022041014/5ec568cc1d869250ba56ef86/html5/thumbnails/63.jpg)
SPECTRUMOperator with CRD
ExtensionController ApplicationController
Expose Controller
ConfigMap Controller
etcd Operator
Prometheus Operator
EAI Operator
![Page 64: KUBERNETES PATTERNS...One shot action before Pod starts Needs to be idempotent Has own resource requirements Pod app containers init containers Container Container Container Container](https://reader030.fdocuments.net/reader030/viewer/2022041014/5ec568cc1d869250ba56ef86/html5/thumbnails/64.jpg)
QUESTIONS?
Twitter ro14nd
Book https://leanpub.com/k8spatterns
Slides https://github.com/ro14nd-talks/kubernetes-patterns
![Page 65: KUBERNETES PATTERNS...One shot action before Pod starts Needs to be idempotent Has own resource requirements Pod app containers init containers Container Container Container Container](https://reader030.fdocuments.net/reader030/viewer/2022041014/5ec568cc1d869250ba56ef86/html5/thumbnails/65.jpg)
https://leanpub.com/k8spatterns