Skip to content

Instantly share code, notes, and snippets.

View wallyqs's full-sized avatar
🌎

Waldemar Quevedo wallyqs

🌎
  • Synadia Communications, Inc.
  • San Francisco
  • X @wallyqs
View GitHub Profile
@wallyqs
wallyqs / nats-server-and-spiffe.md
Last active March 30, 2024 01:57
NATS Server + SPIFFE

Start the server with SPIFFE SVID Auth enabled:

git clone https://github.com/nats-io/nats-server
cd nats-server/test/configs/certs/svid

wget https://gist.githubusercontent.com/wallyqs/f2479312079afb04b83ad6b90aa8bca1/raw/c2ae6949807bb9cd090ebff0bcff3fc1b62c42e3/svid-auth.conf
wget https://gist.githubusercontent.com/wallyqs/f2479312079afb04b83ad6b90aa8bca1/raw/747a3a5fe74887f0b9a23d2ac9e99182fa9dd971/svid-a.go
docker run -v $(pwd):/conf -p 4222:4222 wallyqs/nats-server:2.1.7-spiffe --config /conf/svid-auth.conf -DV
@wallyqs
wallyqs / readme.md
Created July 15, 2023 04:10
JetStream on Docker with Docker Compose

First, create a few volumes so that state is persisted across restarts:

docker volume create nats1
docker volume create nats2
docker volume create nats3

Now create a docker-compose.yaml with the following:

@wallyqs
wallyqs / cert-manager.yaml
Created June 25, 2020 20:56
NATS Helm Charts + Cert Manager
---
apiVersion: cert-manager.io/v1alpha2
kind: ClusterIssuer
metadata:
name: selfsigning
spec:
selfSigned: {}
---
apiVersion: cert-manager.io/v1alpha2
kind: Certificate
@wallyqs
wallyqs / Docker Compose + NATS example
Last active February 18, 2024 22:27
NATS Docker blog post/HTTP Server
FROM golang:1.6.2
COPY . /go
RUN go get github.com/nats-io/nats
RUN go build api-server.go
EXPOSE 8080
ENTRYPOINT ["/go/api-server"]
@wallyqs
wallyqs / aiohttp-example-thread-pool-executor.py
Created August 30, 2018 07:04
aiohttp-example-thread-pool-executor.py
import asyncio
import json
import logging
import signal
import aiohttp
import platform
from aiohttp import web
from datetime import datetime
from nats.aio.client import Client as NATS
@wallyqs
wallyqs / app.html
Created August 15, 2018 06:07
NATS Socket IO + Sanic
<!DOCTYPE HTML>
<html>
<head>
<title>NATS &plus; SocketIO </title>
<script type="text/javascript" src="//code.jquery.com/jquery-2.1.4.min.js"></script>
<script type="text/javascript" src="//cdnjs.cloudflare.com/ajax/libs/socket.io/1.3.5/socket.io.min.js"></script>
<script type="text/javascript" charset="utf-8">
$(document).ready(function(){
namespace = '/test';
var socket = io.connect('http://' + document.domain + ':' + location.port + namespace);
@wallyqs
wallyqs / readme.md
Created July 22, 2021 15:03
Mixed Auth via Leafnodes

Mixed Auth via Leafnodes

Server A starts with basic auth:

port = 4222

leaf {
  port = 7422
}
@wallyqs
wallyqs / aks-lb.md
Last active October 18, 2022 11:25
Setting up a NATS Server with external access on Azure

Setting up a NATS Server with external access on Azure

With the following, you can create a 3-node NATS Server cluster:

kubectl apply -f https://raw.githubusercontent.com/nats-io/k8s/b55687a97a5fd55485e1af302fbdbe43d2d3b968/nats-server/leafnodes/nats-cluster.yaml

The configuration map from the NATS cluster that was created can be found below.

@wallyqs
wallyqs / wq.go
Created April 16, 2021 00:04
Pull Subscribe + WorkQueuePolicy
package main
import (
"context"
"encoding/json"
"errors"
"math"
"time"
"log"
@wallyqs
wallyqs / nats-cluster-tls-kubernetes.org
Last active September 9, 2022 11:41
Secure NATS Cluster in Kubernetes

Secure NATS Cluster in Kubernetes

Creating the certificates

Generating the Root CA Certs

{
    "CN": "My Custom CA",