Skip to content

Instantly share code, notes, and snippets.

View trstringer's full-sized avatar

Thomas Stringer trstringer

View GitHub Profile
version: '3'
services:
svc1:
build: .
links:
- redis
ports:
- "8000:8000"
redis:
image: redis:latest
@trstringer
trstringer / python_logging_to_systemd.py
Created February 5, 2018 13:39
Python logging to systemd
import logging
import random
import time
from systemd.journal import JournaldLogHandler
# get an instance of the logger object this module will use
logger = logging.getLogger(__name__)
# instantiate the JournaldLogHandler to hook into systemd
journald_handler = JournaldLogHandler()
[Unit]
Description=Sample to show logging from a Python application to systemd
After=network.target
[Service]
Type=simple
ExecStart=/usr/local/bin/pysystemdlogging/run_app.sh
Restart=on-abort
[Install]
#!/bin/bash
SCRIPT_PATH=$(dirname "$(realpath "$0")")
. "$SCRIPT_PATH/venv/bin/activate"
python "$SCRIPT_PATH/app.py"
#!/bin/bash
# the first and only parameter to this script is an _optional_ bin name
# if not specified, it will default to "miki"
#
# usage:
# ./install.sh othermikiname
CWD=$(python -c "import os; print(os.getcwd())")
BIN_NAME="miki"

Create a PersistentVolumeClaim with Azure Files

Create a storage account in the same resource group as the k8s cluster:

$ az storage account create -g <resource_group_name> -n <new_storage_account_name> --sku Standard_LRS -l <location>

Create a new role to assign principals to allow them to create secrets:

apiVersion: rbac.authorization.k8s.io/v1
# ROOT_PACKAGE :: the package (relative to $GOPATH/src) that is the target for code generation
ROOT_PACKAGE="github.com/trstringer/k8s-controller-core-resource"
# CUSTOM_RESOURCE_NAME :: the name of the custom resource that we're generating client code for
CUSTOM_RESOURCE_NAME="myresource"
# CUSTOM_RESOURCE_VERSION :: the version of the resource
CUSTOM_RESOURCE_VERSION="v1"
# retrieve the code-generator scripts and bins
go get -u k8s.io/code-generator/...
cd $GOPATH/src/k8s.io/code-generator
package myresource
const GroupName = "trstringer.com"
package v1
import (
meta_v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)
// +genclient
// +genclient:noStatus
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
// +k8s:deepcopy-gen=package
// +groupName=trstringer.com
package v1