36
APACHE SLING & FRIENDS TECH MEETUP 2 - 4 SEPTEMBER 2019 Deep-dive into cloud-native AEM deployments based on Kubernetes Tomek Rękawek, Adobe

adaptTo() 2019 - Deep-dive into cloud-native AEM ......APACHE SLING & FRIENDS TECH MEETUP 2 - 4 SEPTEMBER 2019 Deep-dive into cloud-native AEM deployments based on Kubernetes Tomek

  • Upload
    others

  • View
    4

  • Download
    0

Embed Size (px)

Citation preview

Page 1: adaptTo() 2019 - Deep-dive into cloud-native AEM ......APACHE SLING & FRIENDS TECH MEETUP 2 - 4 SEPTEMBER 2019 Deep-dive into cloud-native AEM deployments based on Kubernetes Tomek

APACHE SLING & FRIENDS TECH MEETUP2 - 4 SEPTEMBER 2019

Deep-dive into cloud-native AEM deployments based on KubernetesTomek Rękawek, Adobe

Page 2: adaptTo() 2019 - Deep-dive into cloud-native AEM ......APACHE SLING & FRIENDS TECH MEETUP 2 - 4 SEPTEMBER 2019 Deep-dive into cloud-native AEM deployments based on Kubernetes Tomek

2

Cloud: what and why?

Page 3: adaptTo() 2019 - Deep-dive into cloud-native AEM ......APACHE SLING & FRIENDS TECH MEETUP 2 - 4 SEPTEMBER 2019 Deep-dive into cloud-native AEM deployments based on Kubernetes Tomek

We want to move from

3

Page 4: adaptTo() 2019 - Deep-dive into cloud-native AEM ......APACHE SLING & FRIENDS TECH MEETUP 2 - 4 SEPTEMBER 2019 Deep-dive into cloud-native AEM deployments based on Kubernetes Tomek

to

4

Page 5: adaptTo() 2019 - Deep-dive into cloud-native AEM ......APACHE SLING & FRIENDS TECH MEETUP 2 - 4 SEPTEMBER 2019 Deep-dive into cloud-native AEM deployments based on Kubernetes Tomek

Cloud: why?

5

▪ Running AEM at scale▪ Hassle-free deployments▪ The cloud provider (AWS, Azure) should worry

about infrastructure

Page 6: adaptTo() 2019 - Deep-dive into cloud-native AEM ......APACHE SLING & FRIENDS TECH MEETUP 2 - 4 SEPTEMBER 2019 Deep-dive into cloud-native AEM deployments based on Kubernetes Tomek

Agenda

6

▪ Jobs▪ Content migration▪ New indexes

▪ QA

▪ Docker & Kubernetes introduction▪ Architecture overview▪ Publish persistence

▪ Cloud Segment Store▪ Golden publish▪ Compaction

▪ Sidecar services

Page 7: adaptTo() 2019 - Deep-dive into cloud-native AEM ......APACHE SLING & FRIENDS TECH MEETUP 2 - 4 SEPTEMBER 2019 Deep-dive into cloud-native AEM deployments based on Kubernetes Tomek

7

Docker & Kubernetes introduction

Page 8: adaptTo() 2019 - Deep-dive into cloud-native AEM ......APACHE SLING & FRIENDS TECH MEETUP 2 - 4 SEPTEMBER 2019 Deep-dive into cloud-native AEM deployments based on Kubernetes Tomek

The power of standardization

8

Page 9: adaptTo() 2019 - Deep-dive into cloud-native AEM ......APACHE SLING & FRIENDS TECH MEETUP 2 - 4 SEPTEMBER 2019 Deep-dive into cloud-native AEM deployments based on Kubernetes Tomek

Dockerized AEM

9

▪ AEM in Docker image▪ Composite Node Store

▪ /apps & /libs stored in the container▪ Actual content lives outside, in the VOLUME or MongoDB

▪ OSGi Feature Model▪ Defines AEM and customer application▪ Feature launcher starts it inside container▪ Covered in Karl & David’s presentation

▪ See adaptTo() 2017 talk for more details

Page 10: adaptTo() 2019 - Deep-dive into cloud-native AEM ......APACHE SLING & FRIENDS TECH MEETUP 2 - 4 SEPTEMBER 2019 Deep-dive into cloud-native AEM deployments based on Kubernetes Tomek

Mini intro to Kubernetes

10

▪ Launches Docker containers without worrying about the underlying VMs

▪ Dictionary▪ Pod – a group of containers starting together on a single machine▪ Service – internal load balancer, exposing a number of pod replicas under

a single address▪ Ingress – exposes a service under an public http address

▪ Every entity is represented by a YAML object in K8s API server▪ The YAML is the desired state, K8s knows how to get there

Page 11: adaptTo() 2019 - Deep-dive into cloud-native AEM ......APACHE SLING & FRIENDS TECH MEETUP 2 - 4 SEPTEMBER 2019 Deep-dive into cloud-native AEM deployments based on Kubernetes Tomek

Deployments with Helm

11

▪ Helm – K8s apps management▪ Chart – a bunch of K8s YAML

descriptors, with a simple templating

▪ Whole AEM deployment can be installed/upgraded with a single command

Image: https://helm.sh

Page 12: adaptTo() 2019 - Deep-dive into cloud-native AEM ......APACHE SLING & FRIENDS TECH MEETUP 2 - 4 SEPTEMBER 2019 Deep-dive into cloud-native AEM deployments based on Kubernetes Tomek

12

Architecture overview

Page 13: adaptTo() 2019 - Deep-dive into cloud-native AEM ......APACHE SLING & FRIENDS TECH MEETUP 2 - 4 SEPTEMBER 2019 Deep-dive into cloud-native AEM deployments based on Kubernetes Tomek

AEM Kubernetes setup

13

Page 14: adaptTo() 2019 - Deep-dive into cloud-native AEM ......APACHE SLING & FRIENDS TECH MEETUP 2 - 4 SEPTEMBER 2019 Deep-dive into cloud-native AEM deployments based on Kubernetes Tomek

14

Publish persistence evolution

Page 15: adaptTo() 2019 - Deep-dive into cloud-native AEM ......APACHE SLING & FRIENDS TECH MEETUP 2 - 4 SEPTEMBER 2019 Deep-dive into cloud-native AEM deployments based on Kubernetes Tomek

Problem definition

15

▪ Author persistence is easy-ish with MongoDB▪ Publish is harder – local SegmentMK, no clustering▪ The publish farm is kept up-to-date with replication▪ However:

▪ we need to provide the new publish instances with a segment store,▪ copy it from another instance.

▪ Problems:▪ copying files between pods is hard and hacky,▪ what if there’s no publish to copy from?

Page 16: adaptTo() 2019 - Deep-dive into cloud-native AEM ......APACHE SLING & FRIENDS TECH MEETUP 2 - 4 SEPTEMBER 2019 Deep-dive into cloud-native AEM deployments based on Kubernetes Tomek

Cloud Segment Store

16

▪ A new plugin for the Segment Node Store

▪ Nodes are stored in a cloud storage service

▪ No tar files, raw segments grouped in dirs

▪ Can be used in RW or RO modes

Page 17: adaptTo() 2019 - Deep-dive into cloud-native AEM ......APACHE SLING & FRIENDS TECH MEETUP 2 - 4 SEPTEMBER 2019 Deep-dive into cloud-native AEM deployments based on Kubernetes Tomek

Golden publish

17

▪ A designated publish instance

▪ Not connected to LB▪ It maintains a “golden copy”

of the segment store▪ New publish just clone it

Page 18: adaptTo() 2019 - Deep-dive into cloud-native AEM ......APACHE SLING & FRIENDS TECH MEETUP 2 - 4 SEPTEMBER 2019 Deep-dive into cloud-native AEM deployments based on Kubernetes Tomek

Problem: duplicated binaries and startup time

18

Golden publish

Segment 1

Segment 2

Segment 4

Segment 3

Segment x

Publish 1

Segment 1

Segment 2

Segment 4

Segment 3

Segment y

Publish 2

Segment 1

Segment 2

Segment 4

Segment 3

Segment z

Publish 3 (starting)

Segment 1

Segment 2

Segment 3

Segment 4

▪ Multiple copies of the same segments 1-4 ($$$)▪ Cloning a bucket takes time during the publish start (🕑🕑🕑)

Page 19: adaptTo() 2019 - Deep-dive into cloud-native AEM ......APACHE SLING & FRIENDS TECH MEETUP 2 - 4 SEPTEMBER 2019 Deep-dive into cloud-native AEM deployments based on Kubernetes Tomek

Optimization: a single segment store

19

Page 20: adaptTo() 2019 - Deep-dive into cloud-native AEM ......APACHE SLING & FRIENDS TECH MEETUP 2 - 4 SEPTEMBER 2019 Deep-dive into cloud-native AEM deployments based on Kubernetes Tomek

20

Publish persistence: compaction

Page 21: adaptTo() 2019 - Deep-dive into cloud-native AEM ......APACHE SLING & FRIENDS TECH MEETUP 2 - 4 SEPTEMBER 2019 Deep-dive into cloud-native AEM deployments based on Kubernetes Tomek

Compaction

21

Page 22: adaptTo() 2019 - Deep-dive into cloud-native AEM ......APACHE SLING & FRIENDS TECH MEETUP 2 - 4 SEPTEMBER 2019 Deep-dive into cloud-native AEM deployments based on Kubernetes Tomek

Out-of-band publish update

22

▪ This pattern will be useful in many cases

▪ We may clone the publish repository, modify it and re-deploy instances on top of it

▪ Persisted message queue will apply missing changes

Page 23: adaptTo() 2019 - Deep-dive into cloud-native AEM ......APACHE SLING & FRIENDS TECH MEETUP 2 - 4 SEPTEMBER 2019 Deep-dive into cloud-native AEM deployments based on Kubernetes Tomek

23

Sidecar services

Page 24: adaptTo() 2019 - Deep-dive into cloud-native AEM ......APACHE SLING & FRIENDS TECH MEETUP 2 - 4 SEPTEMBER 2019 Deep-dive into cloud-native AEM deployments based on Kubernetes Tomek

Sidecar approach

24

▪ A single pod can run many containers, sharing their volumes and localhost interface

▪ We can use them for the auxiliary services (sidecars):▪ Dispatcher in the publish pod▪ Upload logs to Splunk▪ Warmup service

Page 25: adaptTo() 2019 - Deep-dive into cloud-native AEM ......APACHE SLING & FRIENDS TECH MEETUP 2 - 4 SEPTEMBER 2019 Deep-dive into cloud-native AEM deployments based on Kubernetes Tomek

AEM pod with sidecars

25Sidecar icon: Flaticons.com

Page 26: adaptTo() 2019 - Deep-dive into cloud-native AEM ......APACHE SLING & FRIENDS TECH MEETUP 2 - 4 SEPTEMBER 2019 Deep-dive into cloud-native AEM deployments based on Kubernetes Tomek

26

Jobs

Page 27: adaptTo() 2019 - Deep-dive into cloud-native AEM ......APACHE SLING & FRIENDS TECH MEETUP 2 - 4 SEPTEMBER 2019 Deep-dive into cloud-native AEM deployments based on Kubernetes Tomek

Kubernetes job

27

▪ Starts a pod▪ Meant to perform a specific task and finish

▪ Unlike the deployment, which run indefinitely

▪ Will be restarted if fails▪ Jobs provides a way to interact with the

deployed AEM

Page 28: adaptTo() 2019 - Deep-dive into cloud-native AEM ......APACHE SLING & FRIENDS TECH MEETUP 2 - 4 SEPTEMBER 2019 Deep-dive into cloud-native AEM deployments based on Kubernetes Tomek

28

Content migration

Page 29: adaptTo() 2019 - Deep-dive into cloud-native AEM ......APACHE SLING & FRIENDS TECH MEETUP 2 - 4 SEPTEMBER 2019 Deep-dive into cloud-native AEM deployments based on Kubernetes Tomek

Content migration

29

▪ How to migrate old content to K8s?▪ Access problem

▪ old AEM envs shouldn’t have access to the K8s (encapsulation)

▪ K8s shouldn’t be able to access old AEMs (they can be installed anywhere)

▪ Solution: demilitarized zone

Page 30: adaptTo() 2019 - Deep-dive into cloud-native AEM ......APACHE SLING & FRIENDS TECH MEETUP 2 - 4 SEPTEMBER 2019 Deep-dive into cloud-native AEM deployments based on Kubernetes Tomek

2-phase migration

30

▪ Phase 1▪ The migrator tool (crx2oak-like jar)

is used to export old AEM content into a cloud storage service

▪ Phase 2▪ A Kubernetes job is used to apply

the migrated content on the cloud instances

Page 31: adaptTo() 2019 - Deep-dive into cloud-native AEM ......APACHE SLING & FRIENDS TECH MEETUP 2 - 4 SEPTEMBER 2019 Deep-dive into cloud-native AEM deployments based on Kubernetes Tomek

31

New indexes

Page 32: adaptTo() 2019 - Deep-dive into cloud-native AEM ......APACHE SLING & FRIENDS TECH MEETUP 2 - 4 SEPTEMBER 2019 Deep-dive into cloud-native AEM deployments based on Kubernetes Tomek

Adding new index

32

▪ Indexes are tricky▪ /oak:index is a part of the mutable content▪ But index definitions belongs to the

application

▪ Only adding new indexes is supported▪ When a new index is added in /oak:index, it’ll

have an extra useIfExists property referencing immutable part /apps▪ This bounds the index definition to the application

version and Docker image

▪ This /apps path have to be added as well

• /oak:index/my-new-index• useIfExists: /apps/indexes@v3

• /apps/indexes• v3: true

Mutable part

Immutable part

Page 33: adaptTo() 2019 - Deep-dive into cloud-native AEM ......APACHE SLING & FRIENDS TECH MEETUP 2 - 4 SEPTEMBER 2019 Deep-dive into cloud-native AEM deployments based on Kubernetes Tomek

Mutable content: adding new index

33

▪ Indexing job should be run before the actual app deployment

▪ The job will:1. Look for the new index defs in /oak:index2. Perform out of band indexing of the content3. Save the new indexing content to the production

repository

▪ The useIfExists will make sure that the new index is ignored, until the new image is installed

▪ When the new image is deployed, the /apps part will be updated and the new index will be used

Page 34: adaptTo() 2019 - Deep-dive into cloud-native AEM ......APACHE SLING & FRIENDS TECH MEETUP 2 - 4 SEPTEMBER 2019 Deep-dive into cloud-native AEM deployments based on Kubernetes Tomek

34

Other topics

Page 35: adaptTo() 2019 - Deep-dive into cloud-native AEM ......APACHE SLING & FRIENDS TECH MEETUP 2 - 4 SEPTEMBER 2019 Deep-dive into cloud-native AEM deployments based on Kubernetes Tomek

Related topics

35

▪ Feature model usage in Docker (covered in David’s and Karl’s talk)

▪ Replication (covered in Timothee’s talk)▪ Monitoring with Prometheus and Grafana▪ CI/CD pipeline▪ Network policies▪ …

Page 36: adaptTo() 2019 - Deep-dive into cloud-native AEM ......APACHE SLING & FRIENDS TECH MEETUP 2 - 4 SEPTEMBER 2019 Deep-dive into cloud-native AEM deployments based on Kubernetes Tomek

36

Thanks!