Skip to content

Instantly share code, notes, and snippets.

View Voronenko's full-sized avatar
turning coffee into code since late 90s

Vyacheslav Voronenko

turning coffee into code since late 90s
View GitHub Profile
@Voronenko
Voronenko / mac_restart_docker.shell
Created May 24, 2021 12:28
for mac restart docker:
➜ ~ launchctl list | grep docker
- 0 com.docker.helper
1990 0 application.com.docker.docker.715810.716504
➜ ~ launchctl stop application.com.docker.docker.715810.716504 && launchctl start application.com.docker.docker.715810.716504
#!/bin/bash
scriptSource="${BASH_SOURCE[0]}"
while [[ -h "${scriptSource}" ]]; do # resolve ${scriptSource} until the file is no longer a symlink
sourceDir="$( cd -P "$( dirname "${scriptSource}" )" >/dev/null 2>&1 && pwd )"
scriptSource="$(readlink "${scriptSource}")"
[[ ${scriptSource} != /* ]] && scriptSource="${sourceDir}/${scriptSource}" # if ${scriptSource} was a relative symlink, we need to resolve it relative to the path where the symlink file w$
done
version: '3.8'
services:
cadvisor:
image: gcr.io/cadvisor/cadvisor:latest
restart: always
volumes:
- /:/rootfs:ro
- /var/run:/var/run:ro
- /sys:/sys:ro
- /var/lib/docker/:/var/lib/docker:ro
@Voronenko
Voronenko / md5-caching-gitlab.yaml
Created April 8, 2021 09:41
Cache based on file contents in gitlab
cache:
- key:
files:
- Gemfile.lock
paths:
- vendor/ruby
- key:
files:
- yarn.lock
paths:
# GCP
Host bastion-projectname
ProxyCommand sh -c "gcloud compute ssh --tunnel-through-iap --project PROJECTNAME --zone ZONENAME %h --command='nc 0.0.0.0 22'"
StrictHostKeyChecking no
#UserKnownHostsFile /dev/null
ForwardAgent no
ForwardX11 no
# Uncomment option below to use bastion as SSH proxy only
#RequestTTY no
ExitOnForwardFailure yes
@Voronenko
Voronenko / aws_billing_policies.tf
Created March 3, 2021 09:10
AWS Policies to grant IAM user to view billing data
// https://docs.aws.amazon.com/awsaccountbilling/latest/aboutv2/billing-permissions-ref.html
data "aws_iam_policy_document" "BillingViewAccess" {
statement {
actions = [
"aws-portal:ViewAccount",
"aws-portal:ViewBilling",
"aws-portal:ViewPaymentMethods",
"aws-portal:ViewUsage",
"budgets:ViewBudget",
"ce:DescribeNotificationSubscription",
from requests.adapters import HTTPAdapter
from requests.packages.urllib3.util.retry import Retry
retry_strategy = Retry(
total=3,
status_forcelist=[429, 500, 502, 503, 504],
method_whitelist=["HEAD", "GET", "OPTIONS"]
)
adapter = HTTPAdapter(max_retries=retry_strategy)
http = requests.Session()
Собираем helm-чарт в gitlab-ci и пушим в docker registry
Используем экспериментальную фичу с oci-registry в которую научился хелм. Это значит что мы можем чарты теперь просто пушить рядом с контейнерами докера с таким же именованием и тегированием.
deploy_helm:
stage: deploy
image: docker:18-dind
services:
- docker:18-dind
environment: { name: production }
tags: [docker]
only:
@Voronenko
Voronenko / backend.tf
Created February 23, 2021 10:14
multi region tf backend
terraform {
backend "s3" {
bucket = "specify"
key = "terraform/project/prod/terraform.tfstate"
profile = "specify"
region = "eu-central-1"
endpoint = "s3.eu-central-1.amazonaws.com"
}
}