Skip to content

Commit

Permalink
init
Browse files Browse the repository at this point in the history
  • Loading branch information
dylankyc authored and dylan committed Dec 18, 2024
0 parents commit d08d9a5
Show file tree
Hide file tree
Showing 54 changed files with 14,191 additions and 0 deletions.
54 changes: 54 additions & 0 deletions .github/workflows/mdbook.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
# Sample workflow for building and deploying a mdBook site to GitHub Pages
#
# To get started with mdBook see: https://rust-lang.github.io/mdBook/index.html
#
name: Deploy mdBook site to Pages
on:
# Runs on pushes targeting the default branch
push:
branches: ["main"]
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
permissions:
contents: read
pages: write
id-token: write
# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued.
# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete.
concurrency:
group: "pages"
cancel-in-progress: false
jobs:
# Build job
build:
runs-on: ubuntu-latest
env:
MDBOOK_VERSION: 0.4.43
steps:
- uses: actions/checkout@v4
- name: Install mdBook
run: |
curl --proto '=https' --tlsv1.2 https://sh.rustup.rs -sSf -y | sh
rustup update
cargo install --version ${MDBOOK_VERSION} mdbook
- name: Setup Pages
id: pages
uses: actions/configure-pages@v5
- name: Build with mdBook
run: mdbook build
- name: Upload artifact
uses: actions/upload-pages-artifact@v3
with:
path: ./book
# Deployment job
deploy:
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
runs-on: ubuntu-latest
needs: build
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
book
Binary file added .img/import-orders-from-schema.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added .img/import-orders.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 6 additions & 0 deletions book.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[book]
authors = ["dylan"]
language = "en"
multilingual = false
src = "src"
title = "Dylan's Blog"
5 changes: 5 additions & 0 deletions run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/bash

mdbook serve

# open localhost:3000
59 changes: 59 additions & 0 deletions src/SUMMARY.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
# Summary

# Solana

- [Quickstart]()
- [使用 TypeScript 创建账户](solana/quickstart/使用TypeScript创建账户.md)
- [不使用 Anchor 开发 solana program(Native Program)](solana/quickstart/不使用Anchor开发solana的program.md)

# React

- [Functional Component]()
- [Render all chartjs charts in react typescript tailwindcss projects](react/functional-component/render-all-chartjs-charts.md)

# Rust

- [GRPC]()
- [Rust grpc helloworld](rust/grpc/rust-grpc-helloworld.md)
- [Diesel]()
- [Upgrade diesel to 2.0](rust/diesel/upgrade-diesel-to-2.0.md)
- [Use jsonb in diesel](rust/diesel/use-jsonb-in-diesel.md)
- [Tokio]()
- [Tokio Codec](rust/tokio/tokio-codec.md)
- [Async Healthcheck Multiple Endpoints](rust/tokio/async-healthcheck-multiple-endpoints.md)
- [Actix]()
- [prometheus support for actix-web project](rust/actix/prometheus-support-to-actix-web.md)
- [Send Http Request in Handle function And started function When Using Actix crate](rust/actix/send-http-request-in-handle-function-and-started-function-when-using-actix-crate.md)
- [Serde]()
- [Serialize time::OffsetDataTime type using serde_as in serde_with crate](rust/serde/serialize-time-offsetdatetime-type-using-serde-as-in-serde-with-crate.md)
- [Error]()
- [How to organise application Error in actix-web application](rust/error/how-to-organise-application-error-in-actix-web-application.md)
- [Return error when unwrap Option when None](rust/error/return-error-when-unwrap-option-when-none.md)

# MUI

- [Upgrade]()
- [Upgrade from v4 to v5](mui/upgrade/upgrade-from-v4-to-v5.md)

# Gitlab

- [Gitlab Runner]()
- [Register gitlab runner on Amazon Linux 2](gitlab/runner/register-gitlab-runner-on-amazon-linux-2.md)
- [Install gitlab runner on ubuntu](gitlab/runner/install-gitlab-runner-on-ubuntu.md)

# Terraform

- [Gitlab]()
- [Start Gitlab using Terraform](terraform/gitlab/start-gitlab-using-terraform.md)
- [Import]()
- [Manage DMS resource using terraform](terraform/import/terraform-import-dms-replication-instance-blog.md)
- [Review terraform import](terraform/import/review-terraform-import.md)
- [S3]()
- [一个 s3 bucket 分配权限的 terraform 管理介绍.md](terraform/s3/s3-bucket-permission-management-using-terraform.md)
- [Management]()
- [A Good Developer knows management](terraform/management/a-good-developer-knows-management.md)

# Kubernetes

- [CronJob]()
- [CronJob To Restart Deployment](kubernetes/cronjob/cronjob-to-restart-deployment.md)
222 changes: 222 additions & 0 deletions src/gitlab/runner/install-gitlab-runner-on-ubuntu.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,222 @@
# Install gitlab runner on ubuntu

- [Intro](#intro)
- [Check GPU info on instance](#check-gpu-info-on-instance)
- [Install gitlab runner](#install-gitlab-runner)
- [Register gitlab runner](#register-gitlab-runner)
- [Uninstall GitLab Runner](#uninstall-gitlab-runner)
- [Start gitlab-runner in container](#start-gitlab-runner-in-container)
- [Gitlab runner token](#gitlab-runner-token)
- [Use local volume](#use-local-volume)
- [docker volume](#docker-volume)
- [Register gitlab runner in non-interactive mode](#register-gitlab-runner-in-non-interactive-mode)
- [stop gitlab-runner](#stop-gitlab-runner)
- [Refs](#refs)

# Intro

I've been using GitLab CI/CD for a while now, and I have to say that it's an amazing tool for code management and automating builds and deployments.

In this blog post, I'll share my experience installing and using GitLab Runner on Ubuntu with GPU instance.

## Check GPU info on instance

First, check the GPU info on the instance:

```bash
(base) smolai@smolai-Z790-UD-AX:~$ nvidia-smi
Mon Sep 18 15:57:06 2023
+-----------------------------------------------------------------------------+
| NVIDIA-SMI 525.116.04 Driver Version: 525.116.04 CUDA Version: 12.0 |
|-------------------------------+----------------------+----------------------+
| GPU Name Persistence-M| Bus-Id Disp.A | Volatile Uncorr. ECC |
| Fan Temp Perf Pwr:Usage/Cap| Memory-Usage | GPU-Util Compute M. |
| | | MIG M. |
|===============================+======================+======================|
| 0 NVIDIA GeForce ... Off | 00000000:01:00.0 Off | Off |
| 0% 35C P8 5W / 450W | 3754MiB / 24564MiB | 0% Default |
| | | N/A |
+-------------------------------+----------------------+----------------------+

+-----------------------------------------------------------------------------+
| Processes: |
| GPU GI CI PID Type Process name GPU Memory |
| ID ID Usage |
|=============================================================================|
| 0 N/A N/A 13290 C python 3752MiB |
+-----------------------------------------------------------------------------+
```

## Install gitlab runner

Next, we can install gitlab runner using the following command:

```bash
wget -qO - https://packages.gitlab.com/install/repositories/runner/gitlab-runner/script.deb.sh | sudo bash
sudo apt install -y gitlab-runner
```

## Register gitlab runner

After installation, we can register gitlab runner using the following command:

```bash
# register gitlab runner
sudo gitlab-runner register \
--non-interactive \
--url "https://gitlab.planetsmol.com" \
--registration-token "glrt-ooooooiiiiiiiiii" \
--description "docker-runner" \
--executor "docker" \
--docker-image ubuntu:latest
```

Here is the output of the command:

```bash
Runtime platform arch=amd64 os=linux pid=74044 revision=f5dfa4d1 version=16.3.1
Running in system-mode.

Verifying runner... is valid runner=eooovvviii
Runner registered successfully. Feel free to start it, but if it's running already the config should be automatically reloaded!
Configuration (with the authentication token) was saved in "/etc/gitlab-runner/config.toml"
root@smolai:/tmp# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
registry.gitlab.com/gitlab-org/gitlab-runner/gitlab-runner-helper x86_64-f5dfa4d1 4af7e8dd8eb7 18 seconds ago 64.1MB
meet latest 7d62cb955a7f 5 weeks ago 915MB
busybox latest a416a98b71e2 2 months ago 4.26MB
```
## Uninstall GitLab Runner
If you want to completely remove GitLab Runner, run the following command:
```bash
# If you want to completely remove GitLab Runner, run the following command:
sudo apt purge --autoremove -y gitlab-runner
# Remove GPG key and repository:
sudo apt-key del 513111FF
sudo rm -rf /etc/apt/sources.list.d/runner_gitlab-runner.list
# Remove GitLab Runner user:
sudo deluser --remove-home gitlab-runner
#You can also remove GitLab Runner configuration:
sudo rm -rf /etc/gitlab-runner
```
# Start gitlab-runner in container
You have two options to start gitlab-runner in container.
To store gitlab-runner config in docker volume, you can either use docker volume or use local system volume.
After install gitlab-runner, you can start gitlab-runner in container.
You have to register gitlab runner after start gitlab-runner in container.
As the docs said:
> Runner registration is the process that links the runner with one or more GitLab instances. You must register the runner so that it can pick up jobs from the GitLab instance.
## Gitlab runner token
You have to obtain gitlab runner token from gitlab to register the runner.
Here is how to obtain the token from gitlab:
1. Login to gitlab
2. Click on the "Runners" button
3. Click on the "Tokens" button
4. Click on the "Create token" button
5. Copy the token
Notice, the gitlab runner authentication tokens have the prefix `glrt-`.
## Use local volume
Let's see how to use local system volume mounts to start the Runner container.

```bash
# Create the directory to mount the docker volume
mkdir -p /srv/gitlab-runner/config
# Start the GitLab Runner container
docker run -d --name gitlab-runner --restart always \
-v /srv/gitlab-runner/config:/etc/gitlab-runner \
-v /var/run/docker.sock:/var/run/docker.sock \
gitlab/gitlab-runner:latest
```

Now the runner is started, let's see how to register it.
```bash
docker run --rm -it -v /srv/gitlab-runner/config:/etc/gitlab-runner gitlab/gitlab-runner register
```
## docker volume
If you want to use docker volume to start the Runner container, you can use the following command:
```bash
# Create the Docker volume
docker volume create gitlab-runner-config
# Start the GitLab Runner container using the volume we just created
docker run -d --name gitlab-runner --restart always \
-v /var/run/docker.sock:/var/run/docker.sock \
-v gitlab-runner-config:/etc/gitlab-runner \
gitlab/gitlab-runner:latest
```
# Register gitlab runner in non-interactive mode
You can use non-interactive mode to register the runner, refer to https://docs.gitlab.com/runner/commands/index.html#non-interactive-registration for more details.
If you want to register the runner on linux, you can use the following command:
```bash
sudo gitlab-runner register \
--non-interactive \
--url "https://gitlab.com/" \
--token "$RUNNER_TOKEN" \
--executor "docker" \
--docker-image alpine:latest \
--description "docker-runner"
```
If you want to register the runner through docker, you can use the following command:
```bash
docker run --rm -v /srv/gitlab-runner/config:/etc/gitlab-runner gitlab/gitlab-runner register \
--non-interactive \
--executor "docker" \
--docker-image alpine:latest \
--url "https://gitlab.com/" \
--token "$RUNNER_TOKEN" \
--description "docker-runner"
```
# stop gitlab-runner
To stop the gitlab-runner container, you can use the following command:
```bash
docker stop gitlab-runner && docker rm gitlab-runner
```
# Refs
Install
https://lindevs.com/install-gitlab-runner-on-ubuntu
Install gitlab runner
https://docs.gitlab.com/runner/install/docker.html
Another install doc
https://docs.gitlab.com/runner/install/linux-repository.html
Register runner
https://docs.gitlab.com/runner/register/index.html#docker
Loading

0 comments on commit d08d9a5

Please sign in to comment.