Skip to content

Instantly share code, notes, and snippets.

@dsandip
dsandip / YugaByte_HAProxy_hasura.md
Created February 26, 2024 16:54
HA Proxy configuration for YugaByte

YugaByte provide's a smartdriver to help load balance across distributed nodes (amongst other things). In cases where this driver can't be used, one can use a proxy to achieve the same. The following are instructions to use HAProxy to do this:

  1. Use HAProxy with the following config (while changing/tuning the YB parameters as needed):

Step 1: Create a Hasura Account

Head to https://cloud.hasura.io and sign-up for an account if you don't already have one. This account will be used to administer all the Hasura instances that you own. If you already have a Hasura Cloud, please ensure that you can see the New Self-Hosted Project option in the Cloud dashboard:

self-hosted-project-option

If you don't see this option, please contact Hasura support to enable it for your Cloud account.

Step 2: Register a self-hosted project

@dsandip
dsandip / migrate_images_to_private_registry.sh
Created May 6, 2022 15:26
Bash script to push Hasura E.E control plane images to a private registry
#!/bin/bash
json_key=$(<example.json) # JSON access key
internal_repo='localhost:8000' # URL to private container registry
docker login -u _json_key --password "$json_key" https://gcr.io # log into GCR
image_list=(`helm template lux-2.0.8.tgz | grep "image:"`) # get raw list of images from Helm charts
ignore_value="image:" # value to parse downstream
names=$(printf "'%s'\n" "${image_list[@]/$ignore_value}" | grep -v "''" | tr -d \'\" | tr -d "\r" | sort -u | uniq) # Assign output to variable via Bash command substitution
@dsandip
dsandip / override-values-private-registry.yaml
Last active May 5, 2022 08:26
sample override file for using a private container registry with Hasura E.E
# For more information on configuration options, refer to https://docs.pro.hasura.io/custom-installation/helm-configs/
global:
# Allowed values: http, https
uriScheme: "http"
# Set to the configured domain / Ingress' loadbalancerIP.nip.io
domain: "35.235.7.103.nip.io"
# Set to the k8s namespace the resources should be deployed to.The namespace should exist before applying the manifest
namespace: "default"
# Configure the container registry to be used; defaults to gcr.io/hasura-ee

Event Trigger issue

Details of the issue:

We have detected an error message similar to the following example, in some projects on Hasura Cloud:

“event trigger "foo_event_trigger" on table "foo" not found”

This happens when the event trigger definition no longer exists in the metadata but the associated Postgres trigger exists in the database which impacts the resource consumption in your project's database.

@dsandip
dsandip / Hasura-Pro-Redis-TLS-details.md
Created September 30, 2021 17:50
describes the recent updates in Hasura E.E data plane for Redis TLS support

Redis TLS configuration

Hasura supports using TLS to connect securely to Redis instances (which it can use for rate limiting and caching).

TLS connection information can be specified via the following environment variables:

  • HASURA_GRAPHQL_REDIS_USE_TLS: Opt-in flag that enables the use of TLS for the caching Redis instance, defaults to false.
  • HASURA_GRAPHQL_RATE_LIMIT_REDIS_USE_TLS: Opt-in flag that enables the use of TLS for the rate-limiting Redis instance, defaults to false.

Slack permissions model based authorization task

  1. Create a Postgres schema that models a Slack-like app's DB requirements:

    a) There are channels and users(3 user roles: users, moderators, admins).

    b) Users can access a subset of all channels, and create messages in each/any of these accessible channels. They can also modify(edit/delete) their own messages. Any user who belongs to a channel can read all messages in that channel.

    c) Moderators can access a subset of all channels and can access/edit/delete any messages in these channels.

GRANT SELECT, REFERENCES ON ALL TABLES IN SCHEMA public TO <hasura-connection-string-user>;
ALTER DEFAULT PRIVILEGES IN SCHEMA public GRANT SELECT ON TABLES TO <hasura-connection-string-user>;
REVOKE CREATE ON SCHEMA public FROM PUBLIC;
GRANT USAGE ON SCHEMA hdb_catalog TO <hasura-connection-string-user>;
GRANT ALL ON schema hdb_catalog TO <hasura-connection-string-user>;
GRANT ALL ON ALL TABLES IN SCHEMA hdb_catalog TO <hasura-connection-string-user> ;
GRANT USAGE ON ALL SEQUENCES IN SCHEMA hdb_catalog TO <hasura-connection-string-user>;
ALTER DEFAULT PRIVILEGES IN SCHEMA hdb_catalog GRANT ALL PRIVILEGES ON TABLES TO <hasura-connection-string-user>;
ALTER DEFAULT PRIVILEGES IN SCHEMA hdb_catalog GRANT USAGE ON SEQUENCES TO <hasura-connection-string-user>;
@dsandip
dsandip / Metrics.md
Created July 25, 2019 13:24
Metrics in commercial product


Objective

The incoming log stream from Hasura instances can be analyzed to derive metrics about the instance and it’s performance.

These can help with real-time requests per second, success-error rates, query whitelisting, regression tests, field level analytics etc.

These features can be broadly classified into four buckets:

@dsandip
dsandip / Metrics.md
Created July 25, 2019 13:23
Metrics in commercial product
<title>Metrics in commercial product</title>