Skip to content

Instantly share code, notes, and snippets.

View AkashRajvanshi's full-sized avatar
😎
DevOps

Akash Rajvanshi AkashRajvanshi

😎
DevOps
View GitHub Profile
## Install Portainer
# Using Arkade ( Works on arm & amd64 )
# If Arkade shows cluster unreachable, use (kubectl config view --raw >~/.kube/config)
$ curl -sLS https://dl.get-arkade.dev | sudo sh
$ arkade install portainer
# Access Portainer UI on http://http://10.0.1.86:30777 ( Master Server IP : 10.0.1.86 )
# If you are using ( arm64 ( 64 bit OS on Rasps ))
$ curl -LO https://raw.githubusercontent.com/portainer/portainer-k8s/master/portainer-nodeport.yaml
# On Master Server
$ microk8s add-node
# It give join command like this: microk8s join 10.0.1.86:25000/6cae23f7273dc6700f439f8c19abc7de
# On Worker Nodes
$ microk8s join 10.0.1.86:25000/6cae23f7273dc6700f439f8c19abc7de
# To Check
$ microk8s kubectl get nodes
NAME STATUS ROLES AGE VERSION
# We use the headless OS, So we have no option to access services other than exposing to the internal network.
# By default Kubernetes dashboard is not accessible on the local network, but if you were using raspbionOS ( GUI ), you could access the clusterIP in your Raspberry pi.
# --Exposing--
$ kubectl -n kube-system edit service kubernetes-dashboard
# Change type: ClusterIP to NodePort
# Get service port
$ microk8s.kubectl --namespace=kube-system get service kubernetes-dashboard
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
# Do this on all the nodes ( Only the Installation step, Rest of the steps are for just master server )
## Install MicroK8s
$ sudo snap install microk8s --channel=1.19 --classic
# Add user to group microk8s & give user permission to ~/.kube
$ sudo usermod -a -G microk8s user
$ sudo chown -f -R user ~/.kube
--------------------------------------------------------------------------------------
# Do this on all of your nodes ( Rasps )
# Install Docker
$ curl -sSL https://get.docker.com | sh
--------------------------------------------------------------------------------------
## Enable cgroups (Control Groups). Cgroups allow the Linux kernel to limit and isolate resources.
# Practically speaking, this allows Kubernetes to manage better resources used by the containers it runs and increases security by isolating containers from one another.
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => General
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Sets how many lines of history VIM has to remember
set history=500
" Enable filetype plugins
filetype plugin on
filetype indent on
{
"editor.fontFamily": "Fira Code iScript",
"editor.detectIndentation": true,
"editor.renderIndentGuides": true,
"editor.formatOnSave": true,
"editor.formatOnPaste": true,
"editor.fontSize": 16,
"editor.lineHeight": 25,
"editor.fontWeight": "700",
"editor.tabSize": 2,
@AkashRajvanshi
AkashRajvanshi / postgres-dump-restore.markdown
Created June 9, 2020 08:08 — forked from jeremykendall/postgres-dump-restore.markdown
PostgreSQL: dump and restore (to db with different name and roles even)

Postgres Export and Import

Export

pg_dump -U [superuser] -Fc [dbname] > db.dump

Import

@AkashRajvanshi
AkashRajvanshi / mysql-docker.sh
Created June 6, 2020 05:22 — forked from spalladino/mysql-docker.sh
Backup and restore a mysql database from a running Docker mysql container
# Backup
docker exec CONTAINER /usr/bin/mysqldump -u root --password=root DATABASE > backup.sql
# Restore
cat backup.sql | docker exec -i CONTAINER /usr/bin/mysql -u root --password=root DATABASE
@AkashRajvanshi
AkashRajvanshi / run_RPI4B_from_SSD.md
Created June 2, 2020 07:43
Run a Raspberry Pi 4B from an SSD connected to a USB-3 port

Run Raspberry Pi 4 from SSD

Introduction

This gist builds on the excellent work done by Graham Garner, Andreas Spiess, and Peter Scargill to make it easy for Makers to install IOTstack on a Raspberry Pi.

One concern with any out-of-the-box Raspberry Pi is the limited lifespan of its SD card. You'd be pretty annoyed if you got your IOTstack up and running, only to find that you were one of the unlucky ones whose SD card wore out in less than six months!

SSDs, on the other hand, while not immune to the same kinds of failure, tend to have projected life expectancies in the hundreds of years.