How to utilise

37

Transcript of How to utilise

Page 1: How to utilise
Page 2: How to utilise

Alexander Tolstikov Smile Open Source Solutions

How to utilise Open Source tools to create CI/CD & DevOps workflows

without vendor lock-in

Page 3: How to utilise

Possible workflows:

- Create Kubernetes cluster- Build release artifact (composer install, yarn build, npm)

- Deliver artifact (ansistano, capistrano, etc)- Drush operations

- Automated functional / load / smoke testing - Anything else?

Page 4: How to utilise

Workflow example:Kubernetes cluster creation on GCP

Page 5: How to utilise

Evolution of the workflow

Page 6: How to utilise

Iteration 1:Create k8s cluster manually with UI

ToolsGCP UI

Secrets/Access You need to be authenticated in the browser

Pros • Very fast • No need to maintain dependencies / tools on the local PC

Cons • Need to remember all command params • Need to do the same for all resources (VPC, subnets, DNS, etc) • Human error-prone • Only you know what you did

Page 7: How to utilise

Congratulations! We just created a snowflake cluster!

Page 8: How to utilise

Snowflakes are beautiful…

Page 9: How to utilise

…but so different (and fragile)

Page 10: How to utilise

“ “Martin Fowler

The true fragility of snowflakes, however, comes when you need to change them. Snowflakes soon become hard to understand and modify. You're not sure what parts of the configuration are important. Their fragility leads to long, stressful bouts of debugging.

Page 11: How to utilise

Toolsgcloud (from Google Cloud SDK)

Secrets/Access Need to be authenticated on the local PC

Pros More “fixed” compared to manual UI operation

Cons • Need to remember all command params • Need to do the same for all other resources (VPC,

subnets, …) • Human error-prone • No centralised history / logs • Still “Snowflake” infrastructure

Iteration 2: Create k8s cluster manually with “gcloud” command

Page 12: How to utilise

Tools • terraform Secrets • Need to use GCP key file stored on the local PC Principles / Concepts • Infrastructure as Code Pros • Logic and configuration are separated (different terraform files) • Can be (should be!) checked-in into Git repo Cons • Need to copy/paste files with variables for different environments manually • Configuration drift is still possible with multiple environments

Iteration 3:Create k8s cluster with terraform: Manual terraform commands execution

Page 13: How to utilise

Iteration 4:PROD & TEST environments & single master config file

Page 14: How to utilise

Need to introduce some tools!

Page 15: How to utilise

“ “Unix philosophy

• Do one thing and do it well. • Make programs to work together. • Write programs to handle text streams,

because that is a universal interface.

Page 16: How to utilise

Tool: uniconf (https://github.com/aroq/uniconf)Config processing (YAML)

Sorry, no documentation…

Page 17: How to utilise

Input config Output config

OutputInput

Page 18: How to utilise

Tool: uniconf (https://github.com/aroq/uniconf)Config processing (YAML)

Page 19: How to utilise

Tool:jq (https://github.com/stedolan/jq)

Config processing (JSON)

Use to extract data from JSON

A lot of filters are available

Check the documentation!

Page 20: How to utilise

Tool:yq (https://github.com/mikefarah/yq)

Config processing (YAML)

Same as jq tools but for YAML files

Basically is a wrapper over jq tool

Page 21: How to utilise

uniconf | yq

Page 22: How to utilise

Output

Page 23: How to utilise

Tool:gomplate (https://github.com/hairyhenderson/gomplate)

Template rendering. Supports lots of local and remote datasources.

Check the documentation!

Page 24: How to utilise

Output

Output

Template

Page 25: How to utilise

Tool:variant (https://github.com/mumoshu/variant)

“One glue to glue them all!”

“Makefile on steroids”

Task definition

Task execution

Page 26: How to utilise

Variant task execution

Page 27: How to utilise

Plain command vs Variant task execution

Page 28: How to utilise

Iteration 4:PROD & TEST environments & single master config file

Now you need to maintain more tools / dependencies:

terraform unicorn

jq / yq gomplate

variant

It can be an issue if we want to execute this workflow somewhere else because we’ll need to sync all software versions, dependencies, etc

Page 29: How to utilise

Dependency hellPythonRuby

NodeJS…

Page 30: How to utilise

How to fix the Dependency Hell issue: Put all tools into the container (Docker)

+ =love

Page 31: How to utilise

Secrets management

Page 32: How to utilise

Managing secrets

Git Secret (https://github.com/sobolevn/git-secret#git-secret)

Chamber (https://github.com/segmentio/chamber)

GPG (https://gpgtools.org/)

AWS Vault (https://github.com/99designs/aws-vault)

Page 33: How to utilise

Execute the workflow in the CICD engine: Gitlab CI

Page 34: How to utilise

Gitlab CI pipeline

Page 35: How to utilise

Demo time!

Page 36: How to utilise

Next steps:GitOps? Check Atlantis:

https://github.com/runatlantis/atlantis

Page 37: How to utilise

Alexander [email protected] / [email protected]

You can find me on Drupal slack as well!

https://www.smile.eu/