Skip to content

Instantly share code, notes, and snippets.

@esys
esys / gcrgc.sh
Last active April 15, 2021 15:10
google container registry cleanup script #gcp #gcr #docker
#!/bin/bash
# Copyright © 2017 Google Inc.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
@esys
esys / gist:ef0d6aa8b8dd2b10f758106a186365df
Created December 7, 2020 08:30
Get shell export variables command from a kubernetes pod environment variables
kubectl get deploy some-deployment -ojsonpath='{.spec.template.spec.containers[0].env}' | jq -r '.[] | "export " + join("=")'
# export VAR1=v1
# export VAR2=v2
# export VAR3=v3
@esys
esys / test.sh
Created November 3, 2020 17:56
pre-commit git sops hook test2
$ sops -d -i my-secrets.yaml
$ git add my-secrets.yaml && git commit -m "commit with unencrypted secret"
💥 File env/bel1/c1/helm_vars/my-secrets.yaml has non encrypted secrets!
🤔 Do you still want to commit? (y|Y to commit) n
aborted
@esys
esys / pre-commit.sh
Last active November 18, 2020 08:57
sops pre-commit git hook
#!/bin/bash
# directories containing potential secrets
DIRS="env/bel1/c1/helm_vars env/bel1/c2/helm_vars env/dev/helm_vars"
bold=$(tput bold)
normal=$(tput sgr0)
# allow to read user input, assigns stdin to keyboard
exec < /dev/tty
@esys
esys / Dockerfile
Created October 27, 2020 15:54
Python Flask HelloWorld Dockerfile
FROM python:3.7-alpine as builder
# install dependencies required to build python packages
RUN apk update && apk add --no-cache make gcc && pip install --upgrade pip
# setup venv and download or build dependencies
ENV VENV="/venv"
ENV PATH="${VENV}/bin:${PATH}"
@esys
esys / hello.py
Created October 27, 2020 15:52
Python Flask hello world
from flask import Flask
app = Flask(__name__)
@app.route('/')
def hello_world():
return 'Hello, World!'
@esys
esys / .gitlab-ci.yaml
Last active October 28, 2020 08:21
gitlab pipeline with external docker dind
stages:
- build
- test
- deploy
variables:
# disable Docker TLS validation
DOCKER_TLS_CERTDIR: ""
# here the dind hostname is resolved as the Kubernetes dind service by the kube dns
DOCKER_HOST: "tcp://dind:2375"
@esys
esys / dind.yaml
Created October 27, 2020 14:06
dind service in kubernetes
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
labels:
app: docker-dind
name: dind
spec:
accessModes:
- ReadWriteOnce
resources:
@esys
esys / gitlab-build-docker-push-builder.yaml
Last active October 28, 2020 14:07
gitlab with build and push builder stage
stages:
- build
- test
- deploy
variables:
# disable Docker TLS validation
DOCKER_TLS_CERTDIR: ""
DOCKER_HOST: "tcp://localhost:2375"
@esys
esys / gitlab-build-docker-remote-cache.yaml
Last active October 28, 2020 08:21
gitlab pipeline with remote cache
stages:
- build
- test
- deploy
variables:
# disable Docker TLS validation
DOCKER_TLS_CERTDIR: ""
DOCKER_HOST: "tcp://localhost:2375"