Skip to content

Instantly share code, notes, and snippets.

Avatar
🎓
Still Learning

Gilang Virga Perdana gilangvperdana

🎓
Still Learning
View GitHub Profile
@gilangvperdana
gilangvperdana / registry-minio.md
Created March 26, 2023 14:05 — forked from leanderjanssen/registry-minio.md
Docker Registry with Minio storage example
View registry-minio.md

Running a docker registry with Minio S3 backend

Run minio in a container

docker run -d -p 9000:9000 --name minio minio/minio server /export

Use docker logs to retrieve access key and secret key from minio container

docker logs minio

Create config.yml for Docker Registry

This file will have to be mounted to /etc/docker/registry/config.yml

@gilangvperdana
gilangvperdana / DecryptBase64.py
Created March 26, 2023 08:09
How to decrypt Base64 to Plaintext ?
View DecryptBase64.py
import base64
base64_message = 'BASE64' # pesan yang ingin di-decode
decoded_message = base64.b64decode(base64_message) # proses decoding
print(decoded_message.decode('utf-8')) # print hasil decoding
@gilangvperdana
gilangvperdana / nginx-minio-static.md
Last active March 24, 2023 08:00 — forked from harshavardhana/nginx-minio-static.md
How to configure static website using Nginx with MinIO ?
View nginx-minio-static.md

How to configure static website using Nginx with MinIO ?

1. Install nginx

2. Install minio

3. Install mc client

  • Add Minio
mc config host add <ALIAS> <YOUR-S3-ENDPOINT> <YOUR-ACCESS-KEY> <YOUR-SECRET-KEY>
mc config host list
@gilangvperdana
gilangvperdana / README.md
Last active March 20, 2023 07:08
Auto Backup File / Directory to S3 with S3CMD
View README.md

General

  • I have a case that is to backup Grafana where grafana.ini is located in /etc/grafana/grafana.ini in the form of a single file and /var/lib/grafana/ is in the form of a directory to be backed up to S3 (here I use minio).
  • In this script the file will be kept for 3 days and will be replaced every 12-hours every day with crontab 0 */12 * * *.
  • And of course when the backup is successful it will send an alert to the telegram bot that is if the file number is 2 correctly (you can adjust it in the -eq 2 section).

Script

#!/bin/bash

# set variable
@gilangvperdana
gilangvperdana / README.md
Last active March 22, 2023 09:11
Setup Proxmox Exporter & Visualize it to Grafana
View README.md

General

Here is my experience installing Exporter on Proxmox and visualizing it on Grafana.

Install PVE Exporter

python3 -m pip install prometheus-pve-exporter

Add User

@gilangvperdana
gilangvperdana / README.md
Last active March 14, 2023 08:17
Reset Ubuntu Root Password from Openstack Console (VNC)
View README.md

General

I get a case that I have to log in to an instance on Openstack without going through the instance IP (because it can't be reached) so I have to try to enter from the console for troubleshooting in the OS. Here's one of my ways to log in using the root user on Ubuntu Server 20.04 LTS running on top of Openstack.

Goes to VNC

  • Goes to Horizon -> Project -> Instance -> Click on your Instance -> Console.
  • If you doesn't have access to Horizon, you can use virsh console but will not shows in here.

Execution

  • Click on SendCtrlAltDel
  • while rebooting from the beginning immediately press esc repeatedly until it enters the boot order menu
@gilangvperdana
gilangvperdana / README.md
Last active March 14, 2023 04:09
Automaticly Enable Disable Swap Based on Utilization of RAM Usage on Linux
View README.md

General

  • I have a case on a server host where when enabling swap it increases IOwait (because of slow disk) but on the other hand it is the most reliable host (so it often runs out of RAM). This prompted me to automate the use of swap when there is only certain RAM.
  • In this script it is possible to execute swapon /swapfile when the RAM threshold reaches 90% while swap is immediately turned off swapoff -a when RAM is below 80%
  • Besides this script executing predetermined commands regarding swap, this script will also report to the BOT telegram.

Script.sh

#!/bin/bash

# Set the threshold for activating and deactivating swap
@gilangvperdana
gilangvperdana / README.md
Last active March 9, 2023 11:34
Search Instance Identity with Bashscript
View README.md

Goals

  • Make bash script to search Instances on Openstack

Script.sh

#!/bin/bash

export OS_PROJECT_DOMAIN_NAME=Default
export OS_USER_DOMAIN_NAME=Default
export OS_PROJECT_NAME=admin
View Ubuntu_Debian_Cloud_images_in_Proxmox.md
@gilangvperdana
gilangvperdana / README.md
Last active March 8, 2023 03:09
Openstack Alerting when any Instance Spwaned or Destroyed
View README.md

General

Script for alerting agent when a new Instance created or Destroyed on Openstack

Script.sh

#!/bin/bash

# Telegram
BOT_TOKEN="$BOTTOKEN"
CHAT_ID="$YOURCHATID"