Repository: bregman-arie/devops-resources
Branch: master
Commit: 1c2f37f44070
Files: 67
Total size: 116.0 KB
Directory structure:
gitextract_0itf_d7e/
├── .gitignore
├── README.md
├── credits.md
├── resources/
│ ├── Grafana/
│ │ ├── deployment.yml
│ │ ├── grafana.md
│ │ └── service.yml
│ ├── ansible.md
│ ├── argocd.md
│ ├── aws.md
│ ├── azure.md
│ ├── bash.md
│ ├── chaos_engineering.md
│ ├── cicd.md
│ ├── coding.md
│ ├── containers.md
│ ├── dataops.md
│ ├── docker.md
│ ├── elk.md
│ ├── gcp.md
│ ├── git.md
│ ├── github.md
│ ├── gitops.md
│ ├── go.md
│ ├── groovy.md
│ ├── jenkins/
│ │ ├── README.md
│ │ ├── jjb/
│ │ │ └── gate.md
│ │ ├── pipeline/
│ │ │ ├── README.md
│ │ │ ├── basic_declarative_pipeline
│ │ │ ├── basic_scripted_pipeline
│ │ │ └── tips.md
│ │ └── scripts/
│ │ ├── README.md
│ │ ├── builds/
│ │ │ ├── abort.groovy
│ │ │ ├── remove_old.groovy
│ │ │ └── remove_old_v2.groovy
│ │ ├── jobs/
│ │ │ ├── delete_jobs_with_regex.groovy
│ │ │ ├── print_all_jobs.groovy
│ │ │ ├── print_jobs_with_regex.groovy
│ │ │ ├── rename_job.groovy
│ │ │ └── rename_jobs_with_regex.groovy
│ │ ├── nodes/
│ │ │ ├── check_all_online.groovy
│ │ │ └── print_node_groups.groovy
│ │ ├── notification/
│ │ │ └── notifier/
│ │ │ ├── __init__.py
│ │ │ ├── main.py
│ │ │ └── parse.py
│ │ ├── plugins/
│ │ │ └── list_all_plugins.groovy
│ │ └── tests/
│ │ └── count_test_failures.groovy
│ ├── jinja2.md
│ ├── kubernetes.md
│ ├── linux.md
│ ├── machine_learning.md
│ ├── mongo.md
│ ├── monitoring.md
│ ├── network.md
│ ├── openshift.md
│ ├── opensource.md
│ ├── openstack.md
│ ├── packer.md
│ ├── prometheus.md
│ ├── python.md
│ ├── security.md
│ ├── sql.md
│ ├── terraform.md
│ ├── vault.md
│ ├── victoriametrics.md
│ ├── virtual_machines.md
│ └── virtualization.md
└── roadmaps.md
================================================
FILE CONTENTS
================================================
================================================
FILE: .gitignore
================================================
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class
# C extensions
*.so
# Distribution / packaging
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
*.egg-info/
.installed.cfg
*.egg
MANIFEST
# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec
# Installer logs
pip-log.txt
pip-delete-this-directory.txt
# Unit test / coverage reports
htmlcov/
.tox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
.hypothesis/
.pytest_cache/
# Translations
*.mo
*.pot
# Django stuff:
*.log
local_settings.py
db.sqlite3
# Flask stuff:
instance/
.webassets-cache
# Scrapy stuff:
.scrapy
# Sphinx documentation
docs/_build/
# PyBuilder
target/
# Jupyter Notebook
.ipynb_checkpoints
# pyenv
.python-version
# celery beat schedule file
celerybeat-schedule
# SageMath parsed files
*.sage.py
# Environments
.env
.venv
env/
venv/
ENV/
env.bak/
venv.bak/
# Spyder project settings
.spyderproject
.spyproject
# Rope project settings
.ropeproject
# mkdocs documentation
/site
# mypy
.mypy_cache/
================================================
FILE: README.md
================================================

:information_source: This repository is about gathering any useful resources and information regarding DevOps and secondly, provide some roadmap for those who want to practice DevOps.
:pencil: Feel free to add more resources by submitting pull requests
****
* [DevOps Roadmap](#devops-roadmap)
* [Alternative Roadmaps](#alternative-roadmaps)
* [Learn About DevOps](#learn-about-devops)
* [Learn Git](#learn-git)
* [Programming](#programming)
* [Operating Systems](#operating-systems)
* [DevOps Toolchain](#devops-toolchain)
## DevOps
### DevOps Roadmap
* The following path is opinionated. You can find alternative paths in the [alternative roadmaps section](#alternative-roadmaps)
* Do NOT attempt to learn everything, especially if you are a complete beginner (the burnout will make you regret you ever heard the word DevOps)
* Learn enough to say "I know what is DevOps and I understand how to practice it". You can learn everything else by demand or when you feel ready
The must list
Topic | What to learn | Alternatives | Description
:------|:------|:------|:------:
Version Control | [Git](#Learn-git) | - | Version Control is used everywhere and Git is the leading version control technology
Programming | At least one [programming language](#programming) | None. Don't settle for learning only shell scripting | Anyone who practice DevOps should know programming to some extent
Operating System | [Linux](#operating-systems) | Other distribution of Linux :D | Operating Systems is another must when it comes to DevOps
Protocols | DHCP, UDP, TCP, HTTP, SSH | Not as an alternative, you can simply learn later: NFS, NTP, FTP | Learn how these protocols work and what they are used for
Applications | Web Server, Load Balancer, Cache, Database | | Learn how they work and try out some implementations (e.g. MySQL for databases and httpd for web servers)
[System Design](https://github.com/bregman-arie/system-design-notebook) | Availability, Reliability, Scalability, Performance | Learn how to design infrastructure and systems
The second must list :)
Seriously though, don't try to master everything in this list and start with something that you are interested in. The order has no meaning in this case.
Topic | What to learn | Alternatives | Description
:------|:------|:------|:------:
Configuration Management and IaC | Ansible and Terraform | CM: Chef, Puppet and Salt. IaC: Pulumi and CloudFormation |
Cloud | Azure, AWS, GCP | - |
Containers | Podman and Kubernetes| Docker instead of Podman. Nomad instead of Kubernetes |
CI/CD | Jenkins, GitHub Actions | Gitlab CI, Circle CI, Argo CD |
Logging and Dashboards | Elastic Stack, Report Portal, Grafana | Graylog, Splunk |
Monitoring | VictoriaMetrics, Prometheus | Nagios, Centreon, Datadog |
### Alternative Roadmaps
There are other DevOps roadmaps and learning plans out there. If you feel the one above is little bit too much or just want to look at other options, maybe you'll find the following useful
Name | Description
:------|:------:
[DevOps Roadmap](https://github.com/kamranahmedse/developer-roadmap) | DevOps skills roadmap. What to to learn at each step.
[DevOps 3 Weeks Plan](https://medium.com/@medineshkatwal/devops-3-week-plan-from-16-oct-2019-to-31st-oct-2019-af486e625f72) | Detailed plan on what to do at each day
[How to Become a DevOps Engineer in Six Months?](https://spacelift.io/blog/how-to-become-devops-engineer) | Skills you need to become DevOps Engineer
### Learn about DevOps
Name | Description
:------|:------:
[What is DevOps? - Amazon](https://aws.amazon.com/devops) | Learn what is DevOps by Amazon and which AWS services can help you to practice DevOps
[What is DevOps? - Red Hat](https://www.redhat.com/en/topics/devops) | Learn what is DevOps by Red Hat, including many interesting articles
[What is DevOps? - Microsoft](https://docs.microsoft.com/en-us/azure/devops/learn/what-is-devops) | Learn what is DevOps by Microsofy, including Azure DevOps service
[What is DevOps? - Google](https://cloud.google.com/devops) | Learn what is DevOps by Google
[Who is DevOps? - Spacelift](https://spacelift.io/blog/who-is-devops-engineer) | Who is DevOps? Is it Worth it to Become a DevOps Engineer?
### Learn Git
Make sure you are comfortable with the following list once you done learning Git basics
* Commit changes to a project
* Submit pull/merge requests
* Working with branches
* Rebase changes (change order, squash, ...)
Name | Description
:------|:------:
[Interactive Git Branching Learning](https://learngitbranching.js.org/) | Visual and interactive way to learn Git branching
[Learn git concepts, not commands](https://dev.to/unseenwizzard/learn-git-concepts-not-commands-4gjc) | Article on Git concepts
[Codeacademy Learn Git](https://www.codecademy.com/learn/learn-git) | Not Free
### Programming
Practicing DevOps without knowing programming is like eating cornflakes with ketchup - it's just doesn't makes sense (yes, my analogies are the worst).
Here is a list of some good sites to practice programming in general:
Name | Comments
:------|:------:
[HackerRank](https://www.hackerrank.com) | Practice Coding skills
[Exercism](https://exercism.io) | Over 48 languages and 2600 exercises
[LeetCode](https://leetcode.com) | Practice programming online
A better approach might be to actually write some DevOps related scripts or projects. Start simple. Here are some ideas:
* Write a script that gets a number of instances and a name of a platform (AWS, local, Azure, ...) as parameters and provisions those instances on the chosen platform
* Write a script to parse logs and extract some specific information you are interested in
* Write a script that extracts information from some website using web scraping libraries
### Operating Systems
Deep dive into operation system internals. Linux should be your first choice.
Here is a list of resources that will help you learn Linux.
Also, don't waste a second on picking the right distribution. For learning OS concepts and internals, any distribution would work fine.
Name | Comments
:------|:------:
[Linux Journey](https://linuxjourney.com) | Written guides + exercises + quiz
[Techmint Linux](https://www.tecmint.com/free-online-linux-learning-guide-for-beginners) | Written articles/lessons
[Linux Survival](https://linuxsurvival.com/linux-tutorial-introduction) | Interactive guide
Once you are familiar with the commands and feel comfortable enough to keep deep diving, learn some OS concepts:
* Memory Management
* Processes
* Kernel
* Virtualization
* Storage
#### Linux Master Application
A completely free application for testing your knowledge on Linux
### System Design
System Design can be a complex topic. For that reason, I've created a separate repository for you to learn it properly.

### Tooling, Apps & Services
Name | Description
:------|:------:
[Periodic table of DevOps tools](https://xebialabs.com/periodic-table-of-devops-tools) | Table of DevOps tools per category
[DevOps tool chest](https://xebialabs.com/the-ultimate-devops-tool-chest/#tool-chest-type) | List of DevOps tools
[DevOps Bookmarks](http://www.devopsbookmarks.com) | NSIA
[CNCF Cloud Native Interactive Landscape](https://landscape.cncf.io) | CNCF's recommended path through the cloud native landscape
[DevOpsBookmarks](https://www.devopsbookmarks.org) | To discover tools in the devops landscape.
## Interactive practice and learning sites
Learning by doing proved to be a very effective way to learn new things. If you are at a point where you don't feel comfortable enough to do it by yourself and you look for some guidance, the following sites might assist you
Name | Description
:------|:------:
[Kodekloud Engineer](https://www.kodekloud-engineer.com/) | perform real tasks by working in a fictional organization
[QWIKLBAS](https://www.qwiklabs.com) | AWS, GCP, ... lab practice
## Community
Another great way to learn is to learn from the experience of others. For that, the are some excellent DevOps communities.
Name | Comments
:------|:------:
[Reddit DevOps](https://www.reddit.com/r/devops) | Reddit DevOps Community
[Linkedin DevOps](https://www.linkedin.com/groups/2825397) | Linkedin DevOps Community
[DevOps Bits](https://www.facebook.com/groups/538897960007080) | Facebook DevOps group. Disclosure: I started it :)
## Conferences
Name | Comments
:------|:------:
[DevOpsDays](https://devopsdays.org) | DevOps Conferences around the world
[Velocity](https://conferences.oreilly.com/velocity) | Oracle's DevOps conference
## Books
Read book! Practice is important and the best way to learn practical things but reading about cultures, methods, concepts, ... has its own important role in your path towards mastering DevOps and SRE.
Name | Comments
:------|:------:
[The Phoenix Project](https://www.amazon.com/Phoenix-Project-DevOps-Helping-Business/dp/1942788290) | DevOps explained through a story of a fictional company on the brink of a failure
[The DevOps Handbook](https://www.amazon.com/dp/1942788002) |
[Google SRE books](https://landing.google.com/sre/books) | Very detailed books on the theory and also practice of SRE
[Essential Infrastructure as Code](https://www.manning.com/books/essential-infrastructure-as-code) | VBook about automating software infrastructure by capturing desired configurations as a set of scripts.
## Blogs & News
My top picks:
Name | Description
:------|:------:
[Codefresh Blog](https://codefresh.io/blog) | Probably best GitOps content out there
Other DevOps & Software Engineering related blogs
Name | Description
:------|:------:
[Spacelift Blog](https://spacelift.io/blog) | Excellent tech blog on Kubernetes, Ansible, Terraform and Engineering in general
[opensource.com](https://opensource.com) | open source related articles including DevOps
[CooperPress](https://cooperpress.com/publications) | various newsletters on different topics
[afreshcup](https://afreshcup.com) | "covering Ruby on Rails and whatever else I find interesting in the universe of software"
[thisweekindevops.com](https://thisweekindevops.com) | "DevOps news without the hype"
[Uber Engineering](https://eng.uber.com/) | Not only DevOps
[Azure DevOps Blog](https://devblogs.microsoft.com/devops) | Microsoft DevOps Blog
[DevOps Dudes](https://medium.com/devops-dudes) | "Shortening the system development life cycle"
[Netflix Tech Blog](https://netflixtechblog.com/tagged/devops) | Not Only DevOps
[CloudBees Blog](https://www.cloudbees.com/blog) |
[Red Hat Blog](https://www.redhat.com/en/blog) | Not only DevOps
[Atlassian DevOps Blog](https://www.atlassian.com/blog/devops) |
[Facebook Engineering Blog](https://engineering.fb.com) | Not only DevOps
[DoorDash Engineering Blog](https://doordash.engineering) | Not only DevOps
[Palark tech blog](https://blog.palark.com/) | Tech blog dedicated to DevOps & SRE
## Articles
Name | Description
:------|:------:
[Infrastructure as Code, Part One](https://crate.io/a/infrastructure-as-code-part-one) |
[DevOps Best Practices](https://gist.github.com/jpswade/4135841363e72ece8086146bd7bb5d91) | What is DevOps + list of resources
[Infrastructure as Code: Examples, Best Practices & Tools](https://spacelift.io/blog/infrastructure-as-code) |
## DevOps Snippets
Name | Description
:------|:------:
[DevOpsnipp](https://www.devopsnipp.com/) | Sharing DevOps Snippets
[Gist](https://gist.github.com) | Not DevOps specific
## Other Great Projects
Name | Comments
:------|:------:
[DevOps Wiki](https://github.com/Leo-G/DevopsWiki) | "A wiki of Devops Tools, Tutorials and Scripts"
[cheat-sheet-pdf](https://github.com/sk3pp3r/cheat-sheet-pdf) | "Cheat-Sheet Collection for DevOps, Engineers, IT and more"
[System Design Primer](https://github.com/donnemartin/system-design-primer) | "Learn how to design large-scale systems. Prep for the system design interview. Includes Anki flashcards."
[awesome-sre](https://github.com/dastergon/awesome-sre) | A curated list of Site Reliability and Production Engineering resources
## Interview Questions
Name | Comments
:------|:------:
[System Design Primer](https://github.com/donnemartin/system-design-primer) | "Learn how to design large-scale systems. Prep for the system design interview. Includes Anki flashcards."
kdn251 | [Interviews](https://github.com/kdn251/interviews) |
[DevOps Exercises](https://github.com/bregman-arie/devops-exercises) | By topic, DevOps related questions and exercises
## Misc
Name | Description
:------|:------:
[CheatSheets](https://cheatsheet.dennyzhang.com) | CheatSeets for Kubernetes, Jenkins, YAML, Groovy, etc.
[Codelabs](https://codelabs.transcend.io) | "Codelabs provide a guided, tutorial, hands-on coding experience"
## Design & Architecture
Name | Description
:------|:------:
[The 12 Factor App](https://12factor.net) | must-read in my opinion
[A distributed Systems Reading List](https://dancres.github.io/Pages/?fbclid=IwAR2gapLU03iaxH4NDotc0LD_GiXOkyByfMT3iwufofUOEfCKEVwmezE3vCw)
## DevOps Tooling
- [ ] CI/CD
- [ ] [Jenkins](https://www.jenkins.io/) (Managed & on-premise, Containers supported, Plugins)
- [ ] [GitHub Actions](https://docs.github.com/en/actions) (Hosted service)
- [ ] [Travis](https://travis-ci.org/) (Hosted service)
- [ ] [CircleCI](https://circleci.com/) (Hosted service)
- [ ] [GitLab CI](https://docs.gitlab.com/ee/ci/) (Hosted service and on-premise)
- [ ] [Bamboo](https://www.atlassian.com/software/bamboo) (Managed service and on-premise)
- [ ] [BuildKite](https://buildkite.com) (Hosted)
- [ ] [Zuul](https://zuul-ci.org/docs/zuul) (Hosted and on-premise)
- [ ] [Drone](https://www.drone.io)
- [ ] [Tekton](https://cloud.google.com/tekton)
- [ ] [Argo CD](https://argoproj.github.io/argo-cd)
- [ ] [werf](https://werf.io/)
Note: "Provisioning" tools can be used to perform configuration management to some extent. The same applies for configuration management tools, which can be used for pprovisioning.
- [ ] Provisioning
- [ ] Terraform (Open Source)
- [ ] CloudFormation (Available only on AWS)
- [ ] Pulumi (Open Source)
- [ ] Configuration Management (all Open Source)
- [ ] Ansible (Agentless, Mutable Infrastructure, Procedural)
- [ ] Puppet (Agent, Mutable Infrastructure, Procedural)
- [ ] Chef (Mutable Infrastructure)
- [ ] Saltstack (Mutable Infrastructure)
- [ ] [Spacelift](https://spacelift.io/) (`$$$`)
- [ ] Images
- [ ] [diskimage-builder](https://github.com/openstack/diskimage-builder)
- [ ] [Packer](https://www.packer.io)
- [ ] Cloud
- [ ] AWS
- [ ] Azure
- [ ] GCP
- [ ] OpenStack
- [ ] Monitoring
- [ ] [AppDynamics](https://www.appdynamics.com/product/infrastructure-monitoring)
- [ ] [Datadog](https://www.datadoghq.com/)
- [ ] [Dynatrace](https://www.dynatrace.com/platform/infrastructure-monitoring/)
- [ ] [Monit](https://mmonit.com/monit/)
- [ ] [Nagios](https://www.nagios.org/)
- [ ] [Centreon](https://www.centreon.com/centreon-editions/centreon-open-source/)
- [ ] [New Relic](https://newrelic.com/)
- [ ] [Prometheus](https://prometheus.io)
- [ ] [Sensu](https://sensu.io/)
- [ ] [SolarWinds](https://www.solarwinds.com/server-application-monitor)
- [ ] [Statuscake](https://www.statuscake.com) - Website Uptime & Performance
- [ ] [VictoriaMetrics](https://victoriametrics.com/) - a fast, cost-effective and scalable monitoring solution and time series database.
- [ ] [Zabbix](https://www.zabbix.com/)
- [ ] Collector of Metrics by agent
- [ ] [Telegraf](https://www.influxdata.com/time-series-platform/telegraf/)
Monitoring
- [ ] Log Management
- [ ] Logstash
- [ ] Graylog
- [ ] Papertrail
- [ ] Fluentd
- [ ] [Splunk](https://www.splunk.com)
- [ ] [SumoLogic](https://www.sumologic.com)
- [ ] Log aggregation system
- [ ] [Loki](https://grafana.com/oss/loki/)
- [ ] Dashboards
- [ ] Grafana
- [ ] Kibana (Elastic)
- [ ] Report Portal (Mostly for Test Automation)
- [ ] Security
- [ ] [Vault](https://www.vaultproject.io) - "Secure, store and tightly control access to tokens, passwords, certificates, encryption keys for protecting secrets..."
- [ ] [Open Policy Agent](https://www.openpolicyagent.org) - "Flexible, fine-grained control for administrators across the stack"
- [ ] Code review
- [ ] Gerrit - Code Review system
- [ ] PullPanda - A collection of Tools such as reminder & analytics
- [ ] Review Board
- [ ] Issue Tracking
- [ ] Jira
- [ ] Bugzilla
- [ ] Code coverage
- [ ] Cobertura
- [ ] Clover
- [ ] JaCoCo
- [ ] Data Processors
- [ ] Spark
- [ ] Apache Hadoop
- [ ] Apache Airflow
- [ ] Presto
- [ ] Analytics Engines
- [ ] Druid
- [ ] Dremio
- [ ] Snowflake
- [ ] Operations Data
- [ ] Salesforce
- [ ] Zuora
- [ ] Containers Orchestration
- [ ] Kubernetes
- [ ] OpenShift
- [ ] Nomad
- [ ] Alerting
- [ ] PagerDuty
- [ ] ServiceNow
- [ ] Slack (Mostly used for IM)
- [ ] Metric Storage
- [ ] InfluxDB
- [ ] Splunk
- [ ] Cloud Storage services and Databases
## More Infra & DevOps projects




## Credits
Images and icons attribution can be found [here](credits.md)
## License
[](https://creativecommons.org/licenses/by-nc-nd/3.0/)
================================================
FILE: credits.md
================================================
The image used for "Dataops" is taken from [Flaticon.com](Flaticon.com)
================================================
FILE: resources/Grafana/deployment.yml
================================================
apiVersion: apps/v1
kind: Deployment
metadata:
name: grafana
namespace: graf # Create and write the name of your own namespace
spec:
replicas: 1
selector:
matchLabels:
app: grafana
template:
metadata:
name: grafana
labels:
app: grafana
spec:
containers:
- name: grafana
image: grafana/grafana:latest
ports:
- name: grafana
containerPort: 3000
================================================
FILE: resources/Grafana/grafana.md
================================================
## Grafana
### Random
* Visualize latency for API endpoints:
```
1. Use https://github.com/prometheus/blackbox_exporter to point API endpoints
2. Scrape exporter with Prometheus
3. Graph from Grafana
```
## Setting up Grafana for Prometheus on Kuberentes
* Grafana is a Visualisation tool that we most commonly use with prometheus Now many of you might have struggled while setting up grafana and Prometheus. To Solve this Problem I have created this deployment file that you can Integrate with Prometheus. If you Don't know how to Setup Prometheus for monitoring in Kuberentes. You can visit prometheus section in this repository, There you will find all the files needed to setup prometheus.
To access Prometheus you can click on this. [Prometheus](../prometheus.md)
```bash
apiVersion: apps/v1
kind: Deployment
metadata:
name: grafana
namespace: graf #<-- Here you can add your own namespace.
spec:
replicas: 1
selector:
matchLabels:
app: grafana
template:
metadata:
name: grafana
labels:
app: grafana
spec:
containers:
- name: grafana
image: grafana/grafana:latest
ports:
- name: grafana
containerPort: 3000
```
I have included this files, You can access them here [Deployment.yml](./deployment.yml)
Note:-
After this deployment file, You will need to setup dashboard on your own.
Also since this is running inside container, so to access grafana dashboard you will
either have to port-forward or else you can make your own service file of type NodePort.
for a example, I will add a service file here that you can reuse with little changes.
Make sure you create your own namespace and edit your own namespace in this file or create a namespace with this name.
```bash
apiVersion: v1
kind: Service
metadata:
name: grafana
namespace: graf #--> write your own namespace make sure all files are in same namespace.
spec:
selector:
app: grafana
type: NodePort
ports:
- port: 3000
targetPort: 3000
nodePort: 32000
```
I have included this files, You can access them here [Service.yml](./service.yml)
Note: Make sure you have the basic knowledge of kuberentes. By default, the range of the service NodePorts is 30000-32768. So it means you can choose any range of your own.
When you will run this file, there is no need to port-forward and you can access this on port
i.e
``` :nodePort
```
This was how you can make use of grafana.
================================================
FILE: resources/Grafana/service.yml
================================================
apiVersion: v1
kind: Service
metadata:
name: grafana
namespace: graf #create and Write your own namespace
spec:
selector:
app: grafana
type: NodePort
ports:
- port: 3000
targetPort: 3000
nodePort: 32000
================================================
FILE: resources/ansible.md
================================================
## Ansible
### Learn Ansible
Name | Comments
:------ |:--------:
[Ansible 101 - Jeff Geerling](https://www.youtube.com/watch?v=goclfp6a2IQ&list=RDCMUCR-DXc1voovS8nhAvccRZhg&index=1) | Comprehensive practical way to learn Ansible
[What is Ansible? - TechWorld with Nana](https://www.youtube.com/watch?v=1id6ERvfozo) | High-level short overview of Ansible
[Learning Ansible basics - Red Hat](https://www.redhat.com/en/topics/automation/learning-ansible-tutorial) | Red Hat's guide on how to learn Ansible basics + links to the content itself
[Introduction to Ansible - 2021](https://medium.com/@bagusays/introduction-to-ansible-82f2bc12cd87) |
### Articles
Name | Comments
:------ |:--------:
[Writing reliable Ansible Playbooks - 2021](https://dev.to/xlab_si/writing-reliable-ansible-playbooks-295i) |
[A CI/CD Pipeline Project for a Trunk-Based Development Strategy in a Kubernetes Environment](https://medium.com/swlh/a-ci-cd-pipeline-project-for-a-trunk-based-development-strategy-in-a-kubernetes-environment-c4ffea9700fe) |
### Books
Name | Comments
:------ |:--------:
[Ansible for DevOps](https://www.amazon.com/Ansible-DevOps-Server-configuration-management/dp/098639341X) |
[Ansible: From Beginner to Pro](https://www.amazon.com/Ansible-Beginner-Pro-Michael-Heap/dp/1484216601) |
[Ansible: Up and Running](https://www.amazon.com/Ansible-Automating-Configuration-Management-Deployment/dp/1491979801) |
### Cheat Sheet
* Check if list has elements
```
when: my_list | length > 0
```
* Update all packages
```
- name: Update system packages
package:
state: latest
name: "*"
```
* Update packages informations and display packages informations
```
- name: Update packages informations
package_facts:
manager: "auto"
- name: Display all installed packages informations
debug:
msg: "{{ ansible_facts.packages }}"
- name: Display all Chromium package informations
debug:
msg: "{{ ansible_facts.packages['chromium'] }}"
when: "'chromium' in ansible_facts.packages"
```
================================================
FILE: resources/argocd.md
================================================
# ArgoCD
## Commands
* login: `argocd login `
* version: `argocd version`
### Apps
* create an application:
```
argocd app create {APP NAME} \
--project {PROJECT} \
--repo {GIT REPO} \--path {APP FOLDER} \
--dest-namespace {NAMESPACE} \
--dest-server {SERVER URL}
```
* app list: `argocd app list`
* app detailed info: `argocd app get `
* sync app: `argocd app sync `
* app history: `argocd app history `
* delete app: `argocd app delete `
* Add cluster: `argocd cluster add CLUSTER`
* List clusters: `argocd cluster list`
* Remove cluster: `argocd cluster rm CLUSTER
================================================
FILE: resources/aws.md
================================================
# AWS
## Infrastructure
Name | Comments
:------|:------:
[infrastructure.aws](https://infrastructure.aws) | AWS Infrastructure Overview
[Regions and Availability Zones](https://aws.amazon.com/about-aws/global-infrastructure/regional-product-services) | See services list per region and AZ
## Tools and Projects
Name | Comments
:------|:------:
[Cloud Mapper](https://github.com/duo-labs/cloudmapper) | "analyze your Amazon Web Services (AWS) environments""
[EC2 Instances Info](https://www.ec2instances.info) | "Easy Amazon EC2 Instance Comparison"
[amazon-redshift-utils](https://github.com/awslabs/amazon-redshift-utils) | "Contains utilities, scripts and view which are useful in a Redshift environment"
[Cloudcraft](https://www.cloudcraft.co) | Automated AWS diagram mapping of your cloud resources.
[nOps](https://www.nops.io/devops/) | "for fast-moving DevOps teams helping them ... monitor, analyze, and manage provisioned cloud workloads.", **Not Free.**
[EC2Instances.info](https://instances.vantage.sh) | "Easy Amazon EC2 Instance Comparison"
## Blog Posts & Articles
Name | Comments
:------|:------:
[The Hitchhiker’s Guide to Redshift — part 1: With great power come performance issues](https://blog.atomdata.io/the-hitchhikers-guide-to-redshift-part-1-with-great-power-comes-performance-issues-748d293e0b18) |
## IaC
Name | Comments
:------|:------:
[terraformer](https://github.com/GoogleCloudPlatform/terraformer) | "A CLI tool that generates tf/json and tfstate files based on existing infrastructure (reverse Terraform)."
[terraforming](https://github.com/dtan4/terraforming) | "Export existing AWS resources to Terraform style (tf, tfstate)"
## Videos
Name | Comments
:------|:------:
[Amazon Redshift Tutorial](https://www.youtube.com/watch?v=fc5WPKnbam8) | Edureka, 2018
## Certificates
Name | Comments
:------|:------:
[DevOpsBit Cloud Practitioner Summary](http://devopsbit.com/aws-cloud-practitioner) | 2020
## Interview Questions
Name | Description
:------|:------:
[devops-interview-questions repository](https://github.com/bregman-arie/devops-interview-questions/#aws) | Over 100 questions
[AWS interview questions and answers](https://www.besanttechnologies.com/aws-interview-questions-and-answers) | 250 AWS interview questions
### Best Practices
#### IAM
* Set up MFA
* Delete root account access keys
* Create IAM users instead of using root for daily management
### Cheat Sheet
### IAM
* List users: `aws iam list-users`
### EC2
* List instances: `aws ec2 describe-instances`
* Remove security group rules:
```
aws ec2 revoke-security-group-ingress \
--group-name someHTTPSecurityGroup
--protocol tcp \
--port 80 \
--cidr 0.0.0.0/0`
```
* Add security group rules:
```
aws ec2 authorize-security-group-ingress \
--group-name someHTTPSecurityGroup
--protocol tcp \
--port 80 \
--cidr 0.0.0.0/0
```
### RDS
* Encryption in PostgreSQL: `rds.force_ssl=1 (parameter groups)`
* Encryption in MySQL: `GRANT USAGE ON *.* TO 'mysqluser'@'%' REQUIRE SSL;`
================================================
FILE: resources/azure.md
================================================
# Azure
## IaC
Name | Comments
:------|:------:
[terraformer](https://github.com/GoogleCloudPlatform/terraformer) | "A CLI tool that generates tf/json and tfstate files based on existing infrastructure (reverse Terraform)."
================================================
FILE: resources/bash.md
================================================
# Bash
## Resources
Name | Description
:------ |:--------:
[Bash Wiki Hackers](http://wiki.bash-hackers.org/start) | "hold documentation of any kind about GNU Bash"
[Bash Reference Manual](https://tiswww.case.edu/php/chet/bash/bashref.html) | everything there is to know about bash
[Hacker Rank Linux Shell](https://www.hackerrank.com/domains/shell) | Bash Challenges
[ExplainShell](https://explainshell.com) | Provides explanation on commands
## Best Practices
Some best practices for you to learn and use in your scripts
### 1. Exit script when a certain command fails
When a script written in Bash fails to run a certain command it will keep
running and will execute all other commands mentioned after the command which failed.
Most of the time we would actually want the opposite to happen.
In order to make Bash exit when a specific command fails, use 'set -e' in your script.
```
#!/usr/bin/env bash
set -e
ls /usr/lib/cowabunga
date # It will never run this (unless you have /usr/lib/cowabunga on your system for some reason...)
```
### 2. Allow some commands to fail
Not every failure is a good reason to exit a script.
You will probably want to allows some commands to fail and keep running
To achieve that simple append '|| true' to your command
```
#!/usr/bin/env bash
set -e
dance || true
ls /tmp # This command will run even if `dance` failed
```
### 3. Get used to using curly braces {}
It's a good habit to use curly braces when
referring to variables. Let's see few examples.
`echo \${foo}bar` if not used you would expand \$foobar
`echo ${10}` to expand any positional parameter beyond you'll have to use {}
`echo ${A[0]}` to expand array elements
There are additional advantages covered in next sections.
### 4. Undeclared Variables
The following one-line "script" will work just fine
```
ls ${x}
```
It's reasonable to think that whoever wrote this amazing script
wanted x to be defined somewhere and either forgot to do it or the
user didn't follow the instructions.
In order to avoid strange failures with your script you would
want to execute 'set -u' in order to make sure variable are not
undefined
```
#!/usr/bin/env bash
set -u
ls ${x}
```
Now the script will return error trying to use undefined x variable.
### 5. Use ':-' for allowing undeclared variables
Sometimes you would want to allow variables to be undeclared.
In that case use this syntax to do so: '\${X:-}'.
You can also set default value if variable is undeclared
like this: '\${X:-mario}'
```
#!/usr/bin/env bash
echo "Nothing more than emptiness ${X:-}"
echo "But here, there is ${X:-something}"
X='anymore'
echo "It doesn't feel empty ${X:-}"
```
## Things you should never do
### 1. Don't use backticks (``) for running commands
backticks were (and still are) used for executing a command and using its
output as a command as well. For some reason people are still using backticks
in scripts although they are deprecated long time ago and were replaced
by \$(...) which was introduced by ksh for the first time and now part of
POSIX standardization.
```
x=`date` -> No!
x=$(date) -> Yes :D
```
## Cheat Sheet
#### Variables
* Set variable with default value (string): `x=${x:-'some_default'}`
* Set variable with default value (variable): `y=${y:-$z}`
* return value of a program: `$?`
* Check if variable is empty: `if [ -z "$var" ]; then`
* Variable length: `${#string}`
#### Arguments
* Read input: `read -p "enter a number: " num`
* Number of arguments: `$#`
* Check if an argument was passed
```
if [ "$#" -lt 1 ]; then
echo "Illegal number of parameters"
fi
```
* Check if two arguments were passed
```
if [ "$#" -ne 2 ]; then
echo 'Please pass two arguments'
exit 1
fi
```
* Check if two arguments were passed and both are numbers
```
re='^[0-9]+$'
if ! [[ $1 =~ $re && $2 =~ $re ]]; then
echo "Oh no...I need two numbers"
exit 2
fi
```
* Check if arguments' strings length is equal
```
if [ ${#1} -ne ${#2} ]; then
echo 'Not equal`
exit 1
fi
```
#### Files
* check if file exists
```
FILE=/some/file
if [ -f "$FILE" ]; then
echo "$FILE exists"
fi
```
* check if directory exists
```
DIR=/some/dir
if [ -d "$DIR"]; then
echo "$DIR" exists"
fi
```
#### Loops
* Iterate over a string: `for i in $(seq 1 ${#1}); do`
#### Arithmetic Operations
* print the sum of two numbers: `echo $((20+17))`
* Check factor: `if [ $(($1 % 3)) -eq 0 ]; then`
#### Extract Patterns
* Extract date with sed: `echo $line | sed 's/.*\[//g;s/].*//g;s/:.*//g'`
* Extract first field (space separator) with awk: `echo $line | awk '{print $1}'`
#### Dictionary / Hash Table
* Define a dictionary: `declare -A somedict`
* Print one value based on given key: `echo ${somedict[some_key]}`
* Print all the keys of a dictionary: `echo ${!somedict[*]}`
* Check if key exists: `if [[ -v some_dict[$day] ]]; then`
* Update dict based values and generate top 10:
```
function update_dict() {
declare -A some_dict
while read line; do
day=$line
if [[ -v some_dict[$day] ]]; then
some_dict[$day]=$((some_dict[$day]+1))
else
some_dict[$day]=1
fi
done < $FILE
for day in ${!some_dict[@]}; do echo ${some_dict[$day]} $day; done | sort -rn | head -10
}
```
#### Common algorithms
* Hamming distance
```
distance=0
for i in $(seq 1 ${#1}); do
if [ ${1:$i-1:1} != ${2:$i-1:1} ]; then
distance=$((distance+1))
fi
done
echo $distance
```
#### Text Manipulation
* Take the first letter of every word in a line: `echo $line | sed 's/\(.\)[^ ]* */\1/g'`
================================================
FILE: resources/chaos_engineering.md
================================================
# Chaos Engineering
## Platforms and Services
* https://www.gremlin.com
## Resources
* Diagram for tracking Chaos Engineering state: http://coggle.it/diagram/WiKceGDAwgABrmyv/0a2d4968c94723e48e1256e67df51d0f4217027143924b23517832f53c536e62
================================================
FILE: resources/cicd.md
================================================
## CI/CD
### Best Practices
* Commit and test often.
* Testing/Staging environment should be a clone of production environment.
* Clean up your environments (e.g. your CI/CD pipelines may create a lot of resources. They should also take care of cleaning up everything they create)
* The CI/CD pipelines should provide the same results when executed locally or remotely
* Treat CI/CD as another application in your organization. Not as a glue code.
* On demand environments instead of pre-allocated resources for CI/CD purposes
* Stages/Steps/Tasks of pipelines should be shared between applications or microservices (don't re-invent common tasks like "cloning a project")
* The CI/CD pipelines should have short execution time in order to provide a short feedback loop
================================================
FILE: resources/coding.md
================================================
## Videos
Name | Comments
:------|:------:
[SOLID design principles](https://www.youtube.com/watch?v=rtmFCcjEgEw) | by Katerina Trajchevska, 2019
================================================
FILE: resources/containers.md
================================================
## Containers
### Articles
Name | Comments
:------ |:--------:
[Docker CheatSheet](https://cheatsheet.dennyzhang.com/cheatsheet-docker-a4) |
[Everything you need to know about containers](https://medium.com/faun/everything-you-need-to-know-about-containers-7655badb4307) |
[A container networking overview](https://jvns.ca/blog/2016/12/22/container-networking) |
[My Docker Cheat Sheet](https://medium.com/statuscode/dockercheatsheet-9730ce03630d) |
[Docker Networking Deep Dive](http://100daysofdevops.com/21-days-of-docker-day-19-docker-networking-deep-dive/?fbclid=IwAR19KJWwhZjulbn7JNbBYLFxKFf-x0v25TSc-_bOJ6YieUND4A6UZcBSUhA) |
### Projects
Name | Comments
:------ |:--------:
[container-diff](https://github.com/GoogleContainerTools/container-diff) | "container-diff is a tool for analyzing and comparing container images"
[awesome-docker](https://github.com/veggiemonk/awesome-docker) |
### Books
Name | Comments
:------ |:--------:
Docker Deep Dive |
### Tools
Name | Description
:------|:------:
[dive](https://github.com/wagoodman/dive) | "A tool for exploring a docker image, layer content, ..."
[trivy](https://github.com/aquasecurity/trivy) | "A Simple and Comprehensive Vulnerability Scanner for Containers and other Artifacts, Suitable for CI."
### Production Best Practices
* Secured communication between daemon and clients using TLS
### Best Practices
#### Dockerfile Best Practcies
* Include only the packages you are going to use. Nothing else.
* Specify a tag in FROM instruction. Not using a tag means you'll always pull the latest, which changes over time and might result in unexpected result.
* Do not use environment variables to share secrets
* Use images from official repositories
* Keep images small! - you want them only to include what is required for the application to run successfully. Nothing else.
* If are using the apt package manager, you might use 'no-install-recommends' with `apt-get install` to install only main dependencies (instead of suggested, recommended packages)
#### Security Best Practcies
* Install only the necessary packages in the container
* Don't run containers as root when possible
* Don't mount the Docker daemon unix socket into any of the containers
* Set volumes and container's filesystem to read only
* DO NOT run containers with `--privilged` flag
### Cheatsheet
* Stop and remove all containers: `podman container stop $(docker container ls -aq)`
* Run container with bash shell: `podman run -ti ubuntu:latest /bin/bash`
* Check how many containers are running: `podman info`
* Cleanup everything: `podman system prune -a -f`
#### Images
* List images: `podman image ls`
* Pull latest ubuntu image: `podman image pull ubuntu:latest`
* Remove image from the host: `podman rmi IMAGE`
* Remove all images: `podman rmi -a` or the more extreme version of it: `podman rmi $(podman images -qa) -f`
* Login to Red Hat registry: `podman login registry.redhat.io`
* List all available tags for a given image using the CLI: `podman search --list-tags IMAGE_NAME`
* List all available tags for a given image using an API request: `curl -Ls https://SERVER/v2/.../tags/list | python -m json.tool`
* Create an archive from the image: `podman save -o some_image.tar IMAGE`
* Load image from the archive: `podman load -i some_image.tar`
* List added/modified/deleted files on container's image filesystem: `podman diff IMAGE_NAME`
* List of mounted files for a running container: `podman inspect -f "{{range .Mounts}}{{println .Destination}}{{end}}" CONTAINER_NAME/ID`
* Commit changes to another image: `podman commit EXISTING_IMAGE NEW_IMAGE`
#### Registries
* List all repositories in a registry: `curl -Ls https://SERVER/v2/_catalog?n=`
* List all repositories in a registry and convert to JSON: `curl -Ls https://SERVER/v2/_catalog?n=3 > | python -m json.tool`
#### Security
* Secure communication between client and server:
```
# On CA node
openssl genrsa -aes256 -out ca-k.pem 4096
openssl req -new -x509 -days 730 -key ca-k.pem -sha256 -out ca.pem
openssl genrsa -out daemon-key.pem 4096
openssl req -subj "/CN=daemon.host.address" -sha256 -new -key daemon-key.pem -out daemon.csr
cat << EOF >> file.conf
subjectAltName = DNS:daemon.host.address,IP:X.X.X.X
extendedKeyUsage = serverAuth
EOF
openssl x509 -req -days 730 -sha256 -in daemon.csr -CA ca.pem -CAkey ca-k.pem -CAcreateserial -out daemon-cert.pem -extfile file.conf
openssl genrsa -out client-key.pem 4096
openssl req -subj '/CN=client.address' -new -key client-key.pem -out client.csr
echo "extendedKeyUsage = clientAuth" > file.conf
openssl x509 -req -days 730 -sha256 -in client.csr -CA ca.pem -CAkey ca-k.pem -CAcreateserial -out client-cert.pem -extfile file.conf
chmod 0400 ca-k.pem client-key.pem daemon-key.pem && chmod -v 0444 ca.pem client-cert.pem daemon-cert.pem
# On daemon host put the keys ca.pem, daemon-cert.pem and daemon-key.pem in ~/.docker
# On client host put the keys ca.pem, client-cert.pem and client-key.pem in ~/.docker
```
* Enable TLS
```
# Put it in /etc/docker/daemon.json
{
"hosts": ["tcp://node3:2376"],
"tls": true,
"tlsverify": true,
"tlscacert": "/home/ubuntu/.docker/ca.pem",
"tlscert": "/home/ubuntu/.docker/cert.pem",
"tlskey": "/home/ubuntu/.docker/key.pem"
}
```
#### Cleanup
* Remove everything: `podman system reset`
================================================
FILE: resources/dataops.md
================================================
# DataOps
## Videos
Year | Video
:------ |:------:
2020 | [DataOps: Why is it so hard?](https://youtu.be/XZ7KhOPCiKU?t=956)
================================================
FILE: resources/docker.md
================================================
## Docker
### Learn
Name | Comments
:------ |:--------:
[Play with Docker](https://labs.play-with-docker.com) | "A simple, interactive and fun playground to learn Docker"
### Articles
Name | Comments
:------ |:--------:
[Docker CheatSheet](https://cheatsheet.dennyzhang.com/cheatsheet-docker-a4) |
[Everything you need to know about containers](https://medium.com/faun/everything-you-need-to-know-about-containers-7655badb4307) |
[A container networking overview](https://jvns.ca/blog/2016/12/22/container-networking) |
[My Docker Cheat Sheet](https://medium.com/statuscode/dockercheatsheet-9730ce03630d) |
[Docker Networking Deep Dive](http://100daysofdevops.com/21-days-of-docker-day-19-docker-networking-deep-dive/?fbclid=IwAR19KJWwhZjulbn7JNbBYLFxKFf-x0v25TSc-_bOJ6YieUND4A6UZcBSUhA) |
### Projects
Name | Comments
:------ |:--------:
[awesome-docker](https://github.com/veggiemonk/awesome-docker) |
### Cheatsheet
* Stop and remove all containers: `docker container stop $(docker container ls -aq)`
* Check how many containers are running: `docker info`
* Check the docker images on your system: `docker images`
* Cleanup everything: `docker system prune -a -f`
#### Managing Containers
* Launch a container and attach to it: `docker container run -it ubuntu:latest /bin/bash`
* Run a command in the container: `docker exec -it `
* Attaching to running container: `docker container exec -it bash`
* List running containers: `docker container ls`
* List all containers (including stopped): `docker container ls -a`
* List containers (including stopped): `docker container ls -a`
* Stop a container: `docker container stop `
* Remove a container: `docker container rm `
* Remove all containers: `docker container rm $(docker container ls -aq) -f`
* Create, start, run command and destroy the container: `docker run --rm -it `
#### Images
* List images: `docker image ls`
* Pull image: `docker image pull :`
* List only images tagged as "latest": `docker image ls --filter=reference="*:latest"`
* List dangling images: `docker image ls --filter dangling=true`
* Which default registry is used: `docker info`
* List supported image architectures: `docker manifest inspect golang | grep 'architecture\|os'`
* Search all repositories that contain the string 'yay': `docker search yay`
* Search only for official repositories: `docker search --filter "is-official=true"`
* Build an image: `docker image build -t : .`
* List images with the following data: name, tag and size: `docker image ls --format "{{.Repository}}: {{.Tag}}: {{.Size}}"`
* List images with their digests: `docker image ls --digests`
* Specify architecture when building an image: `docker buildx build --platform linux/arm/v1985 -t some_image:arm-v1985 .`
* Delete an image: `docker image rm :`
* Remove all images: `docker image rm $(docker image ls -q) -f`
* Tag an image: `docker tag : /:`
* Push an image: `docker push /:`
* Save a running container as an image: `docker commit -m "some commit message" -a "author name/username" /:`
#### Logs
* Print the last 100 lines from container's logs: `docker container logs --tail 100 `
* Follow container logs: `docker logs -ft `
#### Network
* List networks: `docker network ls`
#### Compose
* Deploy compose app: `docker-compose up`
* Stop and delete a running Compose app: `docker-compose down`
* Restart a Compose app: `docker-compose restart`
* List each container in the Compose app: `docker-compose ps`
* Stop all of the container in Compose app: `docker-compose stop`
* Delete a stopped Compose app: `docker-compose rm`
### Common Failures
#### Unable to start the Docker service
Error:
` Failed to start Docker Application Container Engine.`
Fix:
```
sudo firewall-cmd --permanent --zone=docker --change-interface=docker0
sudo firewall-cmd --reload
```
================================================
FILE: resources/elk.md
================================================
## ELK articles
Name | Comments
:------|:------:
[logz.io - complete-guide-elk-stack](https://logz.io/learn/complete-guide-elk-stack) | name says it all
## Logstash articles
Name | Comments
:------|:------:
[Logstash Grok Guide](https://logz.io/blog/logstash-grok) | Learn Grok, It's important to know
## Data Sets & Patterns
Name | Comments
:------|:------:
[Kaggle](https://www.kaggle.com) | Free Data Sets
[Logstash Patterns](https://github.com/logstash-plugins/logstash-patterns-core/tree/master/patterns) | Logstash Patterns Code
[Grok Patterns](https://github.com/logstash-plugins/logstash-patterns-core/blob/master/patterns/grok-patterns) | Logstash Patterns Code
[RE used by Grok](https://github.com/kkos/oniguruma/blob/master/doc/RE) |
## Elasticsearch Tools
Name | Comments
:------|:------:
[elasticsearch-dump](https://github.com/taskrabbit/elasticsearch-dump) | Import and export tools for elasticsearch
## Logstash Tools
Name | Comments
:------|:------:
[GrokDebug](https://grokdebug.herokuapp.com) | Test Grok Patterns
## Kibana Tools
Name | Comments
:------|:------:
[Rubban](https://github.com/sherifabdlnaby/rubban) | "Kibana Automatic Index Pattern Discovery and Other Curating Tasks"
## Elsaticsearch Cheat Sheet
* Test elasticsearch: `curl :9200`
* List of APIs: `curl :9200/_cat`
* List nodes: `curl :9200/_cat/nodes`
* List nodes with headers: `curl :9200/_cat/nodes?v`
* Check elasticsearch health (also good for checking number of nodes): `curl -X GET "localhost:9200/_cat/health?v"`
* List indexes: `curl 'localhost:9200/_cat/indices?v'`
* Create a new index called "customers" and add a document with the field name
```
curl -X PUT "localhost:9200/gamer/_doc/1?pretty" -H 'Content-Type: application/json' -d'
{
"name": "John Doe"
}
'
```
* Add documents from a JSON file: `curl -H "Content-Type: application/json" -XPOST "localhost:9200/customer/_bulk?pretty&refresh" --data-binary "@customers.json"`
* Get the document with ID 1: `curl -X GET "localhost:9200/gamer/_doc/1"`
* List all indices: `curl "localhost:9200/_cat/indices?v"`
* Increase fields limit
```
PUT test_index/_settings
{
"index.mapping.total_fields.limit": 2000
}
```
* Delete index from console UI: `DELETE /`
* Delete all indexes from CLI: `curl -X DELETE 'http://:9200/_all` # Don't run this! it will delete also the Kibana index and you'll not have default space available
* Create cluster
```
# On the master node
dnf install -y elasticsearch
systemctl enable elasticsearch
vi /etc/elasticsearch/elasticsearch.yml
set cluster.name
set node.name
set network.host to [_local_, _site_]
set discovery.seed_hosts to master private IP address (or addresses if you are using multiple nodes)
set cluster.inital_master_nodes to master node name(s)
set node.master to true
set node.data to false
set node.ingest to true
set node.ml to false
# On second node (and any additional node)
set cluster.name
set node.name
set network.host to [_local_, _site_]
set discovery.seed_hosts to master private IP address (or addresses if you are using multiple nodes)
set cluster.inital_master_nodes to master node name(s)
set node.master to false
set node.master to true
set node.ingest to false
set node.ml to false
# On all nodes
systemctl start elasticsearch
```
## Logstash Cheat Sheet
* input - filebeat
```
input {
beats {
port => 5044
}
}
```
* Check if Logstash receiving logs from filebeat:
```
tcpdump -Xni eth0 port 5140
```
* Load Parquet files
```
Use https://github.com/Parquet/parquet-compatibility/blob/master/parquet-compat/src/test/java/parquet/compat/test/ConvertUtils.java
Specifically https://github.com/Parquet/parquet-compatibility/blob/master/parquet-compat/src/test/java/parquet/compat/test/ConvertUtils.java#L111
Once it's convreted to CSV, you process it with
input {
file {
path => "/path/to/your/parquet/as/csv/file"
}
}
filter {
csv {
columns => ["col1", "col2"]
}
}
```
## Kibana Cheat Sheet
* Unlock Indexes (in case of forbbiden error)
```
PUT .kibana/_settings
{
"index": {
"blocks": {
"read_only_allow_delete": false
}
}
}
```
* Unlock specific index
```
PUT your_index_name/_settings
{
"index": {
"blocks": {
"read_only_allow_delete": "false"
}
}
}
```
================================================
FILE: resources/gcp.md
================================================
# GCP
## IaC
Name | Comments
:------|:------:
[terraformer](https://github.com/GoogleCloudPlatform/terraformer) | "A CLI tool that generates tf/json and tfstate files based on existing infrastructure (reverse Terraform)."
[validkube](https://validkube.com/) | "A tool that to verify and validate your yml file."
[validiac](https://www.validiac.com/) | "A tool that to verify and validate your terraform file."
================================================
FILE: resources/git.md
================================================
# Git
## Learn Git
Name | Comments
:------|:------:
[git-scm](https://git-scm.com) | The best place (imho) to learn everything about Git (through reading)
[Interactive Git Branching Learning](https://learngitbranching.js.org/) | Visual and interactive way to learn Git branching
[Learn git concepts, not commands](https://dev.to/unseenwizzard/learn-git-concepts-not-commands-4gjc) | Article on Git concepts
[Codeacademy Learn Git](https://www.codecademy.com/learn/learn-git) | Not Free
[Git for Computer Scientists](https://eagain.net/articles/git-for-computer-scientists/) |
[shortcutfoo](https://www.shortcutfoo.com/app/dojos/git) | interactive learning
## Best Practices
* Use a descriptive commit message
* Make each commit a logical unit
* Incorporate others' changes frequently
* Share your changes frequently
* Coordinate with your co-workers
* Don't commit generated files
## CheatSheet
* Clone a repository: `git clone https://github.com/bregman-arie/devops-resources.git`
* Pull changes from remote repository: `git pull`
* Pull changes without trying to merge the changes between the local branch and the remote one: `git pull --ff-only`
### Branches
* Switch to a branch called "main": `git checkout main`
* Create (if doesn't exists) and switch to a branch called `devel`: `git checkout -b devel`
* List branches: `git branch`
* Update based on status of remote branches: `git remote prune origin`
* Delete local branch: `git branch -d some-branch`
* What are the changes if merging branch y into x: `git merge-tree $(git merge-base x y) x y`
### Staging
* See what the current status in the repository: `git status`
* Add changes to the staging area: `git add ` or `git add .` to add everything
### Commits
* Create a commit: `git commit`
* List of latest commits: `git log --oneline`
* Push commits to the remote branch: `git push origin main`
* Revert to commit X
```
git revert --no-commit X..HEAD
git commit
```
### References
* All references in current repository: `find .git/refs/`
* Update master reference: `git update-ref refs/heads/master `
### Tags
* Create a new tag: `git tag -a "v0.0.1" -m "First release...yay`
================================================
FILE: resources/github.md
================================================
# GitHub
## Common Issues
* 'can't sync because main is not tracking [PROJECT NAME]'
This happens the branch is no longer tracking main from upstream. Can be fixed with this command: `git push --set-upstream origin main`.
## Cheat Sheet
### Repository
* Clone repository: `gh clone `
* Sync your fork from source repo: `gh repo sync --source /`
### Pull Requests
* Create PR: `gh pr create --title "Some Pull Request ;)`
* List PRs: `gh pr list`
* Change to PR (aka checkout): `gh pr checkout `
* Update PR: `git push`
### CI
* List builds/workflow runs: `gh run list`
### Rebase
* Rebase current branch commits on top of latest changes in main branch: `git rebase origin/main`
================================================
FILE: resources/gitops.md
================================================
https://opengitops.dev
================================================
FILE: resources/go.md
================================================
## Go
### Cheat Sheet
* Run your program:
```
go run
```
* Compile your app package:
```
go build
```
* Install and run from a remote location:
```
go install github.com/bregman-arie/myApp
bin/myApp
```
* var definition
```
var i int = 42
OR
i := 42
```
* Define several variables
```
var (
name string = "hello"
num int = 42
```
================================================
FILE: resources/groovy.md
================================================
### Cheat Sheet
* Type of a variable
`println obj.getClass()`
================================================
FILE: resources/jenkins/README.md
================================================
# Jenkins
## Documentation
Title | Author | Comments
:------ |:------|:------:
[Official Jenkins Doc](https://jenkins.io/user-handbook.pdf) | jenkinsci-docs | |
[Job DSL Plugin](https://jenkinsci.github.io/job-dsl-plugin) | jenkinsci | |
## Tutorials & Articles
Title | Author | Comments
:------ |:------|:------:
[Jenkins Tutorial For Beginners](https://devopscube.com/jenkins-2-tutorials-getting-started-guide) | Focusing on installing and configuring Jenkins
[Top 10 Best Practices for Jenkins Pipeline Plugin](https://www.cloudbees.com/blog/top-10-best-practices-jenkins-pipeline-plugin) | apemberton | |
[The Need For Jenkins Pipeline](https://www.cloudbees.com/blog/need-jenkins-pipeline) | Viktor Farcic | Great article. Recommended.
[Jenkins Pipeline](https://www.cloudbees.com/blog/jenkins-pipeline) | Viktor Farcic | Another great article from Victor.
## Scripts
Repository | Comments
:------ |:------:
[pipeline-examples](https://github.com/jenkinsci/pipeline-examples) | The [HTML](https://jenkins.io/doc/pipeline/examples) version |
[This Repository](https://github.com/bregman-arie/jenkins-goodies/tree/master/scripts) | |
## Presentations
Title | Author | Comments
:------ |:------|:------:
[Jenkins API](https://www.slideshare.net/ArieBregman/jenkins-api) | Arie Bregman | |
## Blogs
Name | Comments
:------ |:------:
[Cloudbees Blog](https://www.cloudbees.com/blog) | |
[Jenkins Community Blog](https://jenkins.io/node/) | |
## Videos
Name | Comments
:------ |:------:
[Multi Branch Pipeline](https://www.youtube.com/watch?v=11z2x3VYO_I&t=) | For projects with multiple branches |
[How to create Jenkins Pipeline with an Example](https://www.youtube.com/watch?v=s73nhwYBtzE) | Great for beginners |
[Codifying the Build and Release Process with a Jenkins Pipeline Shared Library](https://www.youtube.com/watch?v=lzzx59kLW9w) |
## Checklist
- [ ] **Terms & Entities**
- [ ] Job
- [ ] Build
- [ ] Plugin
- [ ] Slave
- [ ] **Job**
- [ ] Freestyle
- [ ] Pipeline
- [ ] Declarative
- [ ] Scripted
- [ ] Checkpoint (cloudbees only at this point)
- [ ] **Slave**
- [ ] Agent
- [ ] Executor
- [ ] Label
### Cheat Sheet
* Set build result to FAILURE/SUCCESS/UNSTABLE: `currentBuild.result = 'FAILURE'`
================================================
FILE: resources/jenkins/jjb/gate.md
================================================
The following is the job definition of a gate to test changes to job definitions
- job:
name: 'gate-jenkins-jjb'
defaults: job_defaults
concurrent: true
parameters:
- string: { name: GERRIT_REFSPEC, default: +refs/heads/master }
- string: { name: GERRIT_BRANCH, default: origin/master }
- string: { name: DEBUG, default: '' }
description: |
Managed by Jenkins Job Builder. Do not edit via web.
Gate against changes to job definitions
node:
properties:
- build-discarder:
days-to-keep: 14
artifact-days-to-keep: 14
scm:
- codeng-scm:
project: '
branch: "master"
refspec: "$GERRIT_REFSPEC"
triggers:
- trigger-rhos-qe-jenkins:
file_paths:
- compare-type: 'REG_EXP'
pattern: '(jobs/.*|bin/.*|requirements\.txt)'
builders:
- shell: |
#!/bin/bash
set -euo pipefail
IFS=$'\n\t'
[ "${DEBUG:-0}" != 0 ] && set -x
PIP_LOG=$WORKSPACE/pip.log
tox -e jobs
publishers:
- archive:
artifacts: '**/*.log'
Also, add this in tox.ini:
[testenv:jobs]
commands =
{[testenv]commands}
mkdir -p out-xml
bash -c "XDG_CACHE_HOME={toxworkdir}/.jjb_cache jenkins-jobs --ignore-cache test --config-xml -o out-xml --recursive jobs 2>{envname}.log || \{ >&2 cat {envname}.log; exit 1; \}"
================================================
FILE: resources/jenkins/pipeline/README.md
================================================
## Pipeline in a nutshell
* A moment of history: Pipeline plugin was developed after the success
of Build Flow Plugin and it was first called 'Workflow Plugin'.
* It's considered to be better than freestyle type because it's implemented
in code, survives restarts and can be extended easily.
* Pipeline supports two syntaxes, Declarative and Scripted.
* [Here](https://github.com/bregman-arie/jenkins-goodies/blob/master/pipeline/basic_declarative_pipeline) is an example for simple declarative pipeline
* 'step' is a single task and tells Jenkins what to do.
* 'stage' is a collection of steps. Example for stages: 'Test', 'Build', 'Deploy'.
* 'node' allocates an executor and workspace for executing the steps in all the stages
* To use Jenkins pipeline, you need Jenkins 2 and Pipeline plugin installed.
* Scripted pipeline is written in Groovy.
* You can create a new pipeline by using Jenkins UI or adding a Jenkinsfile in the relevant repository. Using Jenkinsfile is recommended.
* To declare pipeline with UI -> click on 'new item', enter the name, choose 'Pipeline' from type options and click on 'save'.
* You can use https:///pipeline-syntax as built-in documentation for generating simple or complex
pipeline snippets.
* There are several types of variables supported in a pipeline. You can find updated reference on global variables
here: https:///pipeline-syntax/globals
* env variables are accessible from Groovy code with 'env.'.
* params are read-only variables exposed for you to use in the pipeline.
* currentBuild variables are set in the context of a specific build
* A reference of the available steps can be found [here](https://jenkins.io/doc/pipeline/steps).
There is also such reference in your Jenkins instance https:///pipeline-syntax/html
* Pipeline examples can be found [here](https://jenkins.io/doc/pipeline/examples)
================================================
FILE: resources/jenkins/pipeline/basic_declarative_pipeline
================================================
// Best practice is to actually call this file 'Jenkinsfile'
// I named it 'basic_pipeline' just to explain its purpose
// Pipeline is written in Pipeline DSL syntax
pipeline {
// Jenkins to allocate workspace and executor
agent any
// Stages are block of code you execute through your build
stages {
// This is the first stage the pipeline will execute
// A stage execute specific step of your flow
stage('Build') {
// Steps to be executed as part of the 'Build' stage
steps {
sh 'echo "Building"' // Execute the 'echo' shell command
}
}
// Once previous stage finished successfully, Jenkins will
// execute this stage.
stage('Test'){
steps {
sh 'echo "Testing"'
// To publish test results add this: junit 'reports/**/*.xml'
}
}
stage('Deploy') {
steps {
sh 'echo "Deploying"'
}
}
}
} // End of the pipeline
================================================
FILE: resources/jenkins/pipeline/basic_scripted_pipeline
================================================
#!/usr/bin/env groovy
================================================
FILE: resources/jenkins/pipeline/tips.md
================================================
# Pipeline - Tips
* Use https:///pipeline-syntax as built-in documentation for generating simple or complex
pipeline snippets.
* Use https:///pipeline-syntax/globals to find out what variables you can use in your pipeline.
* A reference of the available steps can be found [here](https://jenkins.io/doc/pipeline/steps).
There is also such reference in your Jenkins instance https:///pipeline-syntax/html
* Learn from [examples](https://jenkins.io/doc/pipeline/examples)
================================================
FILE: resources/jenkins/scripts/README.md
================================================
## How to run
There are several ways to run the snippets in this repository. The quickest would be:
1. Go to https:///script
2. Paste the script
3. Click on "Run"
4. Enjoy :)
================================================
FILE: resources/jenkins/scripts/builds/abort.groovy
================================================
Jenkins.instance.getItemByFullName("").getBuildByNumber().finish(hudson.model.Result.ABORTED, new java.io.IOException("Aborting build"));
================================================
FILE: resources/jenkins/scripts/builds/remove_old.groovy
================================================
// Remove old builds that are older than the number of given days
def removeOldBuilds(buildDirectory, days = 14) {
def wp = new File("${buildDirectory}")
def currentTime = new Date()
def backTime = currentTime - days
wp.list().each { fileName ->
folder = new File("${buildDirectory}/${fileName}")
if (folder.isDirectory()) {
def timeStamp = new Date(folder.lastModified())
if (timeStamp.before(backTime)) {
folder.delete()
}
}
}
}
return this;
================================================
FILE: resources/jenkins/scripts/builds/remove_old_v2.groovy
================================================
// Remove builds older than 5 days
builds = Jenkins.instance.getItem('test2').getBuilds()
def daysToKeep = 5
builds.each{ build ->
def runningSince = groovy.time.TimeCategory.minus( new Date(), build.getTime() ).getDays();
if (runningSince > daysToKeep){
build.delete();
println "Build " + build + "was deleted since it was built " + runningSince + " days ago";
}
}
================================================
FILE: resources/jenkins/scripts/jobs/delete_jobs_with_regex.groovy
================================================
def jobs = Jenkins.instance.items.findAll { job -> job.name =~ /the_regex/ }
jobs.each { job ->
println job.name
//job.delete()
}
================================================
FILE: resources/jenkins/scripts/jobs/print_all_jobs.groovy
================================================
jobs = jenkins.model.Jenkins.instance.getJobNames()
println "Number of jobs: " + jobs.size()
println "\nList of jobs:\n" + jobs.join("\n")
/*
Another version:
jobs = jenkins.model.Jenkins.instance.items
println "Number of jobs: " + jobs.size()
println "\nList of jobs:\n"
jobs.each { job -> println job.name }
*/
================================================
FILE: resources/jenkins/scripts/jobs/print_jobs_with_regex.groovy
================================================
jobs = jenkins.model.Jenkins.instance.items.findAll { job -> job.name =~ /network.*10_((?!SRIOV).)*$/ }
println "Number of jobs: " + jobs.size() + "\n"
jobs.each { job -> println job.name }
================================================
FILE: resources/jenkins/scripts/jobs/rename_job.groovy
================================================
def job = jenkins.model.Jenkins.instance.getItem('dashboard');
def currentName = job.name;
def newName = 'test2';
job.renameTo(newName);
println "\nRenamed " + currentName + " to " + newName;
================================================
FILE: resources/jenkins/scripts/jobs/rename_jobs_with_regex.groovy
================================================
def jobs = Jenkins.instance.items.findAll { job -> job.name =~ /the_regex/ }
def newNameAddition = 'test2'
jobs.each { job ->
currentName = job.name
job.renameTo(job.name + newNameAddition);
println "\nRenamed " + currentName + " to " + currentName + newNameAddition + "\n";
}
================================================
FILE: resources/jenkins/scripts/nodes/check_all_online.groovy
================================================
// Check if all slaves are online. Fail the script if not.
int excode = 0
for (slave in hudson.model.Hudson.instance.slaves) {
if (slave.getComputer().isOffline().toString() == "true"){
println('The Slave ' + slave.name + " is offline");
excode++;
}
}
if (excode > 0) {
println("We have a Slave down! I repeat, we have a slave down!");
return 1;
}
================================================
FILE: resources/jenkins/scripts/nodes/print_node_groups.groovy
================================================
import jenkins.model.Jenkins;
def list = []
def description = ''
def slave_label_map = [:]
for (slave in Jenkins.instance.slaves) {
description = slave.getNodeDescription()
if (description.contains('<#{') && description.contains('}#>')) {
words = slave.getLabelString().split()
def labelListForSlave = []
words.each() {
labelListForSlave.add(it);
list.add(it)
}
slave_label_map.put(slave.name, labelListForSlave)
}
}
list.unique()
================================================
FILE: resources/jenkins/scripts/notification/notifier/__init__.py
================================================
# Copyright 2018 Arie Bregman
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
================================================
FILE: resources/jenkins/scripts/notification/notifier/main.py
================================================
# Copyright 2018 Arie Bregman
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
import json
import requests
import sys
from notifier import parse
message = 'Build {}'.format('FAILED')
headers = {
'Content-Type': 'application/json',
}
payload = {
'message': message,
}
endpoint = ''
def main():
"""Main entry point."""
# Parse given arguments
parser = parse.create_parser()
args = parser.parse_args()
r = requests.post(endpoint,
data=json.dumps(payload + args),
headers=headers)
print(r.status)
if __name__ == '__main__':
sys.exit(main())
================================================
FILE: resources/jenkins/scripts/notification/notifier/parse.py
================================================
# Copyright 2018 Arie Bregman
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
import argparse
def create_parser():
"""Returns argument parser"""
parser = argparse.ArgumentParser(add_help=True)
parser.add_argument('--debug', '-d', action='store_true',
dest="debug", help='Turn on debug')
parser.add_argument('--yaml-file', '-y', dest='yaml_f', nargs='+',
help='YAML files')
return parser
================================================
FILE: resources/jenkins/scripts/plugins/list_all_plugins.groovy
================================================
Jenkins.instance.pluginManager.plugins.sort { it.getShortName() }.each{ plugin -> println "${plugin.getShortName()}:${plugin.getVersion()}" }
================================================
FILE: resources/jenkins/scripts/tests/count_test_failures.groovy
================================================
import jenkins.*
import jenkins.model.*
import hudson.*
import hudson.model.*
def jobNameStartsWith = 'DFG-network-neutron'
def textToMatch = "Traceback"
Jenkins.instance.items.findAll { it.displayName.startsWith(jobNameStartsWith) }
.each { job ->
if(job.builds) {
def build = job.isBuilding() ? job.builds[1] : job.builds[0]
def log = build.logFile.text
def regexPattern = "(?i).*${textToMatch}.*"
def summary = log =~ /${regexPattern}/
println "${summary.size()}: $job.displayName"
}
}
return ""
================================================
FILE: resources/jinja2.md
================================================
### CheatSheet
* Split string to list of items using comma as the separator: `{% set list1 = variable1.split(',') %}`
================================================
FILE: resources/kubernetes.md
================================================
## Kubernetes
### Getting started with Kubernetes
Name | Comments
:------ |:--------:
[kubernetes.io](https://kubernetes.io) | Official Kubernetes site by Google
[Kubernetes 101](https://medium.com/google-cloud/kubernetes-101-pods-nodes-containers-and-clusters-c1509e409e16) | Great beginner article on Kubernetes fundamental concepts
[Kubernetes Tutorial for Beginners](https://www.youtube.com/watch?v=X48VuDVv0do&ab_channel=TechWorldwithNana) | Full video of 4 hours on Kubernetes (2020)
[Learning Path: Kubernetes](https://developer.ibm.com/series/kubernetes-learning-path/) | From basic to advanced Kubernetes learning series
[Kubernetes 101 - Concepts and Why It Matters](https://www.magalix.com/blog/kubernetes-101-concepts-and-why-it-matters?fbclid=IwAR10FZlZ9Pw5c94tGRlgsCrVZTa1bSV2mbxEP8p4cXZ5T-k4VXF-3OUKkFo) |
[kubernetes-workshop](https://github.com/eon01/kubernetes-workshop) |
[Kubernetes Deployment Tutorial](https://devopscube.com/kubernetes-deployment-tutorial) |
[Katacoda](https://www.katacoda.com/courses/kubernetes) | Learn Kubernetes using Interactive Browser-Based Scenarios
[Kubernetes Scheduler](https://jvns.ca/blog/2017/07/27/how-does-the-kubernetes-scheduler-work/) | How does the Kubernetes scheduler work?
### Kubernetes - Deep Dive
Name | Comments
:------ |:--------:
[Kubernetes Networking](https://github.com/nleiva/kubernetes-networking-links) | Kubernetes Networking Resources
[Liveness and Readiness Probes](https://www.openshift.com/blog/liveness-and-readiness-probes) |
### Kubernetes - Troubleshooting
Name | Comments
:------ |:--------:
[troubleshoot.sh](https://troubleshoot.sh) | "A kubectl plugin providing diagnostic tools for Kubernetes applications"
[Kubernetes Troubleshooting Visual Guide](https://learnk8s.io/troubleshooting-deployments) |
### Kubernetes - Security
Name | Comments
:------ |:--------:
[Kubescape](https://github.com/armosec/kubescape) | "Kubescape is the first tool for testing if Kubernetes is deployed securely as defined in Kubernetes Hardening Guidance by NSA and CISA"
[Falco](https://falco.org) | "Falco...is the de facto Kubernetes threat detection engine"
### Kubernetes - Misc
Name | Comments
:------ |:--------:
[confTest](https://www.conftest.dev) | "Conftest is a utility to help you write tests against structured configuration data" (Used in the development phase)
[datree](https://www.datree.io) | "Prevent Kubernetes Misconfigurations From Reaching Production" (Used in development phase)
[gatekeeper](https://github.com/open-policy-agent/gatekeeper) | Used in the production
[telepresence](https://www.telepresence.io) | "FAST, LOCAL DEVELOPMENT FOR KUBERNETES AND OPENSHIFT MICROSERVICES"
[Kubernetes CheatSheet](https://cheatsheet.dennyzhang.com/cheatsheet-kubernetes-A4) |
[OperatiorHub.io](https://www.operatorhub.io) | Kubernetes native applications
[YAML templates](https://cheatsheet.dennyzhang.com/kubernetes-yaml-templates) |
[Kubesort](https://github.com/AATHITH/kubesort) | "kubesort helps you sort the results from kubectl get in an easy way"
[IngressMonitorController](https://github.com/stakater/IngressMonitorController) | "A Kubernetes controller to watch ingresses and create liveness alerts for your apps/microservices"
### Kubernetes - SRE
Name | Comments
:------ |:--------:
[KubeInvaders](https://github.com/lucky-sideburn/KubeInvaders) | "Chaos Engineering Tool for Kubernetes and Openshift"
### Kubernetes - Certificates
Name | Comments
:------ |:--------:
[CKAD-Practice-Questions](https://github.com/bbachi/CKAD-Practice-Questions) | "a consolidated list for CKAD practice questions"
[CKAD Prep Exam Video](https://www.youtube.com/watch?v=TPXwVmvzlV4&ab_channel=TheFrontOpsGuy) | A video of doing a CKAD prep exam (2020)
[CKA Complete Prep Exam ](https://github.com/walidshaari/Kubernetes-Certified-Administrator) | CKA prep exam (2021)
[CKAD Complete Prep Exam ](https://github.com/dgkanatsios/CKAD-exercises) | CKAD prep exam (2021)
[CKS Complete Prep Exam ](https://github.com/walidshaari/Certified-Kubernetes-Security-Specialist) | CKA prep exam (2021)
### Kubernetes - Labs
Name | Comments
:------ |:--------:
[Building a Kubernetes 1.23 Cluster with Kubeadm](https://github.com/croguerrero/CKA-Labs/blob/main/resources/KC.md) | "Labs CKA - Build a Kubernetes cluster 1.23"
### Best Practices
#### Security Best Practices
* Secure inter-service communication (one way is to use Istio to provide mutual TLS)
* Isolate different resources into separate namespaces based on some logical groups
* Use supported container runtime (if you use Docker then drop it because it's deprecated. You might want to CRI-O as an engine and podman for CLI)
* Test properly changes to the cluster (e.g. consider using Datree to prevent kubernetes misconfigurations)
* Limit who can do what (by using for example OPA gatekeeper) in the cluster
* Use NetworkPolicy to apply network security
* Consider using tools (e.g. Falco) for monitoring threats
### CheatSheet
#### Minikube
* Minikube version: `minikube version`
* Start cluster: `minikube start`
* Delete cluster: `minikube delete`
#### Common Kubectl Operations
* Create objects defined in a YAML: kubectl apply -f rs.yaml
#### Service Accounts
* List service accounts: `kubectl get serviceaccounts`
### Cluster
* Cluster version: `kubectl version`
* Cluster information: `kubectl cluster-info`
* List nodes: `kubectl get nodes`
### Images
* List all containers images from all namespaces:
```
kubectl get pods --all-namespaces -o jsonpath="{.items[*].spec.containers[*].image}" |\
tr -s '[[:space:]]' '\n' |\
sort |\
uniq -c
```
### Pods
* List of Pods in current namespace: `kubectl get po`
* List of Pods in all amespaces: `kubectl get po --all-namespaces`
* Get containers names: `kubectl get po -o jsonpath="{.spec.containers[*].name}"`
* Create a Pod from file: `kubectl create -f pod_definition.yaml`
* Delete a Pod using a YAML definition: `kubectl delete -f pod_definition.yaml`
* Delete a Pod using the Pod name: `kubectl delete `
* Delete a Pod instantly: `kubectl delete --grace-period=0 --force`
* Execute commands inside a container: `kubectl exec -it -c ls`
* Display logs of a Pod: `kubectl logs `
* Display logs of a specific container in a Pod: `kubectl logs -c `
* Get Pod name based on specific labels
```
POD_NAME=$(kubectl get pod \
--no-headers \
-o=custom-columns=NAME:.metadata.name \
-l type=api,service=some-service \
| tail -1)
```
* Get pods sorted by time creation: `kubectl get pods --sort-by='{.metadata.creationTimestamp}'`
* Run long/endless running container: `kubectl run test --image ubuntu -- sleep 2000000000`
* Get a shell access to a container: `kubectl exec --stdin --tty some-shell -- /bin/bash`
### User
* Creating a new user
```
openssl genrsa -out user.key 2048 # create key
openssl req key user.key user.csr -subj "/CN=user /O=sgroup" # create csr
openssl x509 -req -in user.csr -CA ca.crt -CAkey ca.key -CAcreateseral -out user.crt -days 365
kubectl config set-credentials myuser --client-certificates=$PWD/user.crt --client-key=$PWD/user.key
kubectl config set-context myuser-context --cluster=k8s-cluster --user=user
```
### Service
* Expose a ReplicaSet: `kubectl expose rs REPLICASET_NAME --name=SERVICE_NAME --target-port=PORT --type=NodePort/SOME_OTHER_SERVICE_TYPE`
### Deployment
* Create and delete a deployment in one step:
```
$ kubectl create deployment demo --image=cloudnatived/demo:hello
$ kubectl get pods --selector app=demo
$ kubectl delete pods --selector app=demo
$ kubectl delete all --selector app=demo
```
### Aliases
* Use kubectl aliases to speed up and reduce typo errors, practice these alaises early at your work and study for the exam. some example aliases:
```
alias k='kubectl'
alias kg='kubectl get'
alias kgpo='kubectl get pod'
alias kcpyd='kubectl create pod -o yaml --dry-run=client'
alias ksysgpo='kubectl --namespace=kube-system get pod'
alias kd='kubectl delete'
alias kdf='kubectl delete -f'
## for quick deletes you can add --force --grace-period=0 **Not sure if it is a good idea if you are in a production cluster**
alias krmgf='kubectl delete --grace-period 0 --force'
alias kgsvcoyaml='kubectl get service -o=yaml'
alias kgsvcwn='watch kubectl get service --namespace'
alias kgsvcslwn='watch kubectl get service --show-labels --namespace'
#example usage of aliases
krmgf nginx-8jk71 # kill pod nginx-8jk71 using grace period 0 and force
```
### Monitoring
* Install metrics-server using Minikube: `minikube addons enable metrics-server`
### Secrets
* Install Bitnami Sealed secrets controller
```
helm repo add sealed-secrets https://bitnami-labs.github.io/sealed-secrets
helm repo update
helm install sealed-secrets-controller sealed-secrets/sealed-secrets
```
* sealed-secrets binary: `https://github.com/bitnami-labs/sealed-secrets/releases`
* encrypt secret in yaml or json format: `kubeseal -n my-namespace <.db-creds.yml> db-creds.json`
* apply secret on the cluser: `kubectl apply -f db-creds.json -n my-namespace`
### Kustomize
* Generate customized YAML file(s): `kustomize build name_of_application`
* Apply generated customized YAML file(s) to the cluster: `kustomize build name_of_application`
================================================
FILE: resources/linux.md
================================================
# Linux

## Learn Linux - Tutorials and Guides
Name | Comments
:------|:------:
[Linux Journey](https://linuxjourney.com) | Written guides + exercises + quiz
[Techmint Linux](https://www.tecmint.com/free-online-linux-learning-guide-for-beginners) | Written articles/lessons
[Linux Survival](https://linuxsurvival.com/linux-tutorial-introduction) | Interactive guide
[NixCraft](https://www.cyberciti.biz/) | Succinct guides
[Linux Filesystem Explained](https://www.linux.com/training-tutorials/linux-filesystem-explained) | NSIA
[Linux SysOps Handbook](https://abarrak.gitbook.io/linux-sysops-handbook) | A study notes book for the common knowledge and tasks of a Linux system admin.
[LinuxToday](https://www.linuxtoday.com) | Contributor-driven news resources
## Linux Internals - Articles
Name | Comments
:------|:------:
[How are Unix pipes implemented?](https://toroid.org/unix-pipe-implementation) |
## Linux Internals - Videos
Name | Comments
:------|:------:
[Understanding fork() system call for new process creation](https://www.youtube.com/watch?v=PwxTbksJ2fo) |
## Learn Linux - Videos
Name | Comments
:------|:------:
[learnlinux.tv](https://www.learnlinux.tv) | Very practical videos on various topics
## Books
Author | Title | Comments
:------ |:------:|:--------:
William Shotts | [The Linux Command Line](http://linuxcommand.org/tlcl.php) | Free |
Christopher Negus | [Linux Bible](https://www.wiley.com/en-us/Linux+Bible%2C+9th+Edition-p-9781118999875) | |
## Sites
Name | Comments
:------|:------:
[Linux From Scratch](http://www.linuxfromscratch.org) |
[Operating Systems: Three Easy Pieces](http://pages.cs.wisc.edu/~remzi/OSTEP) |
## Videos
Presenter | Video | Length | Level
:------ |:------|:------:|:--------:
Joseph Delgadillo | [The Complete Linux Course: Beginner to Power User!](https://www.youtube.com/watch?v=wBp0Rb-ZJak&t=6578s) | 07:23:52 | Beginner |
## Tweak OS
Fedora disable alert sound
`dconf write /org/gnome/desktop/sound/event-sounds "false"`
## Presentations
Author | Presentation | Level | Comments
:------ |:------|:--------:|:--------:
Arie Bregman | [Linux Networking](https://www.slideshare.net/ArieBregman/linux-networking-113100224) | Beginner | |
Andrew McNico | [tcpdump](https://www.slideshare.net/j0b1n/tcpdump-hunter?qid=b71dea53-7829-40a3-b82b-4a669383eac6) | Beginner | |
## Cheat Sheet
### Common Operations
* Copy files to a remote host: `rsync -azv dir USER:REMOTE_HOST_ADDR`
* View file size: `du -sh DIR/FILE`
### Users
* Who is connected: `w`
### Troubleshooting and Debugging
* see list of processes and the CPU and memory the consume: `top`
* show how long the server is up running: `uptime`
* List open files: `lsof`
* List open connections: `lsof -i`
### SElinux
Get SElinux denials
```
semodule -DB
sudo ausearch -m avc -m user_avc -m selinux_err -m user_selinux_err -i -ts today
```
### Communication
* Broadcast a message to everyone: `wall`
### Tmux
* Join a session `tmux a`
* Attach to existing session: `tmux attach -t `
* New tab: `ctrl + B + c`
* New session called "bla": `tmux new -s bla`
#### Virsh
* Destroy: `virsh destroy `
* Shutdown: `virsh shutdown `
#### Date
* year: `date +”%Y”`
* month: `date +”%m”`
* day: `date +”%a”`
#### Fedora
* Reset "interface text" value: `gsettings reset org.gnome.desktop.interface font-name`
* Reset "monospace text" value: `gsettings reset org.gnome.desktop.interface monospace-font-name`
* Reset "document text" value: `gsettings reset org.gnome.desktop.interface document-font-name`
* Reset "Legacy Window Titles": `gsettings reset org.gnome.desktop.wm.preferences titlebar-font`
#### Files
* Sort files by size: `ls -l | sort -nk5`
* Find broken links: `find /some/path -type l -exec test ! -e {} \; -print`
### LDAP
* LDAP search for a username: `ldapsearch -x -W -D username`
* LDAP search for a username specifying DC and ldap server: `ldapsearch -x -H ldap://ldap.blabla.com -LLL -b 'dc=DOMAIN,dc=com' "rhatNickName=abregman"`
### YAML
* Validate YAML file with Ruby: `ruby -ryaml -e "p YAML.load(STDIN.read)" < some_file.yaml`
* Validate YAML file with Python: `pip install pyyaml; python -c 'import yaml, sys; print(yaml.safe_load(sys.stdin))' < some_file.yaml`
### Misc
* Random string of 7 characters: `mkpasswd -l 8`
* Generate 8 digit random number: `shuf -i 9999999-99999999 -n 1`
## Checklist
Check your Linux educational progress with the following list:
- [ ] **File System Hierarchy**
- [ ] `/` (aka root)
- [ ] `/bin` and `/sbin`
- [ ] `/opt`
- [ ] `/usr`
- [ ] `/var`
- [ ] `/home`
- [ ] `/etc`
- [ ] `/proc`
- [ ] `/tmp`
- [ ] Test
- [ ] What is '/'?
- [ ] What is stored in '/bin'? what about `/etc`?
- [ ] What '/home' is usually used for?
- [ ] What type of files can you find in '/var'?
- [ ] What is unique about `/tmp`?
- [ ] **Navigation**
- [ ] Commands
- [ ] `pwd` - where am I?
- [ ] `cd` - change directory
- [ ] relative vs. absolute paths
- [ ] Test
- [ ] How to check your current path?
- [ ] Where `cd ..` will take you?
- [ ] What would be the effect of running `cd .`?
- [ ] What will happen when running 'cd -'?
- [ ] **Files**
- [ ] Types of files
- [ ] Regular
- [ ] Directory
- [ ] Socket
- [ ] Block
- [ ] Link
- [ ] Commands
- [ ] `ls` - list files and directories
- [ ] `-a` for listing hidden files
- [ ] `-l` for list formt
- [ ] `-t` order by time
- [ ] `-F` better distinguish between regular files and directories
- [ ] `touch` - creating files (original intention is updating timestamp)
- [ ] nice to know: `touch file{1..5}`
- [ ] `rm` - remove files
- [ ] `-r` for recursive
- [ ] `-f` to force removal, no questions asked
- [ ] `mkdir` - create directories
- [ ] `-p` - for creating multiple nested directories
- [ ] `rmdir` - remove directories
- [ ] `echo` - display a line of text
- [ ] `cat` - concatenate files (common usage: read a file)
- [ ] `mv` - move files directories (also rename files and directories)
- [ ] `cp` - copy a file
- [ ] `-r` for recursive (copy a directory)
- [ ] Test
- [ ] How to list hidden files?
- [ ] How to create an empty new file?
- [ ] How to remove a directory?
- [ ] How to rename a file?
- [ ] How to copy an entire directory with all its files?
- [ ] Commands
- [ ] `man` - manual for commands
- [ ] `which` - get full path for given command
- [ ] `whatis` - one-line manual page descriptions
- [ ] **I/O redirection**
- [ ] File Descriptor
- [ ] stdin 0 (input) <
- [ ] stdout 1 (output) >
- [ ] stderr 2 (error) 2>
- [ ] Append >>
- [ ] Test
- [ ] How to redirect output?
- [ ] What would be the result of the following command `blop 2> file`?
- [ ] Text Editor (one is enough)
- [ ] vim
- [ ] `i` to start typing
- [ ] `:wq` to exit (or `shit+zz`)
- [ ] nano
- [ ] emacs
- [ ] atom
- [ ] sublime
- [ ] Test (mainly for vim)
- [ ] How to remove an entire line?
- [ ] How to copy 5 lines?
- [ ] How to jump to the end of the line
- [ ] How to remove one word
- [ ] How to jump to the end of the file
- [ ] **Users**
- [ ] Commands
- [ ] useradd
- [ ] usermod
- [ ] userdel
- [ ] who
- [ ] Nice to know commands
- [ ] lastlog
- [ ] Test
- [ ] how to add a new user?
- [ ] should you be using your user or root?
- [ ] **Network**
- [ ] netstat
- [ ] **Monitoring and performence commands**
- [ ] top
- [ ] stat
- [ ] **Processes**
- [ ] Running in ackground (&)
- [ ] **Archives**
- [ ] what is it good for
- [ ] tar
- [ ] zip
- [ ] commands
- [ ] create an archive
- [ ] list archive's content
- [ ] remove an archive
- [ ] **Storage, Filesystem**
- [ ] inode
================================================
FILE: resources/machine_learning.md
================================================
# Machine Learning
## Checkbox List
- [ ] **Basic Terms**
- [ ] Sample
- [ ] Attribute
- [ ] **Data Mining**
- [ ] Association Rules
- [ ] Apriori
- [ ] Support
- [ ] Confidence
- [ ] Conviction
- [ ] Lift
- [ ] Eclat
- [ ] FP-growth
## Videos
Name | Description
:------|:------:
[Apriori](https://www.youtube.com/watch?v=WGlMlS_Yydk) | Apriori algorithm beginner explanation
[Bayesian Networks](https://www.youtube.com/watch?v=TuGDMj43ehw) | Bayesian beginner explanation
## Repos
Name | Description
:------|:------:
[PracticalAI](https://github.com/GokuMohandas/practicalAI) | A practical approach to learning and using machine learning.
================================================
FILE: resources/mongo.md
================================================
# MongoDB
## Tutorials
Name | Description
:------|:------:
[Guru99 MongoDB Tutorial](https://www.guru99.com/what-is-mongodb.html) | MongoDB Tutorial
[Tutorialspoint Tutorial](https://www.tutorialspoint.com/mongodb) | MongoDB Tutorial
## Authentication and Authorization
Name | Description
:------|:------:
[Tutorial User Administration Without You Integrating LDAP with MongoDB](https://www.youtube.com/watch?v=ky8OKWPCZXs&ab_channel=MongoDB) | Full explanation on Mongo and LDAP integration
## Cheat Sheet
### Mongo Shell
#### General
* DB stats: `db.stats()`
* Switch to a DB: `use DB_NAME`
* Show collections: `show collections`
* Show all the document in a collection: `db.COLLECTION_NAME.find({})`
* Count the number of documents in a collection: `db.COLLECTION_NAME.count()`
* Remove all the documents from a collection: `db.COLLECTION_NAME.remove({})`
* Remove field from all documents: `db.COLLECTION_NAME.update({}, {$unset: { FIELD_NAME: ""}}, {multi:true})`
* Rename field: ```db.hosts.updateMany( {}, { $rename: { "CURRENT_FIELD_NAME": "NEW_FIELD_NAME" } } )```
#### Mongoexport
* Export Mongo DB collection to a JSON file: `mongoexport --db=DB_NAME --collection=COLLECTION_NAME --out=data.json`
* Export specific fields from a Mongo DB collection to a JSON file: `mongoexport --db=DB_NAME --fields=FIELD_NAME,FIELD_NAME2 --collection=COLLECTION_NAME --out=data.json`
#### Aggregations
* Count the number of documents: `db.accounts.aggregate([ { "$count": "number of documents" }])`
* Show only the sub element 'attachment_uuids': `db.accounts.aggregate( [ {$project: {"hosts.attachment_uuids": 1, _id:0}} ] )`
#### Users
* Display users:
```
use admin
db.getUsers()
```
* Create administrative user
```
use admin
db.createUser({user: "admin", pwd: "some_password", roles: ["root"]})
```
* Authentice: `db.auth(USERNAME, PASSWORD)`
#### Roles
* Display roles
```
use admin
db.getRoles()
```
* Drop/Remove role: `db.dropRole("NAME_OF_THE_ROLE")`
#### LDAP
* Mongo Conf LDAP configuration
```
security:
# authorization: "enabled"
ldap:
servers: 'some.ldap.server.com'
userToDNMapping:
'[
{
match: "(.+)",
ldapQuery: "DC=X,DC=com??sub?(uid={0})"
}
]'
authz:
queryTemplate: "{USER}?memberOf?base"
setParameter:
authenticationMechanisms: 'PLAIN,SCRAM-SHA-1'
```
* Create role where the LDAP group "unicorns" has permissions to only run 'find' on "hosts" collection in 'test' db:
```
db.createRole({role:"cn=unicorns,ou=groups,dc=X,dc=com", privileges: [{ resource: {db: "", collection: "hosts"}, actions: ["find"]}], roles: [{ role: "read", db: "test"}]})
```
* Drop/Remove role from the previous example: `db.dropRole("cn=unicorns,ou=groups,dc=X,dc=com")`
### Mongo Python
* Add new element to an arrray only if it doesn't exists already
```
mongo_client.update(
{ "account_number": account_num },
{ "$addToSet": { "hosts": {'hostname': hostname} } }
)
```
* Add a new element to an array in sub-document (if it doesn't exists already):
```
mongo_client.update_one(
{ "account_number": account_num, "hosts.hostname": hostname },
{ "$addToSet": { "hosts.$.attachment_uuids": attachment_uuid } }
)
```
* Add all the elements in an array to an array in document (This is not about adding the array as it is but adding the elements of it):
```
mongo_client.update_one(
{'_id': 1},
{'$addToSet': {'some_list': { '$each': [1, 2, 3]} }}, upsert=True)
```
================================================
FILE: resources/monitoring.md
================================================
# Monitoring
## Articles
Name | Comments
:------|:------:
[Stack Overflow: How We Do Monitoring - 2018 Edition](https://nickcraver.com/blog/2018/11/29/stack-overflow-how-we-do-monitoring) |
## CLI Tools
Name | Comments
:------|:------:
[statuscakectl](https://github.com/omerh/statuscakectl) | Statuscake CLI
================================================
FILE: resources/network.md
================================================
# Network
## Docs
Name | Comments
:------|:------:
[TCP/IP networking referen](http://www.penguintutor.com/linux/basic-network-reference)
## Books
Author | Title | Comments
:------ |:------:|:--------:
James Kurose & Keith Ross | Computer Networking: A Top-Down Approach | Great for beginners
Andrew S. Tanenbaum | Computer Networks | Commonly used by academic networking courses
Richard Stevens | TCP/IP illustrated |
Richard Stevens | UNIX Network Programming |
OccupyTheWeb | Linux Basics for Hackers: Getting Started with Networking, Scripting, and Security in Kali | Includes a chapter on wireless networking
Evi Nemeth & Garth Snyder & Trent R. Hein & Ben Whaley & Dan Mackin | UNIX and Linux System Administration Handbook | A great book on Linux and there is a dedicated chapter for Linux networking
## Videos - Basic Networking Concepts
Presenter | Video | Length | Level
:------ |:------|:------:|:--------:
Rene Molenaar | [Address Resolution Protocol (ARP) Explained](https://www.youtube.com/watch?v=xTOyZ6TWQdM) | 00:05:13 | Beginner |
Eli the Computer Guy | [The OSI Model Demystified](https://www.youtube.com/watch?v=HEEnLZV2wGI) | 00:18:40 | Beginner |
Pieter De Decker | [Hub, Switch or Router? Network Devices Explained](https://www.youtube.com/watch?v=Ofjsh_E4HFY) | 00:07:39 | Beginner |
Pieter De Decker | [How Network Address Translation Works](https://www.youtube.com/watch?v=QBqPzHEDzvo) | 00:10:04 | Beginner |
Pieter De Decker | [How DHCP Works](https://www.youtube.com/watch?v=RUZohsAxPxQ) | 00:07:55 | Beginner |
Pieter De Decker | [UDP and TCP: Comparison of Transport Protocols](https://www.youtube.com/watch?v=Vdc8TCESIg8) | 00:11:34 | Beginner |
Ricky Tapia | [CSMA/CD](https://www.youtube.com/watch?v=IAKncL67Pp4) | 00:04:01 | Beginner |
## Videos - Linux
Presenter | Video | Length | Level
:------ |:------|:------:|:--------:
David Mahler | [Introduction to Linux Network Namespaces](https://www.youtube.com/watch?v=_WgUwUf1d34) | 00:25:50 | Beginner |
## Videos - OpenvSwitch
Presenter | Video | Slides | Length | Level
:------ |:------|:------:|:--------:|:--------:
David Mahler | [Introduction to Open vSwitch](https://www.youtube.com/watch?v=rYW7kQRyUvA) | | 00:14:35 | Beginner |
David Mahler | [An Introduction to Open vSwitch](https://www.youtube.com/watch?v=_PCRNUB7oNw) | [Slides](http://openvswitch.org/slides/openvswitch.en-2.pdf)| 00:35:49 | First half beginners, second half intermediate level |
## Videos - OpenFlow
Presenter | Video | Length | Level | Comments
:------ |:------|:------:|:--------:|:--------:
David Mahler | [Introduction to OpenFlow](https://www.youtube.com/watch?v=l25Ukkmk6Sk) | 00:15:25 | Beginner | |
Steven Wallace | [Describes the OpenFlow flow table](https://www.youtube.com/watch?v=-xLQHld3fPI) | 00:03:00 | Beginner | |
David Mahler | [OpenFlow with multiple Flow Tables](https://www.youtube.com/watch?v=TD5wmoD7XOE) | 00:09:30 | Intermediate | |
David Mahler | [OpenFlow flow entries on Open vSwitch (OVS)](https://www.youtube.com/watch?v=FyV4MoQ3T0I) | 00:14:22 | Intermediate | Required Knowledge: Open vSwitch |
## Videos - OpenStack Neutron
Presenter | Video | Length | Level | Comments
:------ |:------|:------:|:--------:|:--------:
[Shalu George & Naveen Joy] | [Neutron networking demystified for beginners](https://www.youtube.com/watch?v=c-x90PZFv8k) | 00:39:53 | Beginner | 2017 |
David Mahler | [Introduction to OpenStack Neutron](https://www.youtube.com/watch?v=yqFpyubsYfE) | 00:19:38 | Beginner | |
Assaf Muller | [Introduction to OpenStack Neutron](https://www.youtube.com/watch?v=IGGgVuZe7UA) | 00:33:20 | Beginner | |
Rossella Sblendido | [I Can't Ping My VM! Learn How to Debug Neutron and Solve Common Problems](https://www.youtube.com/watch?v=aNA8Pvewu2M) | 00:42:16 | Intermediate | Required Knowledge: neutron basics |
David Mahler | [OpenStack Neutron Packet Walkthrough (DVR)](https://www.youtube.com/watch?v=7IXEtUEZslg) | 00:44:56 | Intermediate | Required Knowledge: neutron, openvswitch, namespaces and openflow |
Mohamed Elsakhawy | [Neutron- Where Did My Packets Go?](https://www.youtube.com/watch?v=uKgMp5c6R-4) | 00:39:32 | Beginner | |
## Checklist - Network Newbie
- [ ] **OSI model**
- [ ] What layers the OSI model has and what is the purpose of each one of them?
- [ ] **Ethernet**
- [ ] What is CSMA/CD and how it works?
- [ ] **MAC address**
- [ ] What is it used for? Is it unique?
- [ ] How many bits are in a MAC address?
- [ ] **IP address**
- [ ] What is it used for? Is it unique worldwide?
- [ ] What are the two parts of an IP address?
- [ ] How many bits are in an IP address?
- [ ] **Subnets**
- [ ] Two hosts are on the same subnet if they have the same '_____'
- [ ] What is a netmask?
- [ ] What two syntaxes exist for expressing a netmask?
- [ ] **ARP**
- [ ] Which layer of the OSI model do ARP belong to?
- [ ] What ARP table includes?
- [ ] Give an example of how ARP protocol works
- [ ] **IP**
- [ ] What it defines?
- [ ] What is a routing table? When is it being used?
- [ ] **TCP**
- [ ] What are the differences between TCP and UDP? When would you prefer to use TCP over UDP?
- [ ] What is a "three-way handshake"?
- [ ] **UDP**
- [ ] Why UDP considered to be unreliable when compared to TCP?
- [ ] Which layer of the OSI model do UDP belong to?
- [ ] **DHCP**
- [ ] How DHCP client locates the DHCP server?
- [ ] Does the client has to be on the same local network as the server?
- [ ] How the exchange between client and the server looks like? what steps are included?
- [ ] Is it using TCP or UDP?
- [ ] What ports is it using?
- [ ] **Netowrk Devices**
- [ ] What is a HUB?
- [ ] What is a Switch?
- [ ] Forwarding table or (aka forwarding information base)
- [ ] What is a Router?
- [ ] What are differences between the three devices above?
- [ ] **Delivery schemes**
- [ ] What is unicast?
- [ ] What is multicast?
- [ ] What is broadcast?
- [ ] What is the broadcast address?
- [ ] What protocols use broadcast?
- [ ] What is a broadcast domain?
- [ ] **VLAN**
- [ ] What are the advantages of using VLAN?
- [ ] What is the range for VLAN IDs?
- [ ] What is a trunk port?
- [ ] **Topologies**
- [ ] Bus topology
- [ ] Ring topology
- [ ] Star topology
- [ ] Tree topology
- [ ] **IP**
- [ ] What layer of OSP model it belongs to?
- [ ] IPv4
- [ ] IPv6
- [ ] Why IPv6 is needed if IPv4 exists?
- [ ] **ICMP**
- [ ] What is it used for?
- [ ] How do you use it?
- [ ] **NAT**
- [ ] What is it and why it's needed?
- [ ] What is SNAT? how it is different from NAT?
- [ ] What is DNAT? how it is different from SNAT?
## Intermediate
- [ ] **Routing**
- [ ] Distance Vector Routing
- [ ] "Count-to-infinity" problem
- [ ] Dijkstra's algorithm
- [ ] **TCP**
- [ ] Silly window syndrome
- [ ] Nagle's algorithm
- [ ] Clark's solution
## Linux Networking
- [ ] **Commands**
- [ ] ping
- [ ] ip addr
- [ ] ip neigh
- [ ] ip link
- [ ] ip route
- [ ] ip netns
- [ ] ethtool
- [ ] netstat
- [ ] traceroute
- [ ] tcpdump
- [ ] mtr
- [ ] **ARP**
- [ ] How to view the contents of the ARP cache?
- [ ] How to initiate an ARP request manually?
- [ ] **MTU**
- [ ] How to see what is the MTU of a given interface?
- [ ] How do you set MTU?
- [ ] **Namespaces**
- [ ] How to create & delete namespaces?
- [ ] How to enter a specific namespace?
- [ ] **Routing*
- [ ] How to display the routing table?
- [ ] How to print the IP address of each router that an IP packet traverses along its path to its destination?
- [ ] **ICMP**
- [ ] How do you use it?
## Academic Level
- [ ] **Digital Modulation**
- [ ] What is Amplitude Shift keying?
- [ ] What is Frequency Shift Keying?
- [ ] What is Phase Shift keying?
- [ ] **Multiplexing**
- [ ] What is it used for and how it works?
- [ ] **Wireless networks**
- [ ] The hidden terminal problem
- [ ] The exposed terminal problem
- [ ] **MACA**
- [ ] What is RTS?
- [ ] What is CTS?
- [ ] **ALOHA**
- [ ] Pure
- [ ] Slotted
- [ ] **Noisy-channel coding theorem**
- [ ] Shannon capacity/limit
- [ ] **CSMA**
- [ ] The Binary Exponential Backoff Algorithm
- [ ] **Stop and Wait**
- [ ] **The adaptive tree walk**
- [ ] **Cryptography**
- [ ] Symmetric
- [ ] Asymmetric
- [ ] Digital Signature
- [ ] **Error Detection**
- [ ] Parity Bit
- [ ] Checksum
- [ ] CRC code
- [ ] Data transmission
- [ ] Piggybacking
- [ ] **Error Correction**
- [ ] Hamming Code
- [ ] Reed Solomon code
- [ ] The NASA binary convolutional code
- [ ] Low-Density Parity Check code
## Cloud Networking (OpenStack Neutron)
- [ ] **Components**
- [ ] API Server
- [ ] Plugins
- [ ] Agents
- [ ] Messaging Queue
- [ ] **Entities**
- [ ] Network
- [ ] Router
- [ ] Port
- [ ] Subnet
- [ ] Security Group
- [ ] **ML2 Plugin**
- [ ] What is it used for?
- [ ] Explain type drivers
- [ ] Explain mechanism drivers
- [ ] **dnsmasq***
- [ ] **Floating IP**
- [ ] **Provider Network**
================================================
FILE: resources/openshift.md
================================================
## OpenShift
### Learn OpenShift
Name | Comments
:------ |:--------:
[Learn OpenShift](https://learn.openshift.com) | Interactive way to learn OpenShift
### CheatSheet
* Login: `oc login -u my_user -p my_password`
#### Projects
* Highlevel overview of the project: `oc status`
* Create a new project: `oc new-project my_project`
* List projects: `oc get projects`
#### Accounts
* The username of the user currently logged in: `oc whoami`
* Add to user "user1" the ability to view the project "wonderland": `oc adm policy add-role-to-user view user1 -n wonderland`
* Add a user as admin to the project "wonderland": `oc adm policy add-role-to-user admin some_user -n wonderland`
* Get a list of all context whihc have ever been created: `oc config get-contexts`
* Check what is the current context: `oc whoami --show-context`
* The OpenShift server currently used: `oc whoami --show-server`
* Get the list of all the OpenShift clusters you have ever logged into: `oc config get-clusters`
#### Pods
* List pods: `oc get po`
* List pods with with node info: `oc get po -o wide`
#### Deployments
* List deployments: `oc get deployments`
#### Service Accounts
* List service accounts: `oc get serviceaccounts`
#### Misc
* Login: `oc login --token= --server=https://:`
================================================
FILE: resources/opensource.md
================================================
## Open Source - Resources
Name | Comments
:------|:------:
[Benevolent dictator for life](https://en.wikipedia.org/wiki/Benevolent_dictator_for_life) |
================================================
FILE: resources/openstack.md
================================================
# OpenStack
## Checklist
- [ ] **Components & Services**
- [ ] Neutron (Networking)
- [ ] Cinder (Storage)
- [ ] Nova (Compute)
- [ ] **Neutron**
- [ ] Agents
- [ ] Server
## Resources
Name | Description
:------|:------:
[OpenStack Operator Tools](https://github.com/openstack/osops-tools-contrib) | Tools and scripts for neutron, nova, etc.
[Infrared](https://github.com/redhat-openstack/infrared) | OpenStack Deployment with Ansible
## Cheatsheet
### Infrared
* Add plugin: `infrared plugin add `
* Add plugin when the spec not in root directory: `infrared plugin add --src-path infrared_plugin`
* Remove plugin: `infrared plugin remove `
* Import workspace (= inventory update): `infrared workspace import https://my-jenkins.com/job/blipblop/1/artifact/workspace.tgz`
* List nodes in inventory/workspace: `infrared workspace node-list`
* If you get error when executing external plugin: "no such role" then you need to create a soft link:
```
mkdir ~/.infrared/plugins//infrared_plugin/roles
ln -s ~/ ~/.infrared/plugins//infrared_plugin/roles/
```
### Servers
* List openstack instances: `openstack server list`
================================================
FILE: resources/packer.md
================================================
## Packer
### Official Resources
* Site: https://www.packer.io
* Docs: https://www.packer.io/docs
### Why Packer
I recommend reading [this discussion](https://www.reddit.com/r/devops/comments/ko3cwq/why_packer) on Reddit
### Blogs Posts
* Getting started with Packer: https://codingshell.com/packer-getting-started
================================================
FILE: resources/prometheus.md
================================================
## Prometheus
### Exporters
Name | Comments
:------|:------:
[Blackbox Exporter](https://github.com/prometheus/blackbox_exporter) | "blackbox probing of endpoints over HTTP, HTTPS, DNS, TCP and ICMP"
Elastic_Search Exporter | Prometheus exporter for various metrics about ElasticSearch, written in Go.
**How to Setup Prometheus in Kubernetes cluster for Elastic Search ?**
To Setup Prometheus in Kubernetes so that we can monitor third party applications like elastic search , we will make use of elastic search exporter which was written in go language and it is now maintained by Prometheus Community. Elastic search exporter will run as a side car container alongside Elastic Search.
now to run as side car container we will just use its image and specify the port:
```
containers:
- name: exporter
image: justwatch/elasticsearch_exporter:1.0.2
ports:
- containerPort: 9108
args: ['-es.uri=http://localhost:9200']
```
Now we will also create a config file for Prometheus:
```
apiVersion: v1
data:
prometheus.yml: |-
global:
scrape_interval: 15s
evaluation_interval: 15s
scrape_configs:
- job_name: "prometheus"
static_configs:
- targets: ["localhost:9090"]
- job_name: "exporter"
static_configs:
- targets: ["elasticsearch:9108"]
kind: ConfigMap
metadata:
name: pr-conf
namespace: elk
```
Here make sure you either write your own namespace or create this elk namespace before running.
Now next we will write a deployment file for Prometheus.
```
apiVersion: apps/v1
kind: Deployment
metadata:
namespace: elk
labels:
app: pr
name: pr
spec:
replicas: 1
selector:
matchLabels:
app: pr
template:
metadata:
creationTimestamp: null
labels:
app: pr
spec:
containers:
- image: prom/prometheus
name: prometheus
ports:
- containerPort: 9090
volumeMounts:
- name: data
mountPath: /etc/prometheus
volumes:
- name: data
configMap:
name: pr-conf
items:
- key: prometheus.yml
path: prometheus.yml
```
Now we will create a service file for nodePort , so that we can access it through our browser through our :
```
apiVersion: v1
kind: Service
metadata:
name: prometheus
namespace: elk
spec:
selector:
app: pr
type: NodePort
ports:
- port: 9090
targetPort: 9090
nodePort: 32200
```
Now we will be able to access the prometheus on 32200 which is our nodePort so start all the services one by one and you're good to go and also we can use Grafana for visualisation too along with prometheus.
================================================
FILE: resources/python.md
================================================
# Python
## Learning Python (Courses)
Name | Description
:------|:------:
[Introduction To Python Programming](https://www.udemy.com/course/pythonforbeginnersintro) | Free, Udemy
[Python for Beginner](https://www.udemy.com/course/python-hackcc) | Free, Udemy
[Learn Python](https://www.youtube.com/watch?v=rfscVS0vtbw&feature=emb_logo) | Free, freeCodeCamp
[Learn Python from Scratch](https://www.educative.io/courses/learn-python-from-scratch) | Free, educative.io
## Learning Python (Tutorials and Interactive platforms)
Name | Description
:------|:------:
[HackerRank](https://www.hackerrank.com) | Python challenges/exercises
[LeetCode](https://leetcode.com) | Python challenges/exercises
[Exercism](https://exercism.io) | Python challenges/exercises
[py4e](https://www.py4e.com) | Python lessons and materials
[W3 Python](https://www.w3schools.com/python) | Python tutorial
[Mode Python Tutorial](https://mode.com/python-tutorial) | Python Tutorial
[Khan Academy](https://www.khanacademy.org) | Python courses and lessons
[Python resources for everybody](https://learnbyexample.github.io/py_resources) | Python written resources
## Modules
Name | Description
:------|:------:
subprocess | Spawn new processes (=execute commands).
agithub | Rest API client for rapid prototyping on any rest API.
## Books
Author | Title | Comments
:------ |:------:|:--------:
Jeff Knupp | Writing Idiomatic Python 3.3 | |
Dane Hillard | [Publishing Python Packages](https://www.manning.com/books/publishing-python-packages) | |
Yong Cui | [Python How-To](https://www.manning.com/books/python-how-to) | |
Pael Anni | [Let's Talk Python](https://www.manning.com/books/lets-talk-python)) | |
## Articles, Tutorials & Blog Posts
Author | Article | Level | Comments
:------ |:------|:--------:|:--------:
Megha Mohan | [Mutable vs Immutable Objects in Python](https://medium.com/@meghamohan/mutable-and-immutable-side-of-python-c2145cf72747) | Beginner | |
Kenneth Reitz | [The Hitchhiker’s Guide to Python](http://docs.python-guide.org/en/latest) | | |
Kenneth Reitz | [Serialization](https://docs.python-guide.org/scenarios/serialization/) | | |
## Libraries, Frameworks & Tools
Name | Description
:------:|:-------:
[Natural Language Toolkit](https://www.nltk.org) | Platform for language processing programming |
[Flask](http://flask.pocoo.org) | Web microframework based on Werkzeug, Jinja 2
[Django](https://www.djangoproject.com) | Web framework with batteries included
[Mypy](http://mypy-lang.org) | Static type checker
[Pandas](https://pandas.pydata.org) | "open source data analysis and manipulation tool"
### Cheat Sheet
#### YAML
* Read YAML
```
with open(r'/file/path') as file:
```
#### Files
* Read remote file(s)
```
from fabric import Connection
with Connection(host) as conn:
with conn.sftp().open(path) as stream:
...
```
#### Dictionaries
* Define dictionary: `some_dict = {'first_number': 2017, 'second_number': 2022}`
* Add item to dictionary: `some_dict['third_number'] = 1991`
* Remove last item: `some_dict.popitem()`
* Remove item by key: `some_dict.pop("third_number")`
* Get all keys without values: `some_dict.keys()`
* Get all values without keys: `some_dict.values()`
* Access item: `some_dict['first_number']` or `some_dict.get('second_number')`
* Number of items in the dictionary: `len(some_dict)`
* Update value of a certain key: `some_dict.update({"first_number": 02017})
## Python Checklist

## Checklist
- [ ] **Data Types**
- [ ] Numbers (int, long, float, complex)
- [ ] List
- [ ] Dictionary
- [ ] String
- [ ] Tuple
- [ ] **Mutability**
- [ ] What data types are mutable?
- [ ] What data types are immutable?
- [ ] **PEP8**
- [ ] What is it?
- [ ] Give an example of three coding conventions Python developers should always follow
- [ ] **Errors & Exceptions**
- [ ] How do you handle exceptions?
- [ ] Iterators
- [ ] What 'enumerate' is used for?
- [ ] **List Comprehensions**
- [ ] Is it better than for loop? If yes, why?
- [ ] How to perform list comprehensions for nested lists?
- [ ] Data serialization
[ ] How you do with Python?
- [ ] **Type Annotations**
- [ ] **Dataclass**
- [ ] **What's that?**
- [ ] What _ is used for in Python?
- [ ] Meta-programming
- [ ] Descriptors
- [ ] Decorators
[ ] Context Managers
- [ ] Buffering Protocol
================================================
FILE: resources/security.md
================================================
## Security
### Books
* [building_secure_and_reliable_systems](https://static.googleusercontent.com/media/sre.google/en//static/pdf/building_secure_and_reliable_systems.pdf)
================================================
FILE: resources/sql.md
================================================
# Linux
## Checklist
Check your Linux educational progress with the following list:
- [ ] **Join**
## Interview Questions
* What is the difference between a hash join to merge join?
* How to compare the performance of inner loop a "when" statement and analytic
function when those are interchangeable?
================================================
FILE: resources/terraform.md
================================================
# Terraform
## Terraform Resources
https://project-awesome.org/shuaibiyy/awesome-terraform
[Terraform Script Builder](https://terraparty.com) | export valid Terraform scripts using UI
## Projects
Name | Comments
:------|:------:
[terraformer](https://github.com/GoogleCloudPlatform/terraformer) | "A CLI tool that generates tf/json and tfstate files based on existing infrastructure (reverse Terraform)."
[terraforming](https://github.com/dtan4/terraforming) | "Export existing AWS resources to Terraform style (tf, tfstate)"
[terrascan](https://github.com/tenable/terrascan) | "Detect compliance and security violations across Infrastructure as Code to mitigate risk before provisioning cloud native infrastructure"
[terraform-kvm](https://github.com/dmacvicar/terraform-provider-libvirt) | "It's a one Terraform Provider for KVM"
### Best Practices
#### tfstate
* Don't edit it manually. tfstate was designed to be manipulated by terraform and not by users directly.
* Store it in secured location (since it can include credentials and sensitive data in general)
* Backup it regularly so you can roll-back easily when needed
* Store it in remote shared storage. This is especially needed when working in a team and the state can be updated by any of the team members
* Enabled versioning if the storage where you store the state file, supports it. Versioning is great for backups and roll-backs in case of an issue.
### Cheat Sheet
* Initialize terraform: `terraform init`
* See what Terraform will execute if running apply: `terraform plan`
* Apply Terraform configuration/code: `terraform apply`
* Cleanup, remove Terraform generated resources: `terraform destroy`
* Dependency graph: `terraform graph`
#### State
* Show state: `terraform show`
* List resources from the state: `terraform state list`
* Rename resource: `terraform state mv`
* Import existing infrastructure into state: `terraform import`
#### Variables
* Pass var: `terraform -var`
* Pass vars file: `terraform -var-file`
* List all outputs: `terraform output`
* Get specific output: `terraform output `
#### Data sources
* Get data: `data...`
#### Backends
* Use variables in a remote backend: `terraform init -backend-config=some_backend_partial_conf.hcl`
#### Workspaces
* Create a new workspace: `terraform workspace new `
* Show current workspace: `terraform workspace show`
#### Productivity
* Console: `terraform console`
================================================
FILE: resources/vault.md
================================================
## Cheat Sheet
* Start Vault server in dev mode (NOT FOR PRODUCTION): `vault server -dev`
* Set up vault client (dev mode):
```
export VAULT_ADDTR='http://'
echo > unseal.key
export VAULT_DEV_ROOT_TOKEN_ID=...
vault status
```
* Write a secret using one pair of key, value: `vault kv put secret/hello foo=bar`
* Write a secret using multiple pairs of key, value: `vault kv put secret/hello foo=bar y=x`
* Get a secret: `vault kv get secret/hello`
================================================
FILE: resources/victoriametrics.md
================================================
## VictoriaMetrics
### Official Resources
* Site: https://victoriametrics.com
* Docs: https://docs.victoriametrics.com
### Why VictoriaMetrics
I recommend to read [case stadies](https://docs.victoriametrics.com/CaseStudies.html) from companies who use VictoriaMetrics in production and [Prominent features](https://docs.victoriametrics.com/Single-server-VictoriaMetrics.html#prominent-features).
### Blogs Posts
* [Getting started with VictoriaMetrics](https://victoriametrics.com/blog/victoriametrics-monitoring/)
* [How to Choose a Scalable Open Source Time Series Database: The Cost of Scale](https://victoriametrics.com/blog/the-cost-of-scale/)
* [Benchmarking Prometheus-compatible time series databases](https://victoriametrics.com/blog/remote-write-benchmark/)
================================================
FILE: resources/virtual_machines.md
================================================
## Vagrant Resources
Name | Description
:------|:------:
[Official Docs](https://www.vagrantup.com/intro/index.html) | Multi-container applications
## Vagrant Commands
Be familiar with the following commands:
vagrant up
vagrant ssh
================================================
FILE: resources/virtualization.md
================================================
## Virtualization
### Virsh CheatSheet
* List VMs: `virsh list --all`
* Shutdown VMs: `virsh shutdown `
* Delete VMs: `virsh undefine `
* List pools: `virsh pool-list`
* Delete pool content: `virsh pool-delete `
* Deactivate pool: `virsh pool-destroy `
* Delete the pool object: `virsh pool-undefine `
* List networks: `virsh net-list`
* Delete network: `virsh net-undefine && virsh net-destroy `
### Vagrant Resources
Name | Description
:------|:------:
[Official Docs](https://www.vagrantup.com/intro/index.html) | Multi-container applications
#### Vagrant Cheatsheet
* Initialize vagrant file using Fedora image: `vagrant init fedora/33-cloud-base`
* Bring up the VM: `vagrant up`
* SSH into the machine: `vagrant ssh`
* Shutdown: `vagrant halt`
* Delete the VM: `vagrant destroy`
* Reload Vagrant configuration: `vagrant reload`
================================================
FILE: roadmaps.md
================================================
## Roadmaps