Skip to content

Instantly share code, notes, and snippets.

View kholisrag's full-sized avatar

Kholis Respati Agum Gumelar kholisrag

  • Indonesia
  • 07:47 (UTC +07:00)
View GitHub Profile
@kholisrag
kholisrag / generate-ssh-config-gcp-vm.sh
Last active March 22, 2024 04:17
Generate SSH Config to make alias with gcp vm instances Internal IPs
#!/bin/bash
# Set the project ID
PROJECT_ID="XXXXXXXXX"
# Get instance information in JSON format
gcloud compute instances list \
--project "${PROJECT_ID}" \
--format="json" > ./instances.json
@kholisrag
kholisrag / check-cronjob.sh
Last active January 18, 2024 10:13
List All CronJob in an List of Instances defined in `instances.cfg` with gcloud compute network tags
#!/bin/bash
instance_list="instances.cfg"
date=$(date +'%FT%TZ')
mkdir -pv $(pwd)/cronjob-logs
mkdir -pv $(pwd)/cronjob-logs/$date
while read instance_name <&3
do
echo "----------------------------------------------" 2>&1 | tee -a $(pwd)/cronjob-logs/$date/$instance_name-cronjob.log
@kholisrag
kholisrag / failed-alloc-counter.go
Created June 17, 2022 15:36
Failed Alloc Counter in All Nomad Job
package main
import (
"encoding/json"
"fmt"
"github.com/hashicorp/nomad/api"
"github.com/sirupsen/logrus"
)
@kholisrag
kholisrag / nomad-failed-alloc-checker.go
Created June 17, 2022 15:33
Checking All possible alloc events details when termination already occurs
package main
import (
"encoding/json"
"fmt"
"time"
"github.com/hashicorp/nomad/api"
"github.com/sirupsen/logrus"
)
@kholisrag
kholisrag / convert_yaml_to_one_line.md
Last active July 13, 2021 13:16
convert yaml file to one line, useful for kubectl patch --type=json

Pre-requisite :

  • Python3
  • Pip
pip3 install pyyaml

test.yaml

@kholisrag
kholisrag / gitlab_restore_project_variables.sh
Created August 11, 2020 19:41
Bash Script forRestore CI/CD Variables of a project, from json file
#!/bin/bash
init() {
PROJECT_ID=
GITLAB_PRIVATE_TOKEN=
}
restore_project_variables() {
while read project_var_key <&3 && \
read project_var_value <&4 && \
@kholisrag
kholisrag / gitlab_backup_and_delete_project_variables.sh
Last active August 11, 2020 19:41
Bash Script for Backup and Delete CI/CD Variables of a project, store it in json and conf file
#!/bin/bash
init() {
PROJECT_ID=
GITLAB_PRIVATE_TOKEN=
touch ./backup_envar_${PROJECT_ID}.conf
touch ./backup_envar_${PROJECT_ID}.json
}
backup_and_delete_project_variables() {
@kholisrag
kholisrag / gitlab_project_variables_import.sh
Created August 11, 2020 17:56
Bash Script for Import CI/CD Variables from one project to another project
#!/bin/bash
init() {
SOURCE_PROJECT_ID=
TARGET_PROJECT_ID=
GITLAB_PRIVATE_TOKEN=
}
import_project_variables() {
while read project_var_key <&3 && \
@kholisrag
kholisrag / gitlab_group_variables_import.sh
Last active August 11, 2020 17:57
Bash Script for Import CI/CD Variables from one group to another group
#!/bin/bash
init() {
SOURCE_GROUP_ID=
TARGET_GROUP_ID=
GITLAB_PRIVATE_TOKEN=
}
import_group_variables() {
while read group_var_key <&3 && \
@kholisrag
kholisrag / install_helm3.sh
Created February 5, 2020 23:11
Get Latest Helm3 (Bash script / shell script)
#!/bin/bash
function install_helm() {
echo "Install helm3 latest version"
curl -fsSL -o get_helm.sh https://raw.githubusercontent.com/helm/helm/master/scripts/get-helm-3
chmod +x get_helm.sh
./get_helm.sh
}
function main () {