From 176ab614008b0faac0d4781281b042a6071e3e65 Mon Sep 17 00:00:00 2001 From: radinpirouz Date: Mon, 16 Dec 2024 14:53:47 +0330 Subject: [PATCH 1/3] add gitlab installtion doc --- .../Git/Gitlab/Install/baremetal.md | 88 +++++++++++++++++++ 1 file changed, 88 insertions(+) create mode 100644 Code Management/Git/Gitlab/Install/baremetal.md diff --git a/Code Management/Git/Gitlab/Install/baremetal.md b/Code Management/Git/Gitlab/Install/baremetal.md new file mode 100644 index 0000000..db6e824 --- /dev/null +++ b/Code Management/Git/Gitlab/Install/baremetal.md @@ -0,0 +1,88 @@ +# Setting Up GitLab CE on Ubuntu + +Follow the steps below to install and configure GitLab Community Edition (CE) on your Ubuntu system. + +--- + +## Step 1: Update the System +Ensure your package lists are up-to-date: +```bash +sudo apt update +``` + +--- + +## Step 2: Install Dependencies +Install required packages for GitLab: +```bash +sudo apt install -y ca-certificates curl openssh-server postfix tzdata perl +``` + +- **ca-certificates**: Ensures proper SSL certificate handling. +- **curl**: For downloading files. +- **openssh-server**: For SSH-based Git operations. +- **postfix**: Mail transport agent for email notifications. +- **tzdata**: Time zone data. +- **perl**: Required by GitLab scripts. + +During the installation, configure **Postfix** to match your mail setup. If unsure, select "Internet Site" and provide your domain. + +--- + +## Step 3: Add GitLab's Repository +Download and run the repository setup script: +```bash +curl -LO https://packages.gitlab.com/install/repositories/gitlab/gitlab-ce/script.deb.sh +sudo bash script.deb.sh +``` + +--- + +## Step 4: Install GitLab CE +Install the GitLab CE package: +```bash +sudo apt install -y gitlab-ce +``` + +--- + +## Step 5: Configure GitLab +Edit the GitLab configuration file to match your environment: +```bash +sudo vim /etc/gitlab/gitlab.rb +``` + +- Modify the `external_url` setting to your desired domain or IP. + +Save and exit the editor. + +--- + +## Step 6: Apply the Configuration +Reconfigure GitLab to apply the changes: +```bash +sudo gitlab-ctl reconfigure +``` + +--- + +## Step 7: Retrieve the Initial Root Password +After configuration, retrieve the initial root password: +```bash +sudo cat /etc/gitlab/initial_root_password +``` + +--- + +## Notes +- The default admin username is `root`. +- Save the password securely and change it after the first login. + +--- + +## Troubleshooting +- If you encounter issues, consult the [GitLab Documentation](https://docs.gitlab.com) or check logs in `/var/log/gitlab`. + +--- + +Enjoy using GitLab CE! From 2ca9571901546d29677c1422beb5d47a92db5209 Mon Sep 17 00:00:00 2001 From: radinpirouz Date: Mon, 16 Dec 2024 20:47:37 +0330 Subject: [PATCH 2/3] add postresql doc --- Databases/Postgresql/install.md | 56 +++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 Databases/Postgresql/install.md diff --git a/Databases/Postgresql/install.md b/Databases/Postgresql/install.md new file mode 100644 index 0000000..1884897 --- /dev/null +++ b/Databases/Postgresql/install.md @@ -0,0 +1,56 @@ +# PostgreSQL Installation and Configuration Guide + +Follow these steps to install and configure PostgreSQL on your system: + +## Step 1: Update System Packages +Ensure your system's package list is up-to-date: + +```bash +sudo apt update +``` + +## Step 2: Install PostgreSQL +Install PostgreSQL and its additional utilities: + +```bash +sudo apt install postgresql postgresql-contrib +``` + +## Step 3: Start PostgreSQL Service +Start the PostgreSQL service: + +```bash +sudo systemctl start postgresql.service +``` + +## Step 4: Enable PostgreSQL to Start on Boot +Enable the PostgreSQL service to start automatically on system boot: + +```bash +sudo systemctl enable postgresql.service +``` + +## Step 5: Switch to the PostgreSQL User +Switch to the `postgres` system user to perform database administration tasks: + +```bash +sudo -i -u postgres +``` + +## Step 6: Access the PostgreSQL Command-Line Interface +Start the `psql` command-line interface: + +```bash +psql +``` + +## Step 7: Configure PostgreSQL +Edit the PostgreSQL configuration file: + +```bash +vim /etc/postgresql/14/main/postgresql.conf +``` + +--- + +**Note:** Replace `14` in the file path above with your PostgreSQL version number, if it's different. From 2f2706db487d8109545e3856b0441aa8dca79350 Mon Sep 17 00:00:00 2001 From: radinpirouz Date: Sun, 2 Feb 2025 16:07:34 +0330 Subject: [PATCH 3/3] Kubernetets: update Command Doc --- .../Kubernetes/3-Commands.md | 243 ++++++++++++++---- 1 file changed, 192 insertions(+), 51 deletions(-) diff --git a/Containerization & Orchestration/Kubernetes/3-Commands.md b/Containerization & Orchestration/Kubernetes/3-Commands.md index 9817309..5c36378 100755 --- a/Containerization & Orchestration/Kubernetes/3-Commands.md +++ b/Containerization & Orchestration/Kubernetes/3-Commands.md @@ -1,67 +1,124 @@ -# Kubernetes -## `kubectl` Command Reference -### Get State of API Resources -```bash -kubectl api-resources -``` +# Kubernetes Command Reference + +This document provides a reference for common `kubectl` commands used for managing Kubernetes clusters. Use the examples and explanations below to help manage nodes, namespaces, pods, deployments, and more. + +## Table of Contents + +- [Kubernetes Command Reference](#kubernetes-command-reference) + - [Table of Contents](#table-of-contents) + - [General Commands](#general-commands) + - [Node Management](#node-management) + - [Namespace Management](#namespace-management) + - [Pod Management](#pod-management) + - [Listing Pods](#listing-pods) + - [Running a Pod](#running-a-pod) + - [Deleting a Pod](#deleting-a-pod) + - [API Resources and Documentation](#api-resources-and-documentation) + - [Logs and Pod Information](#logs-and-pod-information) + - [Applying YAML Files](#applying-yaml-files) + - [Managing Nodes and Labels](#managing-nodes-and-labels) + - [Viewing Cluster Resources](#viewing-cluster-resources) + - [ReplicaSet and Deployment Management](#replicaset-and-deployment-management) + - [Additional Information](#additional-information) + +--- + +## General Commands + +- **List API Resources** + + ```bash + kubectl api-resources + ``` + +--- + +## Node Management + +- **Show all nodes** -### Node Management -- **Show all nodes:** ```bash kubectl get node ``` -### Namespace Management -- **List all namespaces:** +- **Set a label on a node** + + ```bash + kubectl label nodes kubernetes.io/= + ``` + +--- + +## Namespace Management + +- **List all namespaces** + ```bash kubectl get namespaces - ``` - ```bash + # or the abbreviated version: kubectl get ns ``` -- **Create a custom namespace:** + +- **Create a custom namespace** + ```bash kubectl create ns ``` -### Pod Management -- **Get the list of pods in the default namespace:** +--- + +## Pod Management + +### Listing Pods + +- **List pods in the default namespace** + ```bash kubectl get pod ``` -- **Get the list of pods in the default namespace with full information:** + +- **List pods with detailed information (wide output) in the default namespace** + ```bash kubectl get pod -o wide ``` -- **Get the list of pods in a custom namespace with full information:** + +- **List pods with detailed information in a specific namespace** + ```bash - kubectl get pod -o wide -n + kubectl get pod -o wide -n ``` ### Running a Pod -- **Run a new pod:** + +- **Run a new pod** + + Use the following command structure to run a pod with various options: + ```bash - kubectl run { - --image=, # Specifies the container image to use - --port=, # Specifies the port that the container exposes - -n , # Specifies the namespace - --env="KEY=VALUE", # Sets environment variables in the container - --command, # Treats the rest of the arguments as the command to run in the container - --replicas=, # Specifies the number of replicas for the deployment - --labels="key=value,key2=value2", # Adds labels to the pod(s) - --dry-run=client, # Prints the object that would be sent, without creating it - --restart=, # Determines the restart policy for the pod - --overrides='', # Provides a JSON override for the generated object - --image-pull-policy=, # Specifies the image pull policy (Always, IfNotPresent, Never) - --limits=cpu=,memory=, # Specifies resource limits for the container - --requests=cpu=,memory= # Specifies resource requests for the container - } + kubectl run { + --image=, # Container image to use + --port=, # Port that the container exposes + -n , # Namespace in which to run the pod + --env="KEY=VALUE", # Environment variables for the container + --command, # Treat the following arguments as the command + --replicas=, # Number of pod replicas to create + --labels="key=value,key2=value2", # Labels to assign to the pod(s) + --dry-run=client, # Print the object without creating it + --restart=, # Pod restart policy + --overrides='', # JSON override for the generated object + --image-pull-policy=, # Image pull policy (Always, IfNotPresent, Never) + --limits=cpu=,memory=, # Resource limits for the container + --requests=cpu=,memory= # Resource requests for the container + } ``` - - *Example:* + + - **Example:** + ```bash - kubectl run mypod --image=nginx --port=80 -n mynamespace \ + kubectl run mypod --image=nginx --port=80 -n mynamespace \ --env="ENV_VAR_NAME=VALUE" --command -- nginx -g "daemon off;" \ --replicas=3 --labels="app=myapp,env=prod" --dry-run=client \ --restart=Always --overrides='{"spec": {"containers": [{"name": "nginx", "image": "nginx"}]}}' \ @@ -69,34 +126,118 @@ kubectl api-resources --requests=cpu=50m,memory=128Mi ``` - ### Deleting a Pod -- **Delete a pod in a custom namespace:** + +- **Delete a pod in a custom namespace** + ```bash kubectl delete pod -n ``` -### API Resource Documentation -- **Get documentation of an API resource:** +--- + +## API Resources and Documentation + +- **Get documentation for an API resource** + ```bash kubectl explain ``` + - *Example:* + ```bash kubectl explain pod ``` -### Logging and Pod Information -- **Get and follow logs of a pod (pod must be created and running):** +--- + +## Logs and Pod Information + +- **Stream logs for a running pod** + ```bash - kubectl logs -f -n - ``` -- **Get logs and state information of a pod (works at any time):** - ```bash - kubectl describe pod -n + kubectl logs -f -n ``` -### Apply Yaml File -```bash -kubectl apply -f -n -``` \ No newline at end of file +- **Get detailed state and log information for a pod** + + ```bash + kubectl describe pod -n + ``` + +--- + +## Applying YAML Files + +- **Apply configuration from a YAML file to a specific namespace** + + ```bash + kubectl apply -f -n + ``` + +--- + +## Managing Nodes and Labels + +- **Label a node with a custom key-value pair** + + ```bash + kubectl label nodes kubernetes.io/= + ``` + +--- + +## Viewing Cluster Resources + +- **Display all resources loaded in a namespace** + + ```bash + kubectl get all -n + ``` + +- **Display replica sets, pods, and deployments in a specific namespace** + + ```bash + kubectl get rs,pod,deployment -n + ``` + +--- + +## ReplicaSet and Deployment Management + +- **Scale a ReplicaSet** + + ```bash + kubectl scale rs -n --replicas= + ``` + +- **View rollout history of a deployment** + + ```bash + kubectl rollout history deployment -n + ``` + +- **View details of a specific revision in a deployment's rollout history** + + ```bash + kubectl rollout history deployment -n --revision + ``` + +- **Roll back a deployment to a specific revision** + + ```bash + kubectl rollout undo deployment -n --to-revision= + ``` + + > **Note:** The command for rolling back to a specific revision is `kubectl rollout undo` rather than using `--to-revision` with `kubectl rollout history`. + +--- + +## Additional Information + +- **Static Manifest Files** + + All YAML files located under `/etc/kubernetes/manifests/` are automatically loaded after a server reboot. + +---