Skip to content

Instantly share code, notes, and snippets.

View ant31's full-sized avatar

Antoine Legrand ant31

View GitHub Profile
#!/usr/bin/env python3
import json
import argparse
import subprocess
def get_leader_pods(node_name: str, namespace: str = '') -> list[dict[str, str]]:
command = ["kubectl", "get", "pod",
"-l", "spilo-role=master", "-lapplication=spilo",
"--field-selector",
f"spec.nodeName={node_name}", "-ojson"]
@ant31
ant31 / Dockerfile
Last active November 25, 2022 01:01
# syntax=docker/dockerfile:1.4
# STAGE 1
FROM golang:1.19 as builder
WORKDIR /app
# ONLY needed for builds with private repo dependencies
RUN --mount=type=secret,id=GHTOKEN \
export GHTOKEN=$(cat /run/secrets/GHTOKEN) \
&& git config --global url.https://me:$GHTOKEN@github.com/.insteadOf https://github.com/
@ant31
ant31 / ff-api.yaml
Last active October 11, 2017 01:07
failfast k8s resources
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
annotations:
deployment.kubernetes.io/revision: "6"
kpm.hash: 4efc67226181bbcd206009cfb9cc5029cd74d9d662889143a03da5ffc55ba11b
kpm.package: ant31/hub2lab-hook
kpm.parent: ant31/hub2lab-hook
kpm.protected: "false"
kpm.version: 0.0.2.1-1
@ant31
ant31 / 01_manifest.yaml
Last active September 8, 2017 10:41
Kpm Manfiests
# Manifest 'hand-written' by the user
# metadata: ~equivalent to Chart.yaml
package:
name: foo/bar
version: 0.0.1
# List resources to deploy
resources:
# can be a template
# jinja2
@ant31
ant31 / cookieapp-opencompose.yaml
Last active May 12, 2017 20:08
jsonnet + opencompose realexample
local opencompose = import "lib/opencompose.libsonnet";
function(params={}, namespace="default")
opencompose.createServices({
web: {
image: "quay.io/ant31/cookiapp:0.5.0",
domain: "cookieapp.kubespray.com",
env: {"database": "postgres://postgres.default.svc"},
ports: [{name: "http", port: 80}],
@ant31
ant31 / manifest.yaml
Last active April 6, 2017 11:57
jsonnet
local kpm = import "kpm.libjsonnet";
function(
params={}
)
# Overall file feels very like a basic json / yaml
# the wrapper function enforce a unique way to write manifests
# and provide many abstraction that user doesn't see
apiVersion: batch/v1
kind: Job
metadata:
name: heketi-init
labels:
glusterfs: heketi-init
annotations:
description: Defines how to deploy Heketi
spec:
template:
# requirements_packages_crypto = [
# 'ecdsa',
# 'cryptography'
# ]
import string
import yaml
import json
import random
import hashlib
import _jsonnet
{
seq(i):: (
[x for x in std.range(1, i)]
),
shards(s, target):: (
if std.type(target) == 'null' then
s
else if std.type(target) == "object" then
@ant31
ant31 / 1_original_manifest.yaml
Last active May 23, 2016 15:41
Convert kpm manifest.yaml to jsonnet to better manifest.yaml
---
package:
name: kubespray/etcd
author: Antoine Legrand
version: 1.0.0
description: etcd
license: MIT
variables:
cluster_token: etcd-cluster-1