Skip to content

Instantly share code, notes, and snippets.

View tasdikrahman's full-sized avatar
💭
Automate everything

Tasdik Rahman tasdikrahman

💭
Automate everything
View GitHub Profile
# config/environments/development.rb
Rails.application.configure do
config.lograge.formatter = Lograge::Formatters::Json.new
config.lograge.enabled = true
config.lograge.base_controller_class = ['ActionController::Base']
config.lograge.custom_options = lambda do |event|
{
request_time: Time.now,
application: Rails.application.class.parent_name,
process_id: Process.pid,
[my-app-fbf8d7bfc-wk5cd] I, [2020-07-01T07:19:05.007174 #1] INFO -- : [ec0ad0ba-dfb2-419b-bd81-5feb7dacb308] Processing by HealthCheckController#ping as HTML
[my-app-fbf8d7bfc-wk5cd] I, [2020-07-01T07:19:05.007874 #1] INFO -- : [ec0ad0ba-dfb2-419b-bd81-5feb7dacb308] Completed 200 OK in 0ms (Views: 0.2ms)
[my-app-fbf8d7bfc-wk5cd] I, [2020-07-01T07:19:05.290929 #1] INFO -- : [86332306-62e4-412e-a690-eee8253ab1c8] Started GET "/ping" for 10.177.3.1 at 2020-07-01 07:19:05 +0000
[my-app-fbf8d7bfc-wk5cd] I, [2020-07-01T07:19:05.292363 #1] INFO -- : [86332306-62e4-412e-a690-eee8253ab1c8] Processing by HealthCheckController#ping as HTML
# config/routes.rb
Rails.application.routes.draw do
get '/ping', to: 'health_check#ping'
end
# config/environments/development.rb
Rails.application.configure do
config.log_tags = [:request_id]
config.log_level = :debug
end
# app/controllers/health_check_controller.rb
class HealthCheckController < ActionController::Base
def ping
render json: { success: true, errors: nil, data: 'pong' }, status: :ok
end
end
# borrowed and modified from https://github.com/shelleg/kubernetes-101
apiVersion: apps/v1
kind: Deployment
metadata:
labels:
app: ping-server
name: ping-server
spec:
replicas: 2
selector:
apiVersion: networking.istio.io/v1alpha3
kind: DestinationRule
metadata:
name: foo
namespace: default
spec:
host: foo.default.svc.cluster.local
subsets:
- labels:
deployment-id: "1"
@tasdikrahman
tasdikrahman / canary-deployment-virtualservice-spec-example.yaml
Created June 7, 2020 10:16
A canary deployment virtualservice spec, to specify weights of 90 and 10% for primary and canary respectively
apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
name: foo
namespace: default
spec:
gateways:
- default-gateway
- mesh
hosts:
apiVersion: apps/v1
kind: Deployment
metadata:
name: redis-cache
spec:
selector:
matchLabels:
app: store
replicas: 3
template:
apiVersion: apps/v1
kind: Deployment
metadata:
name: redis-cache
spec:
selector:
matchLabels:
app: store
replicas: 3
template: