This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ApplicationController < ActionController::Base | |
protect_from_forgery with: exception | |
def append_info_to_payload(payload) | |
super | |
payload[:host] = request.host | |
payload[:remote_ip] = request.remote_ip | |
payload[:ip] = request.ip | |
end | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# config/routes.rb | |
Rails.application.routes.draw do | |
get '/ping', to: 'health_check#ping' | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# config/environments/development.rb | |
Rails.application.configure do | |
config.log_tags = [:request_id] | |
config.log_level = :debug | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# app/controllers/health_check_controller.rb | |
class HealthCheckController < ActionController::Base | |
def ping | |
render json: { success: true, errors: nil, data: 'pong' }, status: :ok | |
end | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
apiVersion: networking.istio.io/v1alpha3 | |
kind: DestinationRule | |
metadata: | |
name: foo | |
namespace: default | |
spec: | |
host: foo.default.svc.cluster.local | |
subsets: | |
- labels: | |
deployment-id: "1" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
apiVersion: networking.istio.io/v1alpha3 | |
kind: VirtualService | |
metadata: | |
name: foo | |
namespace: default | |
spec: | |
gateways: | |
- default-gateway | |
- mesh | |
hosts: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
apiVersion: apps/v1 | |
kind: Deployment | |
metadata: | |
name: redis-cache | |
spec: | |
selector: | |
matchLabels: | |
app: store | |
replicas: 3 | |
template: |