Skip to content

Instantly share code, notes, and snippets.

View Lefthander's full-sized avatar

Sergey Olisov Lefthander

  • Align technology
  • Moscow, Russia
View GitHub Profile
@Lefthander
Lefthander / battery.py
Created May 8, 2021 09:25 — forked from lloeki/battery.py
Battery status script for Mac OS X
#!/usr/bin/env python
from __future__ import print_function
from __future__ import division
from subprocess import Popen, PIPE
def ioreg_battery_info():
output = Popen(["ioreg", "-r", "-k", "LegacyBatteryInfo", "-w", "0"], stdout=PIPE).communicate()[0]
try: #python3
@Lefthander
Lefthander / kubectl-cs.md
Created April 30, 2021 07:25 — forked from luebken/kubectl-cs.md
Kubectl Cheatsheet
# start up a cluster
KUBERNETES_PROVIDER=vagrant ./cluster/kube-up.sh

# start a simple vagrant cluster
NUM_NODES=1 KUBERNETES_PROVIDER=vagrant KUBE_ENABLE_CLUSTER_MONITORING=none KUBE_ENABLE_CLUSTER_UI=false ./cluster/kube-up.sh

# validate cluster 
./cluster/validate-cluster.sh
kubectl cluster-info
@Lefthander
Lefthander / ssm_parameter_store.py
Created April 30, 2021 07:13 — forked from nqbao/ssm_parameter_store.py
Python class to provide a dictionary-like interface to access AWS SSM Parameter Store easily
# Copyright (c) 2018 Bao Nguyen <[email protected]>
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all
@Lefthander
Lefthander / pytest_fixture_mock_moto_lambda.py
Created March 30, 2021 14:45 — forked from mikegrima/pytest_fixture_mock_moto_lambda.py
pytest fixture to mock out the moto AWS Lambda capability such that it DOES NOT try to execute the code in a Docker container
import pytest
import moto
from mock import mock, patch
from moto import mock_lambda
@pytest.fixture(scope='function')
def aws_credentials():
"""Mocked AWS Credentials for moto."""
@Lefthander
Lefthander / kubernetes_job_example.py
Created February 19, 2021 13:21 — forked from seandavi/kubernetes_job_example.py
example of kubernetes batch job with env variables and secrets
"""
Creates, updates, and deletes a job object.
"""
from os import path
import os
import yaml
import uuid
apiVersion: apps/v1
kind: DaemonSet
metadata:
name: fluent-bit
namespace: default
labels:
k8s-app: fluent-bit-logging
spec:
selector:
matchLabels:
@Lefthander
Lefthander / kubernetes_api_exec.py
Created November 1, 2020 11:55 — forked from ahmetkotan/kubernetes_api_exec.py
Run command on container from another container on same pod with kubernetes api
from kubernetes import client
from kubernetes.stream import stream
import os
import sys
if len(sys.argv) < 4:
print(f"Usage: {sys.argv[0]} <pod_name> <container_name> <command>")
sys.exit(1);
@Lefthander
Lefthander / disk_available_least.py
Created May 22, 2020 13:34 — forked from JCallicoat/disk_available_least.py
Overview and code dive showing how disk_available_least is calculated
"""
How disk_available_least is calculated
======================================
Summary:
The nova-scheduler uses disk_available_least on the host to determine if there is enough space to boot / migrate / resize and instance of a given flavor.
This is the calculation scheduler uses: