Skip to content

Commit

Permalink
Devops: Terraform updates
Browse files Browse the repository at this point in the history
  • Loading branch information
mcruanes committed May 29, 2021
1 parent da8972c commit db91b32
Show file tree
Hide file tree
Showing 28 changed files with 888 additions and 78 deletions.
48 changes: 29 additions & 19 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# DevOps with examples
by seomago
date: 3/5/2021
Update: 29/5/2021

## About the project

These are a list of self-study examples for my personal Devops roadmap learning path.
These is a list of self-study examples for my personal Devops roadmap learning path.
DevOps is changing the way of developing web applications. We will be building several web applications
using different technologies.
We will be using debian distribution linux machines.
Expand All @@ -22,12 +22,16 @@ git clone git@github.com/seomago/devops-examples
If you like this project and you want to contribute, you're more than welcome to do it, See contribute section below.



## 1. Sysadmin linux examples
Classic web app 3-tier installation
1. [App Mono tier ghost - without ansible - the old non devops way](./sysadmin/1)
2. [App Mono tier ghost install - with ansible](./sysadmin/2)
3. [App 3-tier ghost install](./sysadmin/3)
## 1. Terraform examples (with docker)
1. [Terraform and docker provider example 1](./terraform/1)
2. [Terraform database container](./terraform/2)
3. [wordpress container example](./terraform/3)
4. [Reverse proxy Traefik with wordpress container](./terraform/4)
5. [Nginx Ghost example](./terraform/5)
6. [Minio S3 container](./terraform/6)
7. [Terraform and modules](./terraform/7)
8. [kubernetes kind provider](./terraform/8)
9. Terraform AWS EKS cloud examples...

## 2. Docker examples
1. [Docker-compose App 3-tier install](./docker/1)
Expand All @@ -40,16 +44,15 @@ Classic web app 3-tier installation
2. [arkade+kind+k9s+delete namespace+kubectl get nodes+k apply.Services and Load Balancers](./kubernetes/2)
3. [arkade+k9s+Deployments](./kubernetes/3) / [video](https://youtu.be/q-ZicDSb3Cc)
4. [App easy install with arkade](./kubernetes/4)
5. more to come...
5. [kubernetes and ingress example](./kubernetes/5) /
6. [kubernetes and argo CD example](./kubernetes/6) /
7. more to come...

## 4. Terraform examples (with docker)
1. [Terraform and docker provider example 1](./terraform/1) /
2. [Terraform database container](./terraform/2) /
3. [wordpress container example](./terraform/3) /
4. [Reverse proxy Traefik with wordpress container](./terraform/4) /
5. [Nginx Ghost example](./terraform/5)
6. [kubernetes and terraform](./terraform/6)
7. Terraform AWS cloud examples
## 4. Sysadmin linux - ansible examples
Classic web app 3-tier installation
1. [App Mono tier ghost - without ansible - the old non devops way](./sysadmin/1)
2. [App Mono tier ghost install - with ansible](./sysadmin/2)
3. [App 3-tier ghost install](./sysadmin/3)

## 5. Salt examples

Expand All @@ -65,7 +68,7 @@ Classic web app 3-tier installation
2. [Portainer CE / weavescope and docker swarm](./mix/3) /
3. [Jupyter notebooks presentation and installation](./mix/4) /
4. [kubernetes cluster with kubeadm](./mix/5) /
5. [argo CD](./mix/3) /

6. [influxdb / telegraf](./mix/3) /
7. [Prometheus](./mix/3)
8. [App Mono tier ghost install - with bash jupyter notebook](./sysadmin/2)
Expand All @@ -78,15 +81,22 @@ Classic web app 3-tier installation
* https://github.com/alexellis/arkade
* https://www.server-world.info/en/note?os=CentOS_7&p=salt&f=1
* https://www.server-world.info/en/note?os=CentOS_7&p=ansible&f=1

* https://github.com/lokeshkamalay/DevOps-References
* https://github.com/seomago/devops-examples
* https://github.com/geerlingguy/ansible-for-devops
* https://github.com/geerlingguy/ansible-for-kubernetes

## References Terraform
* https://gitlab.com/xavki/presentations-terraform-fr
* https://github.com/zealvora/terraform-beginner-to-advanced-resource



## Feedback / Contribute

I am sure all these exercises are can be improved/more academic.
If you like this project and you want to contribute, you're more than welcome to do it, just fork it and make a pull request when you're ready. Here, you can see the [To Do list](https://github.com/xe-nvdk/ezcompose/projects/1) and here the [Issues](https://github.com/xe-nvdk/ezcompose/issues).
If you like this project and you want to contribute, you're more than welcome to do it, just fork it and make a pull request when you're ready. Here, you can see the [To Do list](https://github.com/seomago/devops-examples/projects/1) and here the [Issues](https://github.com/seomago/devops-examples/issues).


## Acknowledgements
Expand Down
23 changes: 23 additions & 0 deletions docker/2/docker-compose.scope.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
version: '2'
# sudo docker-compose -f docker-compose.scope.yml up -d
services:
nginx-proxy:
image: jwilder/nginx-proxy
ports:
- "80:80"
volumes:
- /var/run/docker.sock:/tmp/docker.sock:ro
# localhost:4040
scope:
image: weaveworks/scope:1.13.2
#network_mode: "host"
pid: "host"
privileged: true
labels:
- "works.weave.role=system"
volumes:
- "/var/run/docker.sock:/var/run/docker.sock:rw"
command:
- "--probe.docker=true"
environment:
- VIRTUAL_HOST=scope.aa.com
34 changes: 34 additions & 0 deletions docker/2/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
version: '2'
services:
#nginx-proxy:
# image: jwilder/nginx-proxy
# ports:
# - "80:80"
# volumes:
# - /var/run/docker.sock:/tmp/docker.sock:ro


whoami1:
image: jwilder/whoami
environment:
- VIRTUAL_HOST=preprod.aa.com,adminpre.aa.com
whoami2:
image: jwilder/whoami
environment:
- VIRTUAL_HOST=preprod.aa.com


adminer1:
image: adminer:4.8.0
environment:
- VIRTUAL_HOST=prod.aa.com
#adminer2:
# image: adminer:4.8.0
# environment:
# - VIRTUAL_HOST=prod.aa.com




#easymysql
#curl -is aa.com
Empty file added docker/2/readme.md
Empty file.
21 changes: 21 additions & 0 deletions kubernetes/2/nginx-deploy.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: nginx-deployment
labels:
env: dev
spec:
replicas: 3
selector:
matchLabels:
env: dev
template:
metadata:
labels:
env: dev
spec:
containers:
- name: nginx
image: nginx
ports:
- containerPort: 80
13 changes: 13 additions & 0 deletions kubernetes/2/nginx-svc.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#https://github.com/seomago/Course_EKS-Basics/blob/master/nginx-svc.yaml
apiVersion: v1
kind: Service
metadata:
name: nginx-svc
labels:
env: dev
spec:
type: LoadBalancer
ports:
- port: 80
selector:
env: dev
41 changes: 41 additions & 0 deletions references.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@

## socks
https://github.com/microservices-demo/microservices-demo
logging fluentd and elasticsearch
locust python load performance
## logging fluentd elasticsearch
https://github.com/microservices-demo/microservices-demo/blob/master/deploy/docker-compose/docker-compose.logging.yml
https://github.com/microservices-demo/microservices-demo/blob/master/deploy/docker-compose/docker-compose.yml
https://docs.bitnami.com/kubernetes/apps/fluentd/


## References 2
https://github.com/aminueza/terraform-provider-minio
https://github.com/severalnines/ansible-clustercontrol

## references kube
devops tools k9s
https://www.golinuxcloud.com/kubernetes-pod/

https://github.com/gruntwork-io/infrastructure-as-code-training
https://github.com/xe-nvdk
https://github.com/PacktPublishing/Cloud-Native-with-Kubernetes
https://github.com/shashank-ssriva/WordPress-on-Minikube


## french youtube channels
https://gitlab.com/users/xavki/projects
https://gitlab.com/xavki/presentations-dockercompose

https://www.youtube.com/c/xavki-linux

https://www.youtube.com/watch?v=hMpGUy3hngc
les chaines francophones

Xavki : https://www.youtube.com/channel/UCs_A...​
Adrien D Linuxtricks : https://www.youtube.com/channel/UCDKP...​
Cocadmin : https://www.youtube.com/channel/UCVRJ...​
Yves Rougy : https://www.youtube.com/channel/UCfsE...​
Tonton Jo : https://www.youtube.com/channel/UCnED

@grafikart_fr @Cookieconnecte @KrustyHack (pas forcement 100% linux mais qui l'aborde un peu)
4 changes: 2 additions & 2 deletions terraform/1/container.tf
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#}


# Devops exercise container 2
# Devops exercise container 1
resource "docker_container" "hello_world" {
name = "de_hello_world"
image = "tutum/hello-world"
Expand All @@ -23,7 +23,7 @@ resource "docker_container" "hello_world" {
}
}

# Devops exercise container 3
# Devops exercise container 2
resource "docker_container" "adminer" {
name = "de_adminer"
image = "adminer:4.8.0"
Expand Down
4 changes: 2 additions & 2 deletions terraform/1/readme.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
## intro terraform

Terraform is a famous declarative infrastructure as code IAC tool.

## arkade terraform install

Expand All @@ -23,7 +23,7 @@ ls terraform.tfstate*
* terraform remote push (minio) S3 / consul from iac book


Terraform is a famous declarative infrastructure as code IAC tool.


## reference

Expand Down
14 changes: 14 additions & 0 deletions terraform/2/provider.tf
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@

# Set the required provider and versions
terraform {
required_providers {
# We recommend pinning to the specific version of the Docker Provider you're using
# since new versions are released frequently
docker = {
source = "kreuzwerker/docker"
version = "2.11.0"
}
}
}


# Configure the Docker provider
provider "docker" {
host = "unix:///var/run/docker.sock"
Expand Down
13 changes: 13 additions & 0 deletions terraform/3/provider.tf
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,17 @@ variable "local" {}
provider "docker" {

host = "${var.local}"
}


# Set the required provider and versions
terraform {
required_providers {
# We recommend pinning to the specific version of the Docker Provider you're using
# since new versions are released frequently
docker = {
source = "kreuzwerker/docker"
version = "2.11.0"
}
}
}
14 changes: 14 additions & 0 deletions terraform/4/provider.tf
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@

# Set the required provider and versions
terraform {
required_providers {
# We recommend pinning to the specific version of the Docker Provider you're using
# since new versions are released frequently
docker = {
source = "kreuzwerker/docker"
version = "2.11.0"
}
}
}


# Configure the Docker provider
provider "docker" {
host = "unix:///var/run/docker.sock"
Expand Down
6 changes: 6 additions & 0 deletions terraform/4/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,9 @@ En este ejemplo, un poco más complejo que el anterior, voy a desplegar con Terr
Este ejemplo, te servirá de manera práctica para tener un wordpress, con su base de datos, ambos, por detrás de un Reverse Proxy con su configuración para que obtenga certificados SSL de Lets Encrypt. También te mostrará como usar una serie de recursos de Terraform, tales volumenes, labels, commandos y variables de entorno.

Si ves que se puede mejorar, hacer un fork y luego hace un Pull Request.


Traefik

a.com
c.com
2 changes: 1 addition & 1 deletion terraform/4/traefik.tf
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Contenedor Traefik
resource "docker_container" "traefik" {
name = "cduser_traefik"
name = "my_traefik"
image = "traefik:v2.1.4"
command = ["--entrypoints.web.address=:80", "--entrypoints.websecure.address=:443", "--providers.docker", "--api", "--api.dashboard=true", "--log.level=ERROR", "--accesslog.filepath=/Users/nacho/terraform/files/traefik/log/access.log", "--accesslog.format=json", "--accesslog.filters.statuscodes=200,300-302", "--accesslog.filters.retryattempts", "--accesslog.filters.minduration=10ms", "--certificatesresolvers.leresolver.acme.httpchallenge=true", "--certificatesresolvers.leresolver.acme.email=nombre@email.com", "--certificatesresolvers.leresolver.acme.storage=/acme.json", "--certificatesresolvers.leresolver.acme.httpchallenge.entrypoint=web"]

Expand Down
Loading

0 comments on commit db91b32

Please sign in to comment.