Skip to content

Instantly share code, notes, and snippets.

View vlobachev's full-sized avatar
🏘️
academic approaches

Vitaly Lobachev vlobachev

🏘️
academic approaches
View GitHub Profile
@vlobachev
vlobachev / delete-git-recursively.sh
Created November 30, 2023 16:41 — forked from facelordgists/delete-git-recursively.sh
Recursively remove .git folders
( find . -type d -name ".git" && find . -name ".gitignore" && find . -name ".gitmodules" ) | xargs rm -rf
@vlobachev
vlobachev / gist:87265eacb1537527a0f11abd468567bd
Last active January 30, 2023 19:58
AWS EKS Cost optimisation
https://aws.amazon.com/blogs/containers/cost-optimization-for-kubernetes-on-aws/
https://docs.aws.amazon.com/eks/latest/userguide/cost-monitoring.html
To find all local storages:
kubectl get pods --all-namespaces -o=json | jq -c '.items[] | {name: .metadata.name, namespace: .metadata.namespace, claimName: .spec | select( has ("volumes") ).volumes[] | select( has ("persistentVolumeClaim") ).persistentVolumeClaim.claimName }'
Istio resources:
kubectl -n istio-system get istiooperators.install.istio.io installed-state -o json | jq .spec.values.global.proxy.resources
@vlobachev
vlobachev / gist:f6a6e451d8bee8432312c68d3134ddaf
Created January 10, 2023 13:35
How to delete k8s resources with finalizers
kubectl patch configmap/mymap \
--type json \
--patch='[ { "op": "remove", "path": "/metadata/finalizers" } ]'

Upgrading Kubernetes Cluster with Kops, and Things to Watch Out For

Alright! I'd like to apologize for the inactivity for over a year. Very embarrassingly, I totally dropped the good habit. Anyways, today I'd like to share a not so advanced and much shorter walkthrough on how to upgrade Kubernetes with kops.

At Buffer, we host our own k8s (Kubernetes for short) cluster on AWS EC2 instances since we started our journey before AWS EKS. To do this effectively, we use kops. It's an amazing tool that manages pretty much all aspects of cluster management from creation, upgrade, updates and deletions. It never failed us.

How to start?

Okay, upgrading a cluster always makes people nervous, especially a production cluster. Trust me, I've been there! There is a saying, hope is not a strategy. So instead of hoping things will go smoothly, I always have bias that shit will hit the fan if you skip testing. Plus, good luck explaining to people

@vlobachev
vlobachev / restoreMongo_bucket.sh
Created October 31, 2022 17:09 — forked from njadhav1/restoreMongo_bucket.sh
Restore MongoDB backup from AWS S3
#!/bin/bash
########
# Purpose :- To Restore backup of MongoDB Collections from AWS s3
# Requirement :- Make Sure you took backup via backupMongo_bucket.sh
# Bug Report to :- jadhav.nitin941@gmail.com
########
PROGNAME=$(basename $0)
[ec2-user ~]$ lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
xvdf 202:80 0 100G 0 disk
xvda1 202:1 0 8G 0 disk /
The output of lsblk removes the /dev/ prefix from full device paths. In this example, /dev/xvda1 is mounted as the root device (note the MOUNTPOINT is listed as /, the root of the Linux file system hierarchy), and /dev/xvdf is attached, but it has not been mounted yet.
Determine whether you need to create a file system on the volume. New volumes are raw block devices, and you need to create a file system on them before you can mount and use them. Volumes that have been restored from snapshots likely have a file system on them already; if you create a new file system on top of an existing file system, the operation overwrites your data. Use the sudo file -s device command to list special information, such as file system type.
[ec2-user ~]$ sudo file -s /dev/xvdf
/dev/xvdf: data
Ansible playbook to setup HTTPS using Let's encrypt on nginx.
The Ansible playbook installs everything needed to serve static files from a nginx server over HTTPS.
The server pass A rating on [SSL Labs](https://www.ssllabs.com/).
To use:
1. Install [Ansible](https://www.ansible.com/)
2. Setup an Ubuntu 16.04 server accessible over ssh
3. Create `/etc/ansible/hosts` according to template below and change example.com to your domain
4. Copy the rest of the files to an empty directory (`playbook.yml` in the root of that folder and the rest in the `templates` subfolder)
@vlobachev
vlobachev / repo-full-copy.sh
Created February 18, 2022 11:38 — forked from AgiosAndreas/repo-full-copy.sh
Полный перенос git репозитория на другой сервер
# Клонируем исходный репозиторий без рабочего каталога (--bare)
git clone --bare https://github.com/exampleuser/old-repository.git
cd old-repository.git
# Делаем mirror-push(будут скопированы все ветки и тэги) в новый репозиторий
git push --mirror https://github.com/exampleuser/new-repository.git
cd ..
# Удаляем папку с репозиторием
@vlobachev
vlobachev / README.md
Created August 3, 2020 10:01 — forked from danielepolencic/README.md
Create 3 nodes Kubernetes cluster locally with Vagrant

3 Virtual Machines Kubernetes cluster

Dependencies

You should install VirtualBox and Vagrant before you start.

Creating the cluster

You should create a Vagrantfile in an empty directory with the following content:

@vlobachev
vlobachev / docker-compose.yml
Created June 30, 2020 08:48 — forked from thomasdarimont/docker-compose.yml
Docker OpenLDAP + phpldapadmin example
version: '2'
services:
openldap:
image: osixia/openldap:1.2.3
container_name: openldap
environment:
LDAP_LOG_LEVEL: "256"
LDAP_ORGANISATION: "Example Inc."
LDAP_DOMAIN: "example.org"
LDAP_BASE_DN: ""