Skip to content

Instantly share code, notes, and snippets.

Avatar

Aaron Freeland afreeland

View GitHub Profile
@afreeland
afreeland / kubectl exec cmd multiple pods (envoy example)
Created Jul 25, 2022
Pipe `kubectl` pod names into `xargs` to invoke `curl` commands to update `envoy` debugging levels
View kubectl exec cmd multiple pods (envoy example)
kubectl -l{LABEL_SELECTOR} --no-headers -o custom-columns=":metadata.name" | xargs -I% kubectl exec % -- curl -X POST http://localhost:{ENVOY_ADMIN_PORT}/logging\?level\=debug
View Update kubeconfig new cluster
# List clusters
aws eks list-clusters
# You may need to target different profiles
AWS_PROFILE={account-profile-name-here} aws eks list-clusters
# Update kubeconfig with cluster info
aws eks update-kubeconfig --name {cluster-name-here}
View gist:f2e26e02a784e7cae66795a3281dbdb2
# git fetch {remote} pull/{PR#}/head && git checkout FETCH_HEAD
git fetch upstream pull/855/head && git checkout FETCH_HEAD
@afreeland
afreeland / WebhookVerification.js
Created Aug 6, 2020
Chargify webhook verification middleware
View WebhookVerification.js
app.use("/chargify", (req, res, next) => {
// This request header contains the signature of the hmac sha 256 of the sites secret with the raw body of the request
const webhookSignature =
req.headers["x-chargify-webhook-signature-hmac-sha-256"];
try {
// Your secret shared site key that you got from Chargify earlier
// This is a SECRET and should be stored/retrieved in a safe manner, not source control (Kube Secret, etc.,)
const sharedKey = "b65ca1b9a6eaea838b7c536ca0ca5fe634214b5d";
// The first step is to create a sha256 of our shared site key
const hmac = crypto.createHmac("sha256", sharedKey);
@afreeland
afreeland / middleware.js
Last active Aug 7, 2020
Webhook middleware (Chargify)
View middleware.js
const app = express();
function rawBodySaver(req, res, buf, encoding) {
if (buf && buf.length) {
req.rawBody = buf.toString(encoding || "utf8");
}
}
// For parsing application/json
app.use(express.json());
// For parsing application/x-www-form-urlencoded (which is the Content-Type from Chargify)
@afreeland
afreeland / gist:7d85e483eb1795bb47af42f8a1115a4d
Last active Mar 13, 2019
Ingress TLS bare-metal Kubernetes
View gist:7d85e483eb1795bb47af42f8a1115a4d
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
annotations:
nginx.ingress.kubernetes.io/proxy-connect-timeout: "21600000"
nginx.ingress.kubernetes.io/proxy-read-timeout: "21600000"
nginx.ingress.kubernetes.io/proxy-send-timeout: "21600000"
nginx.ingress.kubernetes.io/rewrite-target: /
name: ds-ingress
namespace: default
@afreeland
afreeland / gist:ee525ba62bba605ad39088e667c13218
Created Oct 5, 2018
Ingress TLS secret Kubernetes bare-metal
View gist:ee525ba62bba605ad39088e667c13218
apiVersion: v1
kind: Secret
metadata:
name: our-tls
namespace: default
type: kubernetes.io/tls
data:
tls.crt: abcde
tls.key: 12345
@afreeland
afreeland / recentQuery.js
Created May 1, 2018
React: Proper declaring enum type
View recentQuery.js
import React, { Component } from 'react';
import { render } from 'react-dom';
const gql = require('graphql-tag');
import { graphql } from 'react-apollo';
import appRoot from 'app-root-path';
import store from '../../store.js';
const Recent_Query = gql(`
query recent_query($username: String! $type: recentTypess! ){
recent (username: $username type: $type){
View gist:0c26acb07558fd730f455f1df4de8300
import React, { Component } from 'react';
import { render } from 'react-dom';
const gql = require('graphql-tag');
import { graphql } from 'react-apollo';
import appRoot from 'app-root-path';
import store from '../../store.js';
const Recent_Query = gql(`
query recent_query($username: String! $type: String! ){
recent (username: $username type: $type){