Skip to content

Instantly share code, notes, and snippets.

View thammaratchok's full-sized avatar

Thammarat Chokwattanakit thammaratchok

View GitHub Profile
#!/bin/zsh
# Define the production context name
PRODUCTION_CONTEXT="PROD_CONTEXT"
# Get the current Kubernetes context
CURRENT_CONTEXT=$(kubectl config current-context)
# Define critical commands that require confirmation
CRITICAL_COMMANDS=("apply" "delete" "edit")
@thammaratchok
thammaratchok / how-to-copy-aws-rds-to-local.md
Created April 20, 2022 08:44 — forked from syafiqfaiz/how-to-copy-aws-rds-to-local.md
How to copy production database on AWS RDS(postgresql) to local development database.
  1. Change your database RDS instance security group to allow your machine to access it.
    • Add your ip to the security group to acces the instance via Postgres.
  2. Make a copy of the database using pg_dump
    • $ pg_dump -h <public dns> -U <my username> -f <name of dump file .sql> <name of my database>
    • you will be asked for postgressql password.
    • a dump file(.sql) will be created
  3. Restore that dump file to your local database.
    • but you might need to drop the database and create it first
    • $ psql -U <postgresql username> -d <database name> -f <dump file that you want to restore>
  • the database is restored
@thammaratchok
thammaratchok / file1.txt
Created September 14, 2021 11:13
Created via API
Demo
@thammaratchok
thammaratchok / reloader.yaml
Last active May 8, 2021 05:58
Reloader on kube-system
# https://github.com/stakater/Reloader
---
# Source: reloader/templates/clusterrole.yaml
apiVersion: rbac.authorization.k8s.io/v1beta1
kind: ClusterRole
metadata:
annotations:
meta.helm.sh/release-namespace: "kube-system"
meta.helm.sh/release-name: "reloader"

progrium/bashstyle

Bash is the JavaScript of systems programming. Although in some cases it's better to use a systems language like C or Go, Bash is an ideal systems language for smaller POSIX-oriented or command line tasks. Here's three quick reasons why:

  • It's everywhere. Like JavaScript for the web, Bash is already there ready for systems programming.
  • It's neutral. Unlike Ruby, Python, JavaScript, or PHP, Bash offends equally across all communities. ;)
  • It's made to be glue. Write complex parts in C or Go (or whatever!), and glue them together with Bash.

This document is how I write Bash and how I'd like collaborators to write Bash with me in my open source projects. It's based on a lot of experience and time collecting best practices. Most of them come from these two articles, but here integrated, slightly modified, and focusing on the most bang for buck items. Plus some ne

Note for k8s the hard way
Tools
cfssl, cfssljson, and kubectl.
Provision servers
create vpc, subnet, internet gateway, route table, security group, nlb
create ssh key
create 3 controllers
create 3 workers
@thammaratchok
thammaratchok / k8s-cluster-kops
Created September 6, 2019 06:03
Create a simple k8s cluster in AWS using Kops
A quick guide to create k8s cluster in new VPC AWS using KOPS
Prerequisite:
- aws profile setup with these permissions
AmazonEC2FullAccess
AmazonRoute53FullAccess
AmazonS3FullAccess
IAMFullAccess
AmazonVPCFullAccess
- s3 bucket to keep kops state file
@thammaratchok
thammaratchok / iterm2-solarized.md
Created July 21, 2019 08:19 — forked from kevin-smets/iterm2-solarized.md
iTerm2 + Oh My Zsh + Solarized color scheme + Source Code Pro Powerline + Font Awesome + [Powerlevel10k] - (macOS)

Default

Default

Powerlevel10k

Powerlevel10k

@thammaratchok
thammaratchok / capybara cheat sheet
Last active September 20, 2015 05:14 — forked from zhengjia/capybara cheat sheet
capybara cheat sheet
=Navigating=
visit('/projects')
visit(post_comments_path(post))
=Clicking links and buttons=
click_link('id-of-link')
click_link('Link Text')
click_button('Save')
click('Link Text') # Click either a link or a button
click('Button Value')
<!DOCTYPE html>
<html><head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<!--Tradedoubler site verification 2380867 -->
<meta charset="utf-8">
<meta content="IE=edge,chrome=1" http-equiv="X-UA-Compatible">
<title>aim test commercial Juliet | ABC Nyheter</title>
<meta content="" name="description">