Skip to content

Instantly share code, notes, and snippets.

View lvthillo's full-sized avatar

Lorenz Vanthillo lvthillo

View GitHub Profile
@lvthillo
lvthillo / SlackNotifier.groovy
Created March 19, 2018 17:56
Groovy function used in Jenkins pipeline to publish build result to Slack
#!/usr/bin/env groovy
def call(String buildResult) {
if ( buildResult == "SUCCESS" ) {
slackSend color: "good", message: "Job: ${env.JOB_NAME} with buildnumber ${env.BUILD_NUMBER} was successful"
}
else if( buildResult == "FAILURE" ) {
slackSend color: "danger", message: "Job: ${env.JOB_NAME} with buildnumber ${env.BUILD_NUMBER} was failed"
}
else if( buildResult == "UNSTABLE" ) {
@lvthillo
lvthillo / wait-for-it.sh
Created March 20, 2018 18:57
wait-for-it.sh to Check if MySQL service is running using environment variables
#!/bin/bash
set -e
host="$1"
shift
cmd="$@"
until mysql -hmysql -p"3306" -u"${database__connection__user}" -p"${database__connection__password}"
-D"${database__connection__database}" ; do
>&2 echo "MySQL is unavailable - sleeping"
sleep 1
done
@lvthillo
lvthillo / docker-compose.yaml
Created March 20, 2018 19:02
docker-compose.yaml to deploy a full Ghost - MySQL stack in Docker
version: '3.1'
volumes:
mysql-volume:
ghost-volume
services:
mysql:
image: mysql:5.7
container_name: mysql
volumes:
@lvthillo
lvthillo / jenkins-namespace.yaml
Created April 3, 2018 17:34
create jenkins namespace
apiVersion: v1
kind: Namespace
metadata:
name: jenkins-project
@lvthillo
lvthillo / jenkins-volume.yaml
Created April 3, 2018 17:40
Create persistent volume for jenkins in minikube
apiVersion: v1
kind: PersistentVolume
metadata:
name: jenkins-pv
namespace: jenkins-project
spec:
storageClassName: jenkins-pv
accessModes:
- ReadWriteOnce
capacity:
@lvthillo
lvthillo / openvpn-pv-claim.yaml
Created April 25, 2018 18:00
Persistent volume claim for OpenVPN
kind: PersistentVolumeClaim
apiVersion: v1
metadata:
name: openvpn-data-claim
namespace: openvpn
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
@lvthillo
lvthillo / values.yaml
Last active April 28, 2018 13:38
Values for OpenVPN Chart (Helm)
# Default values for openvpn.
# This is a YAML-formatted file.
# Declare variables to be passed into your templates.
replicaCount: 1
image:
repository: jfelten/openvpn-docker
tag: 1.1.0
pullPolicy: IfNotPresent
service:
name: openvpn
@lvthillo
lvthillo / get-certificate
Created April 28, 2018 15:03
Get .OVPN file by executing each line separately
# execute each line separately
POD_NAME=$(kubectl get pods --namespace openvpn -l type=openvpn -o jsonpath='{ .items[0].metadata.name }')
SERVICE_NAME=$(kubectl get svc --namespace openvpn -l type=openvpn -o jsonpath='{ .items[0].metadata.name }')
SERVICE_IP=$(kubectl get svc --namespace openvpn $SERVICE_NAME -o go-template='{{ range $k, $v := (index .status.loadBalancer.ingress 0)}}{{ $v }}{{end}}')
KEY_NAME=kubeVPN
kubectl --namespace openvpn exec -it $POD_NAME /etc/openvpn/setup/newClientCert.sh $KEY_NAME $SERVICE_IP
kubectl --namespace openvpn exec -it $POD_NAME cat /etc/openvpn/certs/pki/$KEY_NAME.ovpn > $KEY_NAME.ovpn
@lvthillo
lvthillo / policy-document-1.json
Last active December 23, 2018 17:58
AWS IAM Policy Document to allow user to assume role
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"iam:ListRoles",
"sts:AssumeRole"
],
"Resource": "*"
@lvthillo
lvthillo / policy-document-2.json
Created December 23, 2018 18:06
AWS IAM Policy Document to allow to put S3 object
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"s3:PutObject"
],
"Resource": "arn:aws:s3:::demo-lvthillo-bucket/*"
}