# DevOps/Infrastructure

### 1. Docker 🐳

Docker is a platform for developing, shipping, and running applications in containers.

#### Key Concepts:

* Containers: Lightweight, standalone executable packages
* Images: Read-only templates used to create containers
* Dockerfile: Script to build Docker images
* Docker Hub: Cloud-based registry for Docker images

#### Architecture:

<figure><img src="/files/TFa2XTK8nbUYVbwxf3GV" alt=""><figcaption></figcaption></figure>

#### Example Dockerfile:

```
FROM node:14
WORKDIR /app
COPY package*.json ./
RUN npm install
COPY . .
EXPOSE 3000
CMD ["npm", "start"]
```

### 2. Kubernetes ☸️

Kubernetes is an open-source container orchestration platform for automating deployment, scaling, and management of containerized applications.

#### Key Concepts:

* Pods: Smallest deployable units in Kubernetes
* Nodes: Worker machines in a Kubernetes cluster
* Clusters: Set of nodes that run containerized applications
* Services: Abstract way to expose applications running on pods

#### Architecture:

<figure><img src="/files/AkihcCMdc1pWthHcoCBg" alt=""><figcaption></figcaption></figure>

#### Example Kubernetes Deployment:

```yaml
apiVersion: apps/v1
kind: Deployment
metadata:
  name: nginx-deployment
spec:
  replicas: 3
  selector:
    matchLabels:
      app: nginx
  template:
    metadata:
      labels:
        app: nginx
    spec:
      containers:
      - name: nginx
        image: nginx:1.14.2
        ports:
        - containerPort: 80
```

### 3. CI/CD 🔄

Continuous Integration and Continuous Deployment (CI/CD) is a method to frequently deliver apps to customers by introducing automation into the stages of app development.

#### Key Concepts:

* Continuous Integration: Merging code changes frequently
* Continuous Delivery: Automatically preparing code for release
* Continuous Deployment: Automatically releasing to production
* Pipelines: Automated processes for building, testing, and deploying

#### CI/CD Pipeline:

<figure><img src="/files/ooOJYveEd0AXgHtRxppT" alt=""><figcaption></figcaption></figure>

#### Example GitLab CI/CD Configuration:

```yaml
stages:
  - build
  - test
  - deploy

build:
  stage: build
  script:
    - npm install
    - npm run build

test:
  stage: test
  script:
    - npm run test

deploy:
  stage: deploy
  script:
    - npm run deploy
  only:
    - master
```

### 4. Docker Swarm 🐝

Docker Swarm is a native clustering and orchestration solution for Docker.

#### Key Concepts:

* Nodes: Docker hosts participating in the swarm
* Services: Definition of tasks to execute on nodes
* Tasks: Docker containers executing commands
* Load Balancing: Distributing service containers across nodes

#### Architecture:

<figure><img src="/files/ts9cE6mNBlzWBgXAv42y" alt=""><figcaption></figcaption></figure>

#### Example Docker Swarm Service:

```bash
docker service create --name my-web-server \\
                      --replicas 3 \\
                      --publish 80:80 \\
                      nginx
```

The core of modern DevOps and Infrastructure management, enabling efficient development, deployment, and scaling of applications. 🚀


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://www.ankitavirani.com/experience/devops-infrastructure.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
