From 0fd2145b72ff2685d1b1d0a8fe91cc9f6aeb01b1 Mon Sep 17 00:00:00 2001 From: Ajay Dhangar Date: Fri, 27 Mar 2026 21:33:35 +0530 Subject: [PATCH] added new docs for devops-beg... doc --- .../devops-beginner/introduction.mdx | 45 +++++++++ .../programming-language/_category_.json | 8 ++ .../choosing-the-right-tool.mdx | 65 +++++++++++++ .../go-for-cloud-tooling.mdx | 88 ++++++++++++++++++ .../intro-to-devops-coding.mdx | 65 +++++++++++++ .../javascript-for-devops.mdx | 70 ++++++++++++++ .../python-for-automation.mdx | 91 +++++++++++++++++++ 7 files changed, 432 insertions(+) create mode 100644 absolute-beginners/devops-beginner/introduction.mdx create mode 100644 absolute-beginners/devops-beginner/programming-language/_category_.json create mode 100644 absolute-beginners/devops-beginner/programming-language/choosing-the-right-tool.mdx create mode 100644 absolute-beginners/devops-beginner/programming-language/go-for-cloud-tooling.mdx create mode 100644 absolute-beginners/devops-beginner/programming-language/intro-to-devops-coding.mdx create mode 100644 absolute-beginners/devops-beginner/programming-language/javascript-for-devops.mdx create mode 100644 absolute-beginners/devops-beginner/programming-language/python-for-automation.mdx diff --git a/absolute-beginners/devops-beginner/introduction.mdx b/absolute-beginners/devops-beginner/introduction.mdx new file mode 100644 index 0000000..cfc4f65 --- /dev/null +++ b/absolute-beginners/devops-beginner/introduction.mdx @@ -0,0 +1,45 @@ +--- +sidebar_position: 1 +title: "What is DevOps?" +sidebar_label: "1. Introduction" +description: "Start your journey into the world of DevOps. Learn the culture, the lifecycle, and why it is the backbone of modern software engineering." +--- + +Welcome to the **DevOps for Absolute Beginners** track! If you've ever wondered how companies like Google, Netflix, or Amazon deploy code thousands of times a day without breaking their websites, the answer is **DevOps**. + +## 🧐 What exactly is DevOps? + +The word "DevOps" is a combination of **Development** (Dev) and **Operations** (Ops). + +Historically, developers wrote code and "threw it over the wall" to the operations team to run it. If it broke, the teams would blame each other. DevOps breaks down this wall, creating a shared responsibility for the entire lifecycle of an application. + +### The 3 Pillars of DevOps: +1. **Culture:** Collaboration between teams instead of silos. +2. **Automation:** Replacing manual, repetitive tasks with code (Scripts, CI/CD). +3. **Measurement:** Using data and monitoring to improve performance and reliability. + +## The DevOps Roadmap + +In this path at **CodeHarborHub**, we aren't just learning tools; we are learning how to build a "Software Factory." We will cover: + +* **Programming for DevOps:** Using Python, Go, and JS to automate tasks. +* **Linux Foundations:** Mastering the command line (the home of DevOps). +* **Containers & Orchestration:** Learning Docker and Kubernetes. +* **CI/CD Pipelines:** Automating the journey from code to production. +* **Cloud Computing:** Managing infrastructure on AWS, Azure, or GCP. + +## Why Learn DevOps? + +* **High Demand:** DevOps Engineers are among the highest-paid roles in tech. +* **Speed:** Help teams move from "one release per month" to "one release per hour." +* **Reliability:** Build systems that automatically fix themselves when they crash. + +## Explore the Modules + +Click on any of the modules below to start your DevOps journey: + + + +:::tip +DevOps is a marathon, not a sprint. Don't worry about mastering every tool at once. Focus on understanding the **process** first, and the tools will follow naturally! +::: \ No newline at end of file diff --git a/absolute-beginners/devops-beginner/programming-language/_category_.json b/absolute-beginners/devops-beginner/programming-language/_category_.json new file mode 100644 index 0000000..122938a --- /dev/null +++ b/absolute-beginners/devops-beginner/programming-language/_category_.json @@ -0,0 +1,8 @@ +{ + "label": "Programming Language", + "position": 2, + "link": { + "type": "generated-index", + "description": "Master the 'Trinity' of DevOps coding: Python for automation, Go for cloud-native tooling, and JavaScript for serverless and CI/CD workflows." + } +} \ No newline at end of file diff --git a/absolute-beginners/devops-beginner/programming-language/choosing-the-right-tool.mdx b/absolute-beginners/devops-beginner/programming-language/choosing-the-right-tool.mdx new file mode 100644 index 0000000..9a267f8 --- /dev/null +++ b/absolute-beginners/devops-beginner/programming-language/choosing-the-right-tool.mdx @@ -0,0 +1,65 @@ +--- +sidebar_position: 5 +title: "Choosing the Right Tool" +sidebar_label: "5. Which Language?" +description: "Learn how to decide between Python, Go, and JavaScript for your DevOps tasks and infrastructure automation." +--- + +In the **CodeHarborHub** DevOps journey, you've now seen the "Big Three": **Python**, **Go**, and **JavaScript**. But in a real production environment, you will often face a choice: "Which one should I use for this task?" + +Choosing the wrong language can lead to slow deployments, hard-to-maintain scripts, or "dependency hell" on your servers. + +## The Decision Matrix + +Use this quick reference guide to pick your weapon based on the task: + +| If the task is... | Use this language | Because... | +| :--- | :--- | :--- | +| **Cloud Automation** (AWS/GCP) | **Python** | Boto3 and Cloud SDKs are most mature in Python. | +| **High-Performance CLI** | **Go** | Fast execution and single-binary deployment. | +| **CI/CD Pipelines** | **JavaScript** | Native support in GitHub Actions and fast startup. | +| **System Administration** | **Python** | Pre-installed on Linux; great for file/OS manipulation. | +| **Infrastructure as Code** | **TypeScript** | AWS CDK and Pulumi have excellent TS support. | +| **Kubernetes Tooling** | **Go** | Native integration with the K8s API. | + +## Deep Dive: Three Common Scenarios + +### Scenario A: The "One-Off" Cleanup Script +* **Task:** You need a script that runs every night to delete temp files older than 30 days. +* **Winner:** **Python**. +* **Reason:** You can write this in 10 lines of code. It doesn't need to be fast, and you don't need to compile it. It’s "Quick and Dirty." + +### Scenario B: The Team-Wide CLI Tool +* **Task:** You are building a tool that all 50 developers in your company will use to "spin up" local dev environments. +* **Winner:** **Go**. +* **Reason:** You don't want to help 50 people debug their Python versions or Node installations. You just want to give them one binary file that "just works." + +### Scenario C: The Deployment Pipeline +* **Task:** You need to write a custom check that runs every time someone pushes code to GitHub to verify their documentation. +* **Winner:** **JavaScript**. +* **Reason:** GitHub Actions run in a Node.js environment by default. Using JS makes the pipeline start 5x faster than pulling a heavy Python image. + +## The "CodeHarborHub" Rule of Thumb + +When in doubt, follow this hierarchy of choice: + +1. **Can I do it in Bash?** If it’s 3 lines or less, use a Shell script. +2. **Is it for AWS/Automation?** Use **Python**. +3. **Does it need to be shared as a Tool?** Use **Go**. +4. **Is it for a Pipeline or Lambda?** Use **JavaScript**. + +## Moving Beyond the Code + +Remember: As a DevOps Engineer, your goal is **less code, more automation.** Before you start writing a 500-line Python script, ask yourself: *"Does a tool like Terraform, Ansible, or a GitHub Action already do this for me?"* + +The best DevOps code is the code you **didn't** have to write. + +## Summary Checklist +* [x] I can explain the strengths of Python, Go, and JS. +* [x] I understand when to prioritize a "Single Binary" (Go) over a "Script" (Python). +* [x] I know that JavaScript is the best choice for Pipeline-specific logic. +* [x] I understand that "Idempotency" and "Simplicity" are more important than the language choice. + +:::success Programming Module Complete! +You have successfully mastered the "Trinity" of DevOps programming. You are no longer just a coder; you are an **Automation Architect**. +::: \ No newline at end of file diff --git a/absolute-beginners/devops-beginner/programming-language/go-for-cloud-tooling.mdx b/absolute-beginners/devops-beginner/programming-language/go-for-cloud-tooling.mdx new file mode 100644 index 0000000..98b3b98 --- /dev/null +++ b/absolute-beginners/devops-beginner/programming-language/go-for-cloud-tooling.mdx @@ -0,0 +1,88 @@ +--- +sidebar_position: 3 +title: "Go: The Language of the Cloud" +sidebar_label: "3. Go for Cloud Tooling" +description: "Learn why Docker, Kubernetes, and Terraform are built in Go, and how it differs from Python for DevOps." +--- + +If Python is the "Swiss Army Knife" of DevOps, **Go** is the "Industrial Power Tool." While Python is great for quick scripts, **Go** is used to build the massive platforms that run the modern internet (Docker, Kubernetes, Terraform, and Prometheus). + +## Why Go for DevOps? + +As a DevOps Engineer at **CodeHarborHub**, you will eventually hit a limit with Python. Go solves three major problems: + +### 1. Static Binaries (The "Zero Dependency" Rule) +In Python, to run a script on a server, you must install Python, pip, and all your libraries (`requirements.txt`). +In **Go**, you "compile" your code into a single, standalone file (a Binary). You can drop that file onto a bare Linux server, and it will run instantly with **zero** installation. + +### 2. High Performance & Concurrency +Go was designed at Google to handle thousands of tasks at once. Its "Goroutines" allow you to perform massive infrastructure tasks (like checking the health of 5,000 servers) in parallel without crashing. + +### 3. Type Safety +Go is "Statically Typed." This means if you try to pass a `String` where a `Number` is expected, the code won't even compile. This prevents 50% of the bugs that usually happen in Python scripts at 3:00 AM. + +## Go vs. Python: When to switch? + +| Feature | Python | Go (Golang) | +| :--- | :--- | :--- | +| **Speed** | Slower (Interpreted) | Very Fast (Compiled) | +| **Deployment** | Needs Runtime/Env | Single Binary file | +| **Concurrency** | Complex (GIL) | Built-in (Goroutines) | +| **Best For** | Data, AI, Simple Scripts | CLI Tools, Microservices | + +## Building a Simple CLI Tool + +In DevOps, we often build **CLI (Command Line Interface)** tools. Here is a simple Go tool that checks if a website is up. + +```go +package main + +import ( + "fmt" + "net/http" + "time" +) + +func main() { + url := "https://codeharborhub.github.io" + + // Perform an HTTP GET request + resp, err := http.Get(url) + + if err != nil { + fmt.Printf("❌ Error: %s is down!\n", url) + return + } + + if resp.StatusCode == 200 { + fmt.Printf("✅ Success: %s is healthy (Status 200)\n", url) + } else { + fmt.Printf("⚠️ Warning: %s returned status %d\n", url, resp.StatusCode) + } +} +``` + +### To "Ship" this tool: + +You run `go build -o health-check`. You now have a file called `health-check` that you can send to any teammate, and it will work\! + +## The Ecosystem: "The Go Stack" + +Almost every major DevOps tool you will use at **CodeHarborHub** is written in Go: + + * **Docker:** The container engine. + * **Kubernetes (K8s):** The container orchestrator. + * **Terraform:** Infrastructure as Code. + * **Hugo:** The static site generator (Faster than Docusaurus\!). + * **Prometheus:** Monitoring and alerting. + +## Summary Checklist + + * [x] I understand that Go compiles to a **Single Binary**. + * [x] I know that Go is much faster than Python for heavy tasks. + * [x] I can explain why "Static Typing" helps prevent bugs. + * [x] I recognize that major DevOps tools (Docker/K8s) are built in Go. + +:::tip +Don't be intimidated by Go's syntax! It is much simpler than C++ or Java. Most DevOps engineers learn just enough Go to build custom CLI tools or contribute small fixes to open-source projects like Terraform providers. +::: \ No newline at end of file diff --git a/absolute-beginners/devops-beginner/programming-language/intro-to-devops-coding.mdx b/absolute-beginners/devops-beginner/programming-language/intro-to-devops-coding.mdx new file mode 100644 index 0000000..77ffb9c --- /dev/null +++ b/absolute-beginners/devops-beginner/programming-language/intro-to-devops-coding.mdx @@ -0,0 +1,65 @@ +--- +sidebar_position: 1 +title: "Coding for DevOps: The Scripting Mindset" +sidebar_label: "1. Intro to DevOps Coding" +description: "Learn the difference between Software Development and DevOps Scripting, and why the Trinity of Python, Go, and JS is essential." +--- + +In the **Backend Development** path, you learned to write code for humans (APIs, Websites). In the **DevOps** path, you will learn to write code for **machines**. + +As a DevOps Engineer at **CodeHarborHub**, your code acts as the "glue" that connects your source code, your servers, and your cloud providers. + +## 🧐 Software Engineering vs. DevOps Scripting + +What's the difference? It's all about the **Goal**. + +| Feature | Software Engineering (Dev) | DevOps Coding (Ops) | +| :--- | :--- | :--- | +| **Target** | End Users (Customers) | Machines & Infrastructure | +| **Output** | Applications / Features | Scripts / Automation / Tools | +| **Focus** | User Experience (UX) | Reliability & Scalability | +| **Execution** | Long-running (Servers) | Task-oriented (Jobs/Pipelines) | + +## The "DevOps Trinity" + +At **CodeHarborHub**, we focus on three specific languages. Each one has a unique "superpower" in the DevOps lifecycle. + + + + **Why?** It's pre-installed on Linux and has the best libraries for AWS (`boto3`) and Data. + **Best for:** Automation scripts, cron jobs, and AI-Ops. + + + **Why?** It's fast and compiles to a single binary. It's what Docker and Kubernetes are built with. + **Best for:** High-performance CLI tools and Cloud-native infrastructure. + + + **Why?** It's the native language of GitHub Actions and Serverless functions (AWS Lambda). + **Best for:** CI/CD workflows and Infrastructure as Code (CDK). + + + +## Core Concepts for DevOps Coders + +To be successful in this path, you must master these three patterns: + +### 1. The CLI Pattern (Input/Output) +Your scripts should take arguments (like `--env production`) and provide clear output (like `Success: Server Restarted`). + +### 2. Idempotency (The "Safety" Rule) +In DevOps, an **Idempotent** script is one that can be run 100 times but only makes a change the *first* time. +* **Bad Script:** Adds a new line to a file every time it runs. +* **Good Script:** Checks if the line exists first, and only adds it if it's missing. + +### 3. Error Handling (The "Graceful" Failure) +If a DevOps script fails halfway through, it could leave a server in a "broken" state. Your code must handle timeouts and network errors gracefully. + +## Summary Checklist +* [x] I understand that DevOps coding focuses on automation and tools. +* [x] I can explain why Python, Go, and JS are the preferred languages. +* [x] I understand the concept of **Idempotency**. +* [x] I know that my "users" are often other scripts or CI/CD pipelines. + +:::tip +You don't need to be a "Master" of all three languages. Most DevOps engineers at **CodeHarborHub** are "Expert" in one (usually Python) and "Proficient" in the others. Pick one to start, and the rest will follow! +::: \ No newline at end of file diff --git a/absolute-beginners/devops-beginner/programming-language/javascript-for-devops.mdx b/absolute-beginners/devops-beginner/programming-language/javascript-for-devops.mdx new file mode 100644 index 0000000..36a6fed --- /dev/null +++ b/absolute-beginners/devops-beginner/programming-language/javascript-for-devops.mdx @@ -0,0 +1,70 @@ +--- +sidebar_position: 4 +title: "JavaScript: Pipelines & Serverless" +sidebar_label: "4. JS for DevOps" +description: "Learn why JavaScript is essential for GitHub Actions, AWS CDK, and modern Serverless DevOps." +--- + +If you come from a **Full-Stack** background at **CodeHarborHub**, you already have a DevOps superpower. JavaScript isn't just for building UI; it is the native language of the modern "Automation Pipeline." + +## Where does JS fit in DevOps? + +In the DevOps world, JavaScript (and its safer brother, **TypeScript**) is used in three critical areas: + +### 1. GitHub Actions (CI/CD) +GitHub is the home of your code. **GitHub Actions** is the engine that tests and deploys that code. Almost all custom GitHub Actions are written in Node.js because it starts instantly and has a massive library ecosystem (NPM). + +### 2. AWS CDK (Infrastructure as Code) +Instead of writing messy YAML or JSON files to define your servers, the **AWS Cloud Development Kit (CDK)** lets you define your entire infrastructure using TypeScript classes. +* *Example:* `new s3.Bucket(this, 'MyDevOpsBucket');` + +### 3. Serverless Functions (AWS Lambda) +When you need a tiny piece of code to run in response to an event (like a file being uploaded), **Node.js** is the most popular choice because of its "Event-Driven" nature. + +## Building a GitHub Action (Scripting) + +One common DevOps task is to automatically label Pull Requests or check for "TODO" comments. Here is a simple Node.js script that a DevOps engineer might run inside a CI/CD pipeline: + +```javascript +const fs = require('fs'); + +// A DevOps script to scan for "TODO" comments in the codebase +const files = fs.readdirSync('./src'); + +files.forEach(file => { + const content = fs.readFileSync(`./src/${file}`, 'utf8'); + if (content.includes('TODO:')) { + console.warn(`⚠️ Warning: ${file} contains unfinished tasks!`); + // In a real pipeline, we might fail the build here + // process.exit(1); + } +}); +``` + +## Why JS over Python or Go? + +| Feature | JavaScript (Node.js) | Python / Go | +| :--- | :--- | :--- | +| **Eco-system** | Largest (NPM) | Large / Growing | +| **Speed** | Fast (Event Loop) | Slower / Faster | +| **Cloud Native** | Best for Lambda/Actions | Great for Automation/CLI | +| **Integration** | Native to Web/GitHub | Needs 3rd Party Wrappers | + +## The DevOps JS Toolbox + +As a DevOps engineer at **CodeHarborHub**, you should be familiar with these JS-based tools: + + * **zx:** A library by Google that makes writing shell scripts in JavaScript as easy as writing them in Bash. + * **Puppeteer:** Used for "Synthetic Monitoring" (Simulating a user clicking through your site to make sure it's not down). + * **Pulumi:** An alternative to Terraform that lets you manage infrastructure using standard JavaScript. + +## Summary Checklist + + * [x] I understand that JS is the primary language for **GitHub Actions**. + * [x] I know that **TypeScript** is preferred for Infrastructure as Code (CDK). + * [x] I can explain why Node.js is a great fit for **Serverless** (Lambda). + * [x] I understand that JS allows Frontend and DevOps teams to speak the same language. + +:::tip +If you are already a JavaScript developer, don't switch to Python immediately\! Start your DevOps journey by writing **GitHub Actions** and **AWS CDK** scripts in TypeScript. You’ll be surprised how much infrastructure you can manage with the skills you already have. +::: \ No newline at end of file diff --git a/absolute-beginners/devops-beginner/programming-language/python-for-automation.mdx b/absolute-beginners/devops-beginner/programming-language/python-for-automation.mdx new file mode 100644 index 0000000..ac3af44 --- /dev/null +++ b/absolute-beginners/devops-beginner/programming-language/python-for-automation.mdx @@ -0,0 +1,91 @@ +--- +sidebar_position: 2 +title: "Python: The DevOps Swiss Army Knife" +sidebar_label: "2. Python for Automation" +description: "Learn how to use Python to automate system tasks, manage files, and control the cloud with Boto3." +--- + +If you ask any DevOps Engineer at **CodeHarborHub** which language they use most, the answer is almost always **Python**. It is readable, powerful, and comes pre-installed on nearly every Linux server in the world. + +## The "Big Three" Automation Libraries + +In DevOps, we rarely use Python for "Algorithms." We use it to talk to the **Operating System**, the **Network**, and the **Cloud**. + +### 1. The `os` & `sys` Modules +These allow your script to "click buttons" and "move files" in Linux. +* **Use case:** Renaming 1,000 log files instantly. +* **Use case:** Checking if a specific folder exists before running a backup. + +### 2. The `subprocess` Module +This is how Python "types" into the terminal for you. It allows you to run shell commands (like `git`, `docker`, or `ls`) and capture the output. + +### 3. The `requests` Library +The gold standard for talking to APIs. +* **Use case:** Sending an alert to a Slack channel when a server goes down. +* **Use case:** Fetching the latest deployment status from GitHub. + +## Cloud Automation with Boto3 + +In the modern DevOps world, we don't manually create servers in the AWS Console. We use **Boto3**, the official AWS SDK for Python. + +### Example: Auto-Stop Idle Servers +Imagine you want to save money at **CodeHarborHub** by stopping all "Dev" servers at 6:00 PM. + +```python +import boto3 + +ec2 = boto3.resource('ec2') + +# Find all instances with the tag "Environment: Dev" +instances = ec2.instances.filter( + Filters=[{'Name': 'tag:Environment', 'Values': ['Dev']}] +) + +for instance in instances: + instance.stop() + print(f"Stopped instance: {instance.id}") +``` + +## Practical Script: The "Log Cleaner" + +One common DevOps task is cleaning up old logs so the disk doesn't get full. Here is a professional-style script: + +```python +import os +import time + +# Configuration +LOG_DIR = "/var/logs/app" +DAYS_OLD = 7 +SECONDS_IN_DAY = 86400 + +current_time = time.time() + +for filename in os.listdir(LOG_DIR): + file_path = os.path.join(LOG_DIR, filename) + + # Get the "Last Modified" time of the file + file_age = os.path.getmtime(file_path) + + # Calculate age in days + if (current_time - file_age) > (DAYS_OLD * SECONDS_IN_DAY): + os.remove(file_path) + print(f"🗑️ Deleted old log: {filename}") +``` + +## Python Best Practices for DevOps + +1. **Use Virtual Environments (`venv`):** Never install libraries globally on a server. It can break the operating system's own Python tools. +2. **Shebang Lines:** Always start your scripts with `#!/usr/bin/env python3`. This tells Linux exactly how to run the file. +3. **Try/Except Blocks:** Servers are messy. Internet goes down. Disks get full. Always wrap your automation in error handling so one failure doesn't crash the whole pipeline. + +## Summary Checklist + + * [x] I understand why Python is preferred for Linux automation. + * [x] I can explain the difference between `os` and `subprocess`. + * [x] I know that **Boto3** is the key to automating AWS. + * [x] I understand the importance of `try/except` for "resilient" scripts. + +:::tip Take Action +Try running the `os.listdir()` command on your local machine to see a list of your files. You’ve just written your first piece of "Operational Code"\! +::: \ No newline at end of file