Skip to content

Instantly share code, notes, and snippets.

k --context app-prod-hq -n nitro-web-production describe po nitro-production-consolepb5wp

Name:             nitro-production-consolepb5wp
Namespace:        nitro-web-production
Priority:         0
Service Account:  default
Node:             prod-app-worker02.hq.powerinfra.io/10.1.160.112
Start Time:       Fri, 14 Jun 2024 15:13:53 -0400
Labels:           app.kubernetes.io/component=shell
                  app.kubernetes.io/instance=nitro-production

Problem: Influxd db series size is managed by max-series-per-database config parameter. In our case it is 1Mil. InfluxDb documentation suggest do not have too many series

Ways To keep low series:

  • Database per measurment type (per table), if you think it will be too many tables than plan B: database for each project (nitro-web, milano)
  • Retention Policy
#!/bin/bash
totalcpu=0
totalmemory=0
filename="$1"
cluster="$2"
namespace="$3"
echo "---" >> "$filename"
#!/bin/bash
totalcpu=0
totalmemory=0
filename="$1"
cluster="$2"
namespace="$3"
echo "---" >> "$filename"
#!/bin/bash
# bash resource_quote.sh /path/to/dir cluster_name namespace_name
totalcpu=0
totalmemory=0
directory="$1"
cluster="$2"
ns="$3"
Test: trying to connect to any of redis/sentinel pods outside of namespace
Results:
Timeout error
Test: make unavailable redis-master pod
Results:
redisoperator detect unavailable node. Changed label of slave redis node to `master`
Test: delete redis master pod
Results:
1. Problem
HA with Redis Sentinel has an issue when k8s remapping ip addresses.
Redis/Sentinel always "remembered" the IP addresses of the old (now gone) nodes.
And that's actually the problem.
During that Redis Sentinel clusters recreation process it is likely that one node got an internal IP address
that was previously used by a node that belonged to a different Redis Sentinel cluster.
2 Solutions
2.1 DNS/Hostnames
Opstree redis-operator in cluster mode was testing as a solution
for a replacement existed HA solution on base of sentinel and redis. Test was done on milano project.
Milano application uses Ruby on Rails framework and redis-rb gem for a communication with redis.
For a cluster approach we had to change existed ruby-redis connection from Redis.new(url: 'url') to Redis.new(cluster: ['url']).
Milano is using redis mostly for sidekiq jobs, so we had to change existing sidekiq connection to redis in order to test
cluster mode.
Unfortunatly sidekiq does not support redis cluster mode, moreover it is not recommended by sidekiq community, here is an
explanation: https://github.com/sidekiq/sidekiq/wiki/Using-Redis#architecture.
So on this step we have 2 options: keep existing approach with a HA redis for a sidekiq and birng on board new redis-cluster
approach for other application tasks.
@rurkss
rurkss / curl.md
Created March 12, 2019 07:20 — forked from subfuzion/curl.md
curl POST examples

Common Options

-#, --progress-bar Make curl display a simple progress bar instead of the more informational standard meter.

-b, --cookie <name=data> Supply cookie with request. If no =, then specifies the cookie file to use (see -c).

-c, --cookie-jar <file name> File to save response cookies to.

@rurkss
rurkss / postgres_queries_and_commands.sql
Created March 11, 2019 11:21 — forked from rgreenjr/postgres_queries_and_commands.sql
Useful PostgreSQL Queries and Commands
-- show running queries (pre 9.2)
SELECT procpid, age(clock_timestamp(), query_start), usename, current_query
FROM pg_stat_activity
WHERE current_query != '<IDLE>' AND current_query NOT ILIKE '%pg_stat_activity%'
ORDER BY query_start desc;
-- show running queries (9.2)
SELECT pid, age(clock_timestamp(), query_start), usename, query
FROM pg_stat_activity
WHERE query != '<IDLE>' AND query NOT ILIKE '%pg_stat_activity%'