Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View icebob's full-sized avatar

Icebob icebob

View GitHub Profile
@icebob
icebob / README.md
Last active October 18, 2022 16:12
Loki logger for Moleculer microservices framework

Loki logger for Moleculer microservices framework

It sends the Moleculer log messages to a Grafana Loki server directly. I'm using it to send logs from Fly.io moleculer app to Grafana Cloud.

For Kubernetes, I recommend to use Grafana Agent to send log messages because Agent adds K8s pod relevant labels to the messages.

Usage

// moleculer.config.js
@icebob
icebob / PostgresRestart.ts
Created October 7, 2020 13:54
Pulumi Dynamic Resource - Restart Azure Managed PostgreSQL Server
import * as pulumi from '@pulumi/pulumi';
export interface PostgresRestartArgs {
resourceGroupName: pulumi.Input<string>;
serverName: pulumi.Input<string>;
}
class PostgresRestartProvider implements pulumi.dynamic.ResourceProvider {
public async check(
olds: any,
@icebob
icebob / star-converter.js
Created August 22, 2020 17:07
Convert Github stars to csv
const fetch = require("node-fetch");
const { createWriteStream, existsSync } = require("fs");
const fs = require("fs").promises;
const outputFileName = "stars.csv";
const githubUser = "icebob";
function log(msg) {
console.log(`[${new Date().toISOString().substr(11, 8)}] -`, msg);
}
@icebob
icebob / docker-compose.yml
Last active November 1, 2023 06:02
Start K3S Cluster on Docker
version: '3'
services:
server:
image: "rancher/k3s:latest"
command: server
tmpfs:
- /run
- /var/run
privileged: true
@icebob
icebob / k8s-install-longhorn.sh
Created January 1, 2020 14:02
Install Longhorn storage for Kubernetes
sudo apt-get install open-iscsi
kubectl apply -f https://raw.githubusercontent.com/longhorn/longhorn/master/deploy/longhorn.yaml
kubectl -n longhorn-system get all
@icebob
icebob / nginx-ingress-install.sh
Created January 1, 2020 13:20
Install Nginx Ingress controller
kubectl apply -f https://raw.githubusercontent.com/nginxinc/kubernetes-ingress/master/deployments/common/ns-and-sa.yaml
kubectl apply -f https://raw.githubusercontent.com/nginxinc/kubernetes-ingress/master/deployments/common/default-server-secret.yaml
kubectl apply -f https://raw.githubusercontent.com/nginxinc/kubernetes-ingress/master/deployments/common/nginx-config.yaml
kubectl apply -f https://raw.githubusercontent.com/nginxinc/kubernetes-ingress/master/deployments/rbac/rbac.yaml
kubectl apply -f https://raw.githubusercontent.com/nginxinc/kubernetes-ingress/master/deployments/daemon-set/nginx-ingress.yaml
@icebob
icebob / k3s_helm_install.sh
Last active March 27, 2024 12:04
K3S + Helm installing
# Install K3S
curl -sfL https://get.k3s.io | sh -
# Copy k3s config
mkdir $HOME/.kube
sudo cp /etc/rancher/k3s/k3s.yaml $HOME/.kube/config
sudo chmod 644 $HOME/.kube/config
# Check K3S
kubectl get pods -n kube-system
'use strict';
const path = require('path');
const fs = require('fs');
const YAML = require('yaml');
function WebpackMoleculerServicePlugin(options) {
options = options || {};
if (typeof options === 'string') {
this.options = { output: options };
@icebob
icebob / README.md
Last active October 22, 2023 19:50
Health-check middleware for Moleculer (for Kubernetes liveness readiness checks)
@icebob
icebob / saga-sample.js
Last active October 2, 2023 10:47
Saga middleware PoC for Moleculer
"use strict";
const _ = require("lodash");
const chalk = require("chalk");
const Promise = require("bluebird");
const ServiceBroker = require("../src/service-broker");
const { MoleculerError } = require("../src/errors");
// --- SAGA MIDDLEWARE ---
const SagaMiddleware = function() {