Skip to content

Instantly share code, notes, and snippets.

View stand-sure's full-sized avatar

Christopher J. Anderson stand-sure

View GitHub Profile
@stand-sure
stand-sure / README.md
Created March 5, 2024 19:24
Kube Stack Prometheus Grafana Datasource with Secrets

Grafana Datasource with Secrets

  1. Create a secret
  2. Add the secrets as environment variables to the Grafana section of the Prometheus yaml
  3. Use the environment values (secureJsonData)
@stand-sure
stand-sure / README.md
Created February 28, 2024 20:39
Clickhouse & Jaeger

jaeger-config.yaml

Set values for address, username, and password.

Make the password into a hash for the clickhouse installation.

printf `printf 'my-password' | sha256sum` ; echo

# 6fa2288c361becce3e30ba4c41be7d8ba01e3580566f7acc76a7f99994474c46
@stand-sure
stand-sure / README.md
Created February 28, 2024 13:31
Using OpenTelemetry Collector with Clickhouse

Clickhouse & OTel Collector

clickhouse network security

The username/networks/ip under spec.configuration.users was the key to getting things to work.
It seems that "10.0.0.0/16" isn't enough. Allowing all networks solved the problem.

Otel Collector and sensitive data

Secrets can be mounted to environment variables under the extraEnvs key.

@stand-sure
stand-sure / helm-secret-lookup-manual.yaml
Created December 28, 2023 16:17
helm random secret with persistence and optional override
{{- if empty .Values.manualSecretName }}
apiVersion: v1
kind: Secret
metadata:
name: "jwt-secret"
annotations:
"helm.sh/resource-policy": "keep"
type: Opaque
data:
# retrieve the secret data using lookup function and when not exists, return an empty dictionary / map as result
### Keybase proof
I hereby claim:
* I am stand-sure on github.
* I am stand_sure (https://keybase.io/stand_sure) on keybase.
* I have a public key ASCyW_dmVCsEDjWTcomieNrIhS2NJrkfRyww-S2qFc7K2Ao
To claim this, I am signing this object:
@stand-sure
stand-sure / get-package-refs.sh
Last active December 1, 2023 18:53
scripts for getting package and project references from csproj files
#! /usr/bin/env bash
for file in src/**/*.csproj
do
cat $file | \
xq '[(try(.Project.ItemGroup[].PackageReference) // [])] | flatten' | \
jq '[.[].["@Include"]]' | \
jq --arg file ${file} '{"file":$file, "refs":.}' | \
yq eval --prettyPrint '[.]';
done
@stand-sure
stand-sure / my.gitsign-credential-cache.plist
Created November 21, 2023 21:48
run gitsign-credential-cache at login on macos
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>KeepAlive</key>
<true/>
<key>Label</key>
<string>my.gitsign-credential-cache</string>
<key>ProgramArguments</key>
<array>
@stand-sure
stand-sure / verify-opentelemetry-trace.cs
Created November 14, 2023 13:58
How to Verify that an OpenTelemetry Trace is produced in a unit test
[Fact]
public async Task InterceptShouldTrace()
{
IList<Activity> exportedActivities = new List<Activity>();
IHostBuilder hostBuilder = Host.CreateDefaultBuilder();
var source = Guid.NewGuid().ToString("N");
hostBuilder.ConfigureServices((_, serviceCollection) =>
@stand-sure
stand-sure / ServiceCollectionExtensions {.cs
Created October 17, 2023 21:19
POCO Config w/o IOptions
// found at https://www.strathweb.com/2016/09/strongly-typed-configuration-in-asp-net-core-without-ioptionst/
public static class ServiceCollectionExtensions
{
public static TConfig ConfigurePOCO<TConfig>(this IServiceCollection services, IConfiguration configuration, Func<TConfig> pocoProvider) where TConfig : class
{
if (services == null) throw new ArgumentNullException(nameof(services));
if (configuration == null) throw new ArgumentNullException(nameof(configuration));
if (pocoProvider == null) throw new ArgumentNullException(nameof(pocoProvider));
@stand-sure
stand-sure / get-secrets.sh
Created August 18, 2023 18:49
get and decode all k8s secrets
#! /usr/bin/env bash
kubectl get secret --output yaml | /usr/local/bin/yq '.items[] | { (.metadata.name): (.data | to_entries) | map_values({ (.key): (.value | @base64d )}) }'
echo