SlideShare ist ein Scribd-Unternehmen logo
1 von 63
Kubernetes @ Meetic
Building an end-to-end testing strategy on top
of Kubernetes in a world of microservices
Sébastien Lavallée
Senior software engineer @ Meetic
Sébastien Le Gall
@seb_legall
Tech Lead back-end @ Meetic
Started in 2001
•
150 people in IT teams
•
Dating leader in Europe
•
Active in 15 countries
•
Millions of Monthly Active Users
Event bus
Meetic Now
Microservices
BackOffices
Consumers
Exposition Layer
Testing
There are only two hard things in Computer Science: cache
invalidation and naming things.
[Phil Karlton]
There are only three hard things in Computer Science: cache
invalidation and naming things and testing a microservice
architecture
[Me]
Testing strategy
Testing strategy
• Unit tests
• Behavioral tests
• End-to-end tests
Testing – Registration
Exposition Layer
Event bus
Consumers
Micro-services
ProfileEmailing
Behavioral Testing
Behavioral Testing
Behavioral Testing
Behavioral Testing
End-to-end Testing
Unit TestingUnit Testing
Unit Testing
Testing strategy
On push :
Unit Tests
Behavioural Tests
Fast Feedback End-to-end tests
Deployment
Continuous Integration
Continuous Integration
In PHP, but all languages we use follow this concepts
Let's focus on the span of our microservice profile used in the
registration process.
Continuous Integration
Profile
Build Strategy / example
Container strategy
Exposition Layer
Event bus
Consumers
Unit testing
Behavioral
testing
End-to-end testing
Base Container
Add a Dockerfile to our Profile repository so we
can run this tools to test the code
FROM artifact/meetic/centos:6.9
RUN yum install
rh-php56 
rh-php56-php-fpm
...
COPY config/cli/php.ini /etc/opt/rh/rh-php56/php.ini
COPY docker-entrypoint.sh /entrypoint.sh
RUN chmod a+x /entrypoint.sh && chown root:root /entrypoint.sh
ENTRYPOINT ["/entrypoint.sh"]
CMD ["/bin/bash"]
CentOS 6.9
Meetic/CentOS 6.9
Meetic/PHP 5.6
Base Container
Test Unit
Test Behavioral
Profile
Behavioral Testing
Unit Testing
docker-compose
services:
oracle:
image: artefact/meetic/oracle-main-data
ports:
- "1521"
broker:
build: docker-images/broker
ports:
- "10234"
depends_on:
- oracle
php:
build: docker-images/php
environment:
COMPOSER_PATH: bin/composer
depends_on:
- memcached
- wiremock
volumes:
- "./:/srv/app"
Profile
Add a docker-compose file to our repository
microservice Profile
docker-compose
Test Unit
Test Behavioral
Profile
Behavioral Testing
Unit Testing
Scaling the model
Target architecture
1 base container 1 container /
application
1 docker-compose /
application 1 interface
Makefile
Base container
Extract the base Dockerfile from repository
Change the entrypoint.sh to make it extendable
CentOS 6.9
Meetic/CentOS 6.9
Meetic/PHP 5.6
Meetic/PHP-CI 5.6
Microservice container
#!/bin/bash
...
chown -R $USERNAME:$GROUPNAME /docker-entrypoint-init.d
for f in /docker-entrypoint-init.d/*; do
case "$f" in
*.sh) echo "$0: running $f"; gosu $USERNAME "$f" ;;
*) echo "$0: ignoring $f" ;;
esac
echo
Done
...
Application Container
Put New and smaller embedded Dockerfile
dockerize.sh (an extension of our entrypoint.sh)
#!/bin/bash
# wait for dependencies to be ready
dockerize -timeout 10s -wait tcp://oracle:1521
dockerize -timeout 10s -wait tcp://broker:10234
CentOS 6.9
Meetic/CentOS 6.9
Meetic/PHP 5.6
Meetic/PHP-CI 5.6
Microservice container
FROM artifact/meetic/php56-ci
COPY config/tnsnames.ora /etc/
COPY docker-entrypoint-init.d/dockerize.sh /docker-entrypoint-init.d/dockerize.sh
RUN chmod a+x /docker-entrypoint-init.d/dockerize.sh
Application docker-compose
services:
wiremock:
build: docker-images/wiremock
memcached:
build: docker-
images/memcached
ports:
- "11211"
php:
build: docker-images/php
environment:
COMPOSER_PATH:
bin/composer
depends_on:
- memcached
- wiremock
volumes:
- "./:/srv/app"
services:
oracle:
image: artefact/meetic/oracle-main-
data
ports:
- "1521"
broker:
build: docker-images/broker
ports:
- "10234"
depends_on:
- oracle
php:
build: docker-images/php
environment:
COMPOSER_PATH: bin/composer
PLATFORM_ENV: test
depends_on:
- broker
volumes:
- "./:/srv/app"
docker-compose Emailing:docker-compose Profile :
Makefile
• Create a unified set of commands
across our microservices
• Stored in each repositories
• Used by generic builder
Makefile
Makefile emailing :
Makefile Profile :
...
cache-warmup:
bin/console cache:warmup
debug-router:
bin/console debug:router
test-behavioural: cache-warmup
test-behavioural: test-behat-ci
...
$ make test-behavioural
...
cache-warmup:
app/console cache:warmup
test-behavioural: test-behat-ci
...
Continuous Integration
A CI environment per microservice
One docker-compose per microservice
Some images are build on the go in order to be able to
override some configuration value during tests
One per microservice. Provide a unified set of commands
Scaling testing architecture
Test Unit
Test Behavioral
Test end-to-end
Exposition Layer
Event bus
Consumers
Micro-services
ProfileEmailing
Behavioral TestingBehavioral Testing
Behavioral Testing
End-to-end Testing
End-to-end testing strategy
Testing – the problem
• Multiple people need to test different thing at the same time
• Small technical increments are easy to test but not revelant for product
owners
• User stories may need multiple microservice to be tested
• When coming to end-to-end testing, docker-compose reach its limitation
Testing at scale
End-to-end testing at Meetics means :
• Running ~30 microservices
• Running ~30 consumers
• Running ~6 different database/search engine technology
• Running kafka
Using VMs and docker-compose?
First thing we though of was using VMs and running services inside
docker containers linked together using docker-compose.
Using VMs and docker-compose?
But…
• Running multiple docker-compose on the same VM cause conflict
on port usage
• There are 150 people in the IT teams. Does it mean that we should
be prepared to run 150 VM? (One per user)
• Automated testing on VMs run by the CI are hard to handle
• Docker-compose does not handle well domain name. (Think about
kubernetes’ ingress like feature)
Introducing Kubernetes
• Kubernetes handle port /name conflict with namespaces
• Ingress is great to handle domain name / url associated to services
• Creating and deleting a namespace is easy
Let’s go with Kubernetes !
Introducing Kubernetes
Test use case :
• Manual tests done by Product Owners
 Need a user friendly interface
• Manuel tests done by developers
 Could be done using a CLI tool but a user friendly interface
could be nice as well
• Automated tests done by a scripts / the CI
 Must be done using a CLI tool.
Introducing Kubernetes
User / CI workflow :
• Create a new namespace
• Apply default configuration (Means deploying all the containers
using the latest version of each, the one used in production)
• Change the container tag for services concerned by the update
(related to the feature)
• Launch test
• Trash the namespace
Building containers for run
Docker Images (w/ code)
Kubernetes need Docker images
Objectives :
• Create docker images
• Push them in a place kubernetes can retrieve them
Continuous integration for containers
Kubernetes Dockerfile
Dockerfile specifies an image with microservice code
Dockerfile
Kubernetes Dockerfile
FROM artifact/meetic/php56
ARG version=master
ARG stage=release
ARG apiName=
COPY docker-entrypoint.sh /entrypoint.sh
RUN chmod a+x /entrypoint.sh && chown root:root /entrypoint.sh
COPY config/fpm/php-fpm.d/* /etc/opt/rh/rh-php56/php-fpm.d/
COPY config/tnsnames.ora /etc/
RUN wget "https://artifact/php-$stage/$apiName/$version.tar.gz" && 
tar zxvf "$version.tar.gz"
ENTRYPOINT ["/entrypoint.sh"]
CMD ["/opt/rh/rh-php56/root/usr/sbin/php-fpm", "-F"]
CentOS 6.9
Meetic/CentOS 6.9
Meetic/PHP 5.6
Microservice container
PHP Dockerfile not versioned in repositories
The Data
A lot of data
We can't just clone the databases in our testing environment
Our data is stored across multiple technology
Two constraints :
• We need to create a sub-set of users that is coherent
• We need to anonymize the data
Database Images
Need Data coherence across all our storage instances
Extract a coherent subset of data.
- same ratio H/M
- same ratio of search
- same ratio of active/inactive
…
With the ID's, extract from all database the data for those members
Database Extract
Extracted
ID LIST
Anonymization
Anonymization
Anonymization
Anonymization
User List
Docker images ready
Managing testing environments
Helm
Helm is a package manager for Kubernetes.
• Creating packages (called charts)
• Sharing packages on a platform
• Deploying shared packages easily on kubernetes
Helm - Charts
“A chart is a collection of files that describe a related set of Kubernetes
resources.”
“Charts are created as files laid out in a particular directory tree, then they
can be packaged into versioned archives to be deployed.”
+
Templates Values Package
Helm - Charts
Helm – the problem
Helm is great but the use case does not really match our needs :
• Helm is a CLI tools (only)
• Helm comes with the features of a package manager that we don’t
care about
• Helm does not manage namespaces. It only handle package
deployment.
Testing env – our goal
api-profile version 0.1.2 api-search
version 1.3.2
Latest Version Latest Version
Template and default
values
Introducing Blackbeard
Blackbeard is a user friendly tool that handle package
configuration and deployment across multiple
kubernetes namespace.
+
Templates
Inventory
Inventory
Playbook
Blackbeard features
• Create namespace
• Apply configuration (deployments, services, etc.)
• Get useful informations about namespace state (Pods status,
exposed service via NodePort or Ingress)
• Delete namespace
Playbooks
Templates
Default values
Inventory for slegall
Config for slegall
Playbook - templates
Playbook - Inventory
Blackbeard usage
+
Working with Blackbeard
$ blackbeard create –n test # Create a namespace and default configuration
$ vi inventories/test_inventory.json # Update the values to match needs
$ blackbeard apply –n test # Apply the change to the namespace
$ blackbeard get services # Show exposed services
$ blackbeard delete –n test # Cleanup files and namespace
Blackbeard under the hood
• Written in the Go programming language
• Interact with the Kubernetes API using the go client
• Expose a collection of CLI commands using the Cobra framework
• Expose a REST API trough the Gin framework
• Rely on the .kube/config configuration file
Blackbeard under the hood
Conclusion
Inheritance in Docker is a game changer
when working with microservices and
different testing strategy
Give your users a base.
Let them override the configuration.
Don’t treat all the use cases with the same
patterns.
Conclusion
Re-create an entire stack in kubernetes
remains hard. You cannot just apply your
prod configuration in a container.
Some useful tricks stay undocumented.
The kubernetes source code is very hard to
understand for outsiders.
There are plenty of tools and stories around
kubernetes . But the reality is far from a
fairy tail.
Kubernetes @ meetic

Weitere ähnliche Inhalte

Was ist angesagt?

WSO2Con US 2015 Kubernetes: a platform for automating deployment, scaling, an...
WSO2Con US 2015 Kubernetes: a platform for automating deployment, scaling, an...WSO2Con US 2015 Kubernetes: a platform for automating deployment, scaling, an...
WSO2Con US 2015 Kubernetes: a platform for automating deployment, scaling, an...
Brian Grant
 

Was ist angesagt? (20)

Service Discovery In Kubernetes
Service Discovery In KubernetesService Discovery In Kubernetes
Service Discovery In Kubernetes
 
Hands-On Introduction to Kubernetes at LISA17
Hands-On Introduction to Kubernetes at LISA17Hands-On Introduction to Kubernetes at LISA17
Hands-On Introduction to Kubernetes at LISA17
 
The (mutable) config management showdown
The (mutable) config management showdownThe (mutable) config management showdown
The (mutable) config management showdown
 
Kubernetes a comprehensive overview
Kubernetes   a comprehensive overviewKubernetes   a comprehensive overview
Kubernetes a comprehensive overview
 
Kubernetes Architecture - beyond a black box - Part 2
Kubernetes Architecture - beyond a black box - Part 2Kubernetes Architecture - beyond a black box - Part 2
Kubernetes Architecture - beyond a black box - Part 2
 
Kubernetes 101
Kubernetes 101Kubernetes 101
Kubernetes 101
 
Kubernetes: The Next Research Platform
Kubernetes: The Next Research PlatformKubernetes: The Next Research Platform
Kubernetes: The Next Research Platform
 
Getting started with kubernetes
Getting started with kubernetesGetting started with kubernetes
Getting started with kubernetes
 
Kubernetes Requests and Limits
Kubernetes Requests and LimitsKubernetes Requests and Limits
Kubernetes Requests and Limits
 
DevJam 2019 - Introduction to Kubernetes
DevJam 2019 - Introduction to KubernetesDevJam 2019 - Introduction to Kubernetes
DevJam 2019 - Introduction to Kubernetes
 
Federated Kubernetes: As a Platform for Distributed Scientific Computing
Federated Kubernetes: As a Platform for Distributed Scientific ComputingFederated Kubernetes: As a Platform for Distributed Scientific Computing
Federated Kubernetes: As a Platform for Distributed Scientific Computing
 
WSO2Con US 2015 Kubernetes: a platform for automating deployment, scaling, an...
WSO2Con US 2015 Kubernetes: a platform for automating deployment, scaling, an...WSO2Con US 2015 Kubernetes: a platform for automating deployment, scaling, an...
WSO2Con US 2015 Kubernetes: a platform for automating deployment, scaling, an...
 
Kubernetes Architecture | Understanding Kubernetes Components | Kubernetes Tu...
Kubernetes Architecture | Understanding Kubernetes Components | Kubernetes Tu...Kubernetes Architecture | Understanding Kubernetes Components | Kubernetes Tu...
Kubernetes Architecture | Understanding Kubernetes Components | Kubernetes Tu...
 
Kubernetes intro public - kubernetes meetup 4-21-2015
Kubernetes intro   public - kubernetes meetup 4-21-2015Kubernetes intro   public - kubernetes meetup 4-21-2015
Kubernetes intro public - kubernetes meetup 4-21-2015
 
Intro to kubernetes
Intro to kubernetesIntro to kubernetes
Intro to kubernetes
 
Ansible, integration testing, and you.
Ansible, integration testing, and you.Ansible, integration testing, and you.
Ansible, integration testing, and you.
 
Kubernetes intro public - kubernetes user group 4-21-2015
Kubernetes intro   public - kubernetes user group 4-21-2015Kubernetes intro   public - kubernetes user group 4-21-2015
Kubernetes intro public - kubernetes user group 4-21-2015
 
Deep Dive into Kubernetes - Part 1
Deep Dive into Kubernetes - Part 1Deep Dive into Kubernetes - Part 1
Deep Dive into Kubernetes - Part 1
 
Introduction to Kubernetes Workshop
Introduction to Kubernetes WorkshopIntroduction to Kubernetes Workshop
Introduction to Kubernetes Workshop
 
Planes, Raft, and Pods: A Tour of Distributed Systems Within Kubernetes
Planes, Raft, and Pods: A Tour of Distributed Systems Within KubernetesPlanes, Raft, and Pods: A Tour of Distributed Systems Within Kubernetes
Planes, Raft, and Pods: A Tour of Distributed Systems Within Kubernetes
 

Ähnlich wie Kubernetes @ meetic

Kubernetes: від знайомства до використання у CI/CD
Kubernetes: від знайомства до використання у CI/CDKubernetes: від знайомства до використання у CI/CD
Kubernetes: від знайомства до використання у CI/CD
Stfalcon Meetups
 
Docker - Portable Deployment
Docker - Portable DeploymentDocker - Portable Deployment
Docker - Portable Deployment
javaonfly
 

Ähnlich wie Kubernetes @ meetic (20)

Kubernetes: від знайомства до використання у CI/CD
Kubernetes: від знайомства до використання у CI/CDKubernetes: від знайомства до використання у CI/CD
Kubernetes: від знайомства до використання у CI/CD
 
Docker Application to Scientific Computing
Docker Application to Scientific ComputingDocker Application to Scientific Computing
Docker Application to Scientific Computing
 
01 - VMUGIT - Lecce 2018 - Fabio Rapposelli, VMware
01 - VMUGIT - Lecce 2018 - Fabio Rapposelli, VMware01 - VMUGIT - Lecce 2018 - Fabio Rapposelli, VMware
01 - VMUGIT - Lecce 2018 - Fabio Rapposelli, VMware
 
DevOps with Azure, Kubernetes, and Helm Webinar
DevOps with Azure, Kubernetes, and Helm WebinarDevOps with Azure, Kubernetes, and Helm Webinar
DevOps with Azure, Kubernetes, and Helm Webinar
 
Develop and deploy Kubernetes applications with Docker - IBM Index 2018
Develop and deploy Kubernetes  applications with Docker - IBM Index 2018Develop and deploy Kubernetes  applications with Docker - IBM Index 2018
Develop and deploy Kubernetes applications with Docker - IBM Index 2018
 
Cont0519
Cont0519Cont0519
Cont0519
 
IBM Container Service Overview
IBM Container Service OverviewIBM Container Service Overview
IBM Container Service Overview
 
Building Cloud-Native Applications with Kubernetes, Helm and Kubeless
Building Cloud-Native Applications with Kubernetes, Helm and KubelessBuilding Cloud-Native Applications with Kubernetes, Helm and Kubeless
Building Cloud-Native Applications with Kubernetes, Helm and Kubeless
 
Docker dev ops for cd meetup 12-14
Docker dev ops for cd meetup 12-14Docker dev ops for cd meetup 12-14
Docker dev ops for cd meetup 12-14
 
Microservices: How loose is loosely coupled?
Microservices: How loose is loosely coupled?Microservices: How loose is loosely coupled?
Microservices: How loose is loosely coupled?
 
Microservices and containers for the unitiated
Microservices and containers for the unitiatedMicroservices and containers for the unitiated
Microservices and containers for the unitiated
 
Docker and kubernetes
Docker and kubernetesDocker and kubernetes
Docker and kubernetes
 
Weave User Group Talk - DockerCon 2017 Recap
Weave User Group Talk - DockerCon 2017 RecapWeave User Group Talk - DockerCon 2017 Recap
Weave User Group Talk - DockerCon 2017 Recap
 
Containers, Serverless and Functions in a nutshell
Containers, Serverless and Functions in a nutshellContainers, Serverless and Functions in a nutshell
Containers, Serverless and Functions in a nutshell
 
Habitat talk at CodeMonsters Sofia, Bulgaria Nov 27 2018
Habitat talk at CodeMonsters Sofia, Bulgaria Nov 27 2018Habitat talk at CodeMonsters Sofia, Bulgaria Nov 27 2018
Habitat talk at CodeMonsters Sofia, Bulgaria Nov 27 2018
 
Docker - Portable Deployment
Docker - Portable DeploymentDocker - Portable Deployment
Docker - Portable Deployment
 
Docker Orchestration: Welcome to the Jungle! Devoxx & Docker Meetup Tour Nov ...
Docker Orchestration: Welcome to the Jungle! Devoxx & Docker Meetup Tour Nov ...Docker Orchestration: Welcome to the Jungle! Devoxx & Docker Meetup Tour Nov ...
Docker Orchestration: Welcome to the Jungle! Devoxx & Docker Meetup Tour Nov ...
 
Get you Java application ready for Kubernetes !
Get you Java application ready for Kubernetes !Get you Java application ready for Kubernetes !
Get you Java application ready for Kubernetes !
 
DCEU 18: Building Your Development Pipeline
DCEU 18: Building Your Development PipelineDCEU 18: Building Your Development Pipeline
DCEU 18: Building Your Development Pipeline
 
Kubernetes solutions
Kubernetes solutionsKubernetes solutions
Kubernetes solutions
 

Kürzlich hochgeladen

Call Girls in Ramesh Nagar Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
Call Girls in Ramesh Nagar Delhi 💯 Call Us 🔝9953056974 🔝 Escort ServiceCall Girls in Ramesh Nagar Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
Call Girls in Ramesh Nagar Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
9953056974 Low Rate Call Girls In Saket, Delhi NCR
 
Cara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak Hamil
Cara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak HamilCara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak Hamil
Cara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak Hamil
Cara Menggugurkan Kandungan 087776558899
 
notes on Evolution Of Analytic Scalability.ppt
notes on Evolution Of Analytic Scalability.pptnotes on Evolution Of Analytic Scalability.ppt
notes on Evolution Of Analytic Scalability.ppt
MsecMca
 
Call Now ≽ 9953056974 ≼🔝 Call Girls In New Ashok Nagar ≼🔝 Delhi door step de...
Call Now ≽ 9953056974 ≼🔝 Call Girls In New Ashok Nagar  ≼🔝 Delhi door step de...Call Now ≽ 9953056974 ≼🔝 Call Girls In New Ashok Nagar  ≼🔝 Delhi door step de...
Call Now ≽ 9953056974 ≼🔝 Call Girls In New Ashok Nagar ≼🔝 Delhi door step de...
9953056974 Low Rate Call Girls In Saket, Delhi NCR
 

Kürzlich hochgeladen (20)

Call Girls in Ramesh Nagar Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
Call Girls in Ramesh Nagar Delhi 💯 Call Us 🔝9953056974 🔝 Escort ServiceCall Girls in Ramesh Nagar Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
Call Girls in Ramesh Nagar Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
 
Bhosari ( Call Girls ) Pune 6297143586 Hot Model With Sexy Bhabi Ready For ...
Bhosari ( Call Girls ) Pune  6297143586  Hot Model With Sexy Bhabi Ready For ...Bhosari ( Call Girls ) Pune  6297143586  Hot Model With Sexy Bhabi Ready For ...
Bhosari ( Call Girls ) Pune 6297143586 Hot Model With Sexy Bhabi Ready For ...
 
Block diagram reduction techniques in control systems.ppt
Block diagram reduction techniques in control systems.pptBlock diagram reduction techniques in control systems.ppt
Block diagram reduction techniques in control systems.ppt
 
Work-Permit-Receiver-in-Saudi-Aramco.pptx
Work-Permit-Receiver-in-Saudi-Aramco.pptxWork-Permit-Receiver-in-Saudi-Aramco.pptx
Work-Permit-Receiver-in-Saudi-Aramco.pptx
 
Employee leave management system project.
Employee leave management system project.Employee leave management system project.
Employee leave management system project.
 
2016EF22_0 solar project report rooftop projects
2016EF22_0 solar project report rooftop projects2016EF22_0 solar project report rooftop projects
2016EF22_0 solar project report rooftop projects
 
FEA Based Level 3 Assessment of Deformed Tanks with Fluid Induced Loads
FEA Based Level 3 Assessment of Deformed Tanks with Fluid Induced LoadsFEA Based Level 3 Assessment of Deformed Tanks with Fluid Induced Loads
FEA Based Level 3 Assessment of Deformed Tanks with Fluid Induced Loads
 
(INDIRA) Call Girl Aurangabad Call Now 8617697112 Aurangabad Escorts 24x7
(INDIRA) Call Girl Aurangabad Call Now 8617697112 Aurangabad Escorts 24x7(INDIRA) Call Girl Aurangabad Call Now 8617697112 Aurangabad Escorts 24x7
(INDIRA) Call Girl Aurangabad Call Now 8617697112 Aurangabad Escorts 24x7
 
Thermal Engineering -unit - III & IV.ppt
Thermal Engineering -unit - III & IV.pptThermal Engineering -unit - III & IV.ppt
Thermal Engineering -unit - III & IV.ppt
 
(INDIRA) Call Girl Meerut Call Now 8617697112 Meerut Escorts 24x7
(INDIRA) Call Girl Meerut Call Now 8617697112 Meerut Escorts 24x7(INDIRA) Call Girl Meerut Call Now 8617697112 Meerut Escorts 24x7
(INDIRA) Call Girl Meerut Call Now 8617697112 Meerut Escorts 24x7
 
KubeKraft presentation @CloudNativeHooghly
KubeKraft presentation @CloudNativeHooghlyKubeKraft presentation @CloudNativeHooghly
KubeKraft presentation @CloudNativeHooghly
 
Unleashing the Power of the SORA AI lastest leap
Unleashing the Power of the SORA AI lastest leapUnleashing the Power of the SORA AI lastest leap
Unleashing the Power of the SORA AI lastest leap
 
Cara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak Hamil
Cara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak HamilCara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak Hamil
Cara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak Hamil
 
notes on Evolution Of Analytic Scalability.ppt
notes on Evolution Of Analytic Scalability.pptnotes on Evolution Of Analytic Scalability.ppt
notes on Evolution Of Analytic Scalability.ppt
 
Call Now ≽ 9953056974 ≼🔝 Call Girls In New Ashok Nagar ≼🔝 Delhi door step de...
Call Now ≽ 9953056974 ≼🔝 Call Girls In New Ashok Nagar  ≼🔝 Delhi door step de...Call Now ≽ 9953056974 ≼🔝 Call Girls In New Ashok Nagar  ≼🔝 Delhi door step de...
Call Now ≽ 9953056974 ≼🔝 Call Girls In New Ashok Nagar ≼🔝 Delhi door step de...
 
Unit 1 - Soil Classification and Compaction.pdf
Unit 1 - Soil Classification and Compaction.pdfUnit 1 - Soil Classification and Compaction.pdf
Unit 1 - Soil Classification and Compaction.pdf
 
COST-EFFETIVE and Energy Efficient BUILDINGS ptx
COST-EFFETIVE  and Energy Efficient BUILDINGS ptxCOST-EFFETIVE  and Energy Efficient BUILDINGS ptx
COST-EFFETIVE and Energy Efficient BUILDINGS ptx
 
DC MACHINE-Motoring and generation, Armature circuit equation
DC MACHINE-Motoring and generation, Armature circuit equationDC MACHINE-Motoring and generation, Armature circuit equation
DC MACHINE-Motoring and generation, Armature circuit equation
 
Water Industry Process Automation & Control Monthly - April 2024
Water Industry Process Automation & Control Monthly - April 2024Water Industry Process Automation & Control Monthly - April 2024
Water Industry Process Automation & Control Monthly - April 2024
 
UNIT - IV - Air Compressors and its Performance
UNIT - IV - Air Compressors and its PerformanceUNIT - IV - Air Compressors and its Performance
UNIT - IV - Air Compressors and its Performance
 

Kubernetes @ meetic

  • 1. Kubernetes @ Meetic Building an end-to-end testing strategy on top of Kubernetes in a world of microservices
  • 3. Sébastien Le Gall @seb_legall Tech Lead back-end @ Meetic
  • 4. Started in 2001 • 150 people in IT teams • Dating leader in Europe • Active in 15 countries • Millions of Monthly Active Users
  • 6. Testing There are only two hard things in Computer Science: cache invalidation and naming things. [Phil Karlton] There are only three hard things in Computer Science: cache invalidation and naming things and testing a microservice architecture [Me]
  • 8. Testing strategy • Unit tests • Behavioral tests • End-to-end tests
  • 9. Testing – Registration Exposition Layer Event bus Consumers Micro-services ProfileEmailing Behavioral Testing Behavioral Testing Behavioral Testing Behavioral Testing End-to-end Testing Unit TestingUnit Testing Unit Testing
  • 10. Testing strategy On push : Unit Tests Behavioural Tests Fast Feedback End-to-end tests Deployment
  • 13. In PHP, but all languages we use follow this concepts Let's focus on the span of our microservice profile used in the registration process. Continuous Integration Profile
  • 14. Build Strategy / example
  • 15. Container strategy Exposition Layer Event bus Consumers Unit testing Behavioral testing End-to-end testing
  • 16. Base Container Add a Dockerfile to our Profile repository so we can run this tools to test the code FROM artifact/meetic/centos:6.9 RUN yum install rh-php56 rh-php56-php-fpm ... COPY config/cli/php.ini /etc/opt/rh/rh-php56/php.ini COPY docker-entrypoint.sh /entrypoint.sh RUN chmod a+x /entrypoint.sh && chown root:root /entrypoint.sh ENTRYPOINT ["/entrypoint.sh"] CMD ["/bin/bash"] CentOS 6.9 Meetic/CentOS 6.9 Meetic/PHP 5.6
  • 17. Base Container Test Unit Test Behavioral Profile Behavioral Testing Unit Testing
  • 18. docker-compose services: oracle: image: artefact/meetic/oracle-main-data ports: - "1521" broker: build: docker-images/broker ports: - "10234" depends_on: - oracle php: build: docker-images/php environment: COMPOSER_PATH: bin/composer depends_on: - memcached - wiremock volumes: - "./:/srv/app" Profile Add a docker-compose file to our repository microservice Profile
  • 21. Target architecture 1 base container 1 container / application 1 docker-compose / application 1 interface Makefile
  • 22. Base container Extract the base Dockerfile from repository Change the entrypoint.sh to make it extendable CentOS 6.9 Meetic/CentOS 6.9 Meetic/PHP 5.6 Meetic/PHP-CI 5.6 Microservice container #!/bin/bash ... chown -R $USERNAME:$GROUPNAME /docker-entrypoint-init.d for f in /docker-entrypoint-init.d/*; do case "$f" in *.sh) echo "$0: running $f"; gosu $USERNAME "$f" ;; *) echo "$0: ignoring $f" ;; esac echo Done ...
  • 23. Application Container Put New and smaller embedded Dockerfile dockerize.sh (an extension of our entrypoint.sh) #!/bin/bash # wait for dependencies to be ready dockerize -timeout 10s -wait tcp://oracle:1521 dockerize -timeout 10s -wait tcp://broker:10234 CentOS 6.9 Meetic/CentOS 6.9 Meetic/PHP 5.6 Meetic/PHP-CI 5.6 Microservice container FROM artifact/meetic/php56-ci COPY config/tnsnames.ora /etc/ COPY docker-entrypoint-init.d/dockerize.sh /docker-entrypoint-init.d/dockerize.sh RUN chmod a+x /docker-entrypoint-init.d/dockerize.sh
  • 24. Application docker-compose services: wiremock: build: docker-images/wiremock memcached: build: docker- images/memcached ports: - "11211" php: build: docker-images/php environment: COMPOSER_PATH: bin/composer depends_on: - memcached - wiremock volumes: - "./:/srv/app" services: oracle: image: artefact/meetic/oracle-main- data ports: - "1521" broker: build: docker-images/broker ports: - "10234" depends_on: - oracle php: build: docker-images/php environment: COMPOSER_PATH: bin/composer PLATFORM_ENV: test depends_on: - broker volumes: - "./:/srv/app" docker-compose Emailing:docker-compose Profile :
  • 25. Makefile • Create a unified set of commands across our microservices • Stored in each repositories • Used by generic builder
  • 26. Makefile Makefile emailing : Makefile Profile : ... cache-warmup: bin/console cache:warmup debug-router: bin/console debug:router test-behavioural: cache-warmup test-behavioural: test-behat-ci ... $ make test-behavioural ... cache-warmup: app/console cache:warmup test-behavioural: test-behat-ci ... Continuous Integration
  • 27. A CI environment per microservice One docker-compose per microservice Some images are build on the go in order to be able to override some configuration value during tests One per microservice. Provide a unified set of commands
  • 28. Scaling testing architecture Test Unit Test Behavioral Test end-to-end Exposition Layer Event bus Consumers Micro-services ProfileEmailing Behavioral TestingBehavioral Testing Behavioral Testing End-to-end Testing
  • 30. Testing – the problem • Multiple people need to test different thing at the same time • Small technical increments are easy to test but not revelant for product owners • User stories may need multiple microservice to be tested • When coming to end-to-end testing, docker-compose reach its limitation
  • 31. Testing at scale End-to-end testing at Meetics means : • Running ~30 microservices • Running ~30 consumers • Running ~6 different database/search engine technology • Running kafka
  • 32. Using VMs and docker-compose? First thing we though of was using VMs and running services inside docker containers linked together using docker-compose.
  • 33. Using VMs and docker-compose? But… • Running multiple docker-compose on the same VM cause conflict on port usage • There are 150 people in the IT teams. Does it mean that we should be prepared to run 150 VM? (One per user) • Automated testing on VMs run by the CI are hard to handle • Docker-compose does not handle well domain name. (Think about kubernetes’ ingress like feature)
  • 34. Introducing Kubernetes • Kubernetes handle port /name conflict with namespaces • Ingress is great to handle domain name / url associated to services • Creating and deleting a namespace is easy Let’s go with Kubernetes !
  • 35. Introducing Kubernetes Test use case : • Manual tests done by Product Owners  Need a user friendly interface • Manuel tests done by developers  Could be done using a CLI tool but a user friendly interface could be nice as well • Automated tests done by a scripts / the CI  Must be done using a CLI tool.
  • 36. Introducing Kubernetes User / CI workflow : • Create a new namespace • Apply default configuration (Means deploying all the containers using the latest version of each, the one used in production) • Change the container tag for services concerned by the update (related to the feature) • Launch test • Trash the namespace
  • 38. Docker Images (w/ code) Kubernetes need Docker images Objectives : • Create docker images • Push them in a place kubernetes can retrieve them
  • 40. Kubernetes Dockerfile Dockerfile specifies an image with microservice code Dockerfile
  • 41. Kubernetes Dockerfile FROM artifact/meetic/php56 ARG version=master ARG stage=release ARG apiName= COPY docker-entrypoint.sh /entrypoint.sh RUN chmod a+x /entrypoint.sh && chown root:root /entrypoint.sh COPY config/fpm/php-fpm.d/* /etc/opt/rh/rh-php56/php-fpm.d/ COPY config/tnsnames.ora /etc/ RUN wget "https://artifact/php-$stage/$apiName/$version.tar.gz" && tar zxvf "$version.tar.gz" ENTRYPOINT ["/entrypoint.sh"] CMD ["/opt/rh/rh-php56/root/usr/sbin/php-fpm", "-F"] CentOS 6.9 Meetic/CentOS 6.9 Meetic/PHP 5.6 Microservice container PHP Dockerfile not versioned in repositories
  • 42. The Data A lot of data We can't just clone the databases in our testing environment Our data is stored across multiple technology Two constraints : • We need to create a sub-set of users that is coherent • We need to anonymize the data
  • 43. Database Images Need Data coherence across all our storage instances Extract a coherent subset of data. - same ratio H/M - same ratio of search - same ratio of active/inactive … With the ID's, extract from all database the data for those members
  • 47. Helm Helm is a package manager for Kubernetes. • Creating packages (called charts) • Sharing packages on a platform • Deploying shared packages easily on kubernetes
  • 48. Helm - Charts “A chart is a collection of files that describe a related set of Kubernetes resources.” “Charts are created as files laid out in a particular directory tree, then they can be packaged into versioned archives to be deployed.” + Templates Values Package
  • 50. Helm – the problem Helm is great but the use case does not really match our needs : • Helm is a CLI tools (only) • Helm comes with the features of a package manager that we don’t care about • Helm does not manage namespaces. It only handle package deployment.
  • 51. Testing env – our goal api-profile version 0.1.2 api-search version 1.3.2 Latest Version Latest Version Template and default values
  • 52. Introducing Blackbeard Blackbeard is a user friendly tool that handle package configuration and deployment across multiple kubernetes namespace. + Templates Inventory Inventory Playbook
  • 53. Blackbeard features • Create namespace • Apply configuration (deployments, services, etc.) • Get useful informations about namespace state (Pods status, exposed service via NodePort or Ingress) • Delete namespace
  • 58. Working with Blackbeard $ blackbeard create –n test # Create a namespace and default configuration $ vi inventories/test_inventory.json # Update the values to match needs $ blackbeard apply –n test # Apply the change to the namespace $ blackbeard get services # Show exposed services $ blackbeard delete –n test # Cleanup files and namespace
  • 59. Blackbeard under the hood • Written in the Go programming language • Interact with the Kubernetes API using the go client • Expose a collection of CLI commands using the Cobra framework • Expose a REST API trough the Gin framework • Rely on the .kube/config configuration file
  • 61. Conclusion Inheritance in Docker is a game changer when working with microservices and different testing strategy Give your users a base. Let them override the configuration. Don’t treat all the use cases with the same patterns.
  • 62. Conclusion Re-create an entire stack in kubernetes remains hard. You cannot just apply your prod configuration in a container. Some useful tricks stay undocumented. The kubernetes source code is very hard to understand for outsiders. There are plenty of tools and stories around kubernetes . But the reality is far from a fairy tail.

Hinweis der Redaktion

  1. Php with the right extentions So let's use this container to run test  WRONG Need to add tools to run test (sudo admin rights, ssh config tsa ora)
  2. Make files + Docker-compose Each micro service has some specificity  Some oracle some mysql
  3. Allows to have specific command to be executed while having a generic command. Allow to have the generic process to test out all the microservices while keeping the speci
  4. Satelite image  Oracle /mysql/elastic/cassandra