Skip to content

Instantly share code, notes, and snippets.

@DazWilkin
DazWilkin / config
Created January 16, 2024 19:01
Web UI Targets repeatedly incorrectly defaults scrape pool #13413
global:
scrape_interval: 30s
scrape_timeout: 10s
evaluation_interval: 30s
external_labels:
prometheus: monitoring/k8s
prometheus_replica: prometheus-k8s-0
alerting:
alert_relabel_configs:
- separator: ;
@DazWilkin
DazWilkin / certs.sh
Created January 12, 2024 22:38
Stackoverflow: 77795697
# CA
# CN is "ca"
# Expiry in 10 years
openssl req \
-x509 \
-newkey rsa:4096 \
-keyout ${PWD}/certs/ca.key \
-out ${PWD}/certs/ca.crt \
-nodes \
-days 3650 \
@DazWilkin
DazWilkin / main.go
Last active March 25, 2024 20:55
Stackoverflow: 73548332
ctx := context.Background()
containerService, _ := container.NewService(ctx)
name := fmt.Sprintf("projects/%s/locations/%s/clusters/%s", clusterProject, clusterLocation, clusterName)
rqst := containerService.Projects.Locations.Clusters.Get(name)
resp, _ := rqst.Do()
cert, _ := base64.StdEncoding.DecodeString(resp.MasterAuth.ClusterCaCertificate)
// Create Config for Cluster
@DazWilkin
DazWilkin / main.py
Created August 31, 2022 02:01
Stackoverflow: 73545312
def generate_token():
scopes = "https://www.googleapis.com/auth/cloud-platform"
url = f"http://metadata.google.internal/computeMetadata/v1/instance/service-accounts/default/token?scopes={scopes}"
headers = {'Metadata-Flavor': 'Google'}
resp = requests.get(url, headers=headers)
j = resp.json()
token = j['access_token']
return token
@DazWilkin
DazWilkin / ackal.tutorial.grafana.dashboard.json
Created May 11, 2022 20:25
Ackal tutorial Grafana Dashboard
{
"annotations": {
"list": [
{
"builtIn": 1,
"datasource": "-- Grafana --",
"enable": true,
"hide": true,
"iconColor": "rgba(0, 211, 255, 1)",
"name": "Annotations & Alerts",
@DazWilkin
DazWilkin / after.go.mod
Last active August 19, 2021 23:12
Errors upgrading operator-sdk v1.6.2-->v1.11.0 when importing modules that use go-logr/stdr
module github.com/my-account/this-repo
go 1.16
require (
github.com/my-account/another-repo v0.0.1
github.com/onsi/ginkgo v1.16.4
github.com/onsi/gomega v1.13.0
github.com/prometheus/client_golang v1.11.0
google.golang.org/api v0.54.0
@DazWilkin
DazWilkin / main.py
Created June 11, 2021 16:07
Stackoverflow #67888711
fields = ["campaign.id", "segments.device"]
query = """
SELECT {fields}
FROM campaign
WHERE segments.date = '{date}'
LIMIT 10
""".format(
fields=",".join([str(f) for f in fields]),
date="210611",
@DazWilkin
DazWilkin / settings.json
Created February 4, 2021 17:56
VS Code
{
"[go]": {
"editor.formatOnSave": true,
"editor.codeActionsOnSave": {
"source.organizeImports": true
}
},
"[markdown]": {
"editor.wordWrap": "off",
"editor.wordWrapColumn": 100,
kubectl get node --output=yaml
apiVersion: v1
items:
- apiVersion: v1
kind: Node
metadata:
annotations:
node.alpha.kubernetes.io/ttl: "0"
volumes.kubernetes.io/controller-managed-attach-detach: "true"
creationTimestamp: "2020-10-26T17:03:29Z"
// DNS (!) permitted name parts
// It's permitted to use hyphens but these must occur at most once (!) between alphanumeric
name = { ASCII_ALPHANUMERIC ~ ( ( ASCII_ALPHANUMERIC ~ HYPHEN ~ ASCII_ALPHANUMERIC ) | ASCII_ALPHANUMERIC )* }
full_name = { "name=\"" ~ name ~ "\"" }
domain = { ASCII_ALPHA_LOWER+ }
full_domain = { "domain=\"" ~ domain ~ "\"" }
// It may be redundant to define these as constants!?
tcp = { "tcp" }