Skip to content

Instantly share code, notes, and snippets.

# k3d-config.yml
apiVersion: k3d.io/v1alpha3
kind: Simple
name: "mycluster"
servers: 1
agents: 2
kubeAPI:
hostIP: "0.0.0.0"
hostPort: "6443"
ports:
/**
Helper that copies the state of Reactor [Context] to MDC on the #onNext function.
*/
@Slf4j
@RequiredArgsConstructor
public class MdcContextLifter<T> implements CoreSubscriber<T> {
    private final CoreSubscriber<T> coreSubscriber;
    @Override
@jei0486
jei0486 / MdcContextLifterConfig.java
Last active January 10, 2023 02:18
MDC with webflux
/**
* @link https://www.novatec-gmbh.de/en/blog/how-can-the-mdc-context-be-used-in-the-reactive-spring-applications/
* https://projectreactor.io/docs/core/release/api/reactor/core/publisher/Hooks.html#onEachOperator-java.util.function.Function-
*/
@Configuration
public class MdcContextLifterConfig {
    public static final String MDC_CONTEXT_REACTOR_KEY = MdcContextLifterConfig.class.getName();
    @PostConstruct
@jei0486
jei0486 / WebFilter.java
Last active January 10, 2023 02:18
MDC with webflux
@Slf4j
@Configuration
public class MdcLoggingFilter implements WebFilter {
    private static final String MDC_KEY_TRACE_ID = "traceId";
    @Override
    public Mono<Void> filter(ServerWebExchange exchange, WebFilterChain chain) {
        ServerHttpRequest request = exchange.getRequest();
        String requestId = getRequestId(request.getHeaders());
// build.gradle
ext {
set('springCloudVersion', "2021.0.5")
}
dependencyManagement {
imports {
mavenBom "org.springframework.cloud:spring-cloud-dependencies:${springCloudVersion}"
}
}
# application.yml
spring:
  security:
    oauth2:
      resourceserver:
        opaquetoken:
          introspection-uri: http://localhost:8080/auth/realms/demo/protocol/openid-connect/token/introspect
          client-id: demo-client
          client-secret: 83f3e948-3f8c-49da-af7f-87a42d5ea6fd
# application.yml
spring:
  security:
    oauth2:
      resourceserver:
        jwt:
          issuer-uri: http://localhost:8080/auth/realms/demo
@jei0486
jei0486 / SecurityConfig.java
Created January 10, 2023 02:22
opaque-token-Spring-Security
package com.demo.scg.config;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.security.config.annotation.web.reactive.EnableWebFluxSecurity;
import org.springframework.security.config.web.server.ServerHttpSecurity;
import org.springframework.security.web.server.SecurityWebFilterChain;
@Configuration
@jei0486
jei0486 / KeycloakReactiveTokenInstrospector.java
Created January 10, 2023 02:23
opaque-token-instrospector
package com.demo.scg.config;
import java.util.Collection;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.stream.Collectors;
# argocd-canary-rollout.yml
apiVersion: argoproj.io/v1alpha1
kind: Rollout
# 이 아래 내용은 기존 Deployment와 동일하게 작성
metadata:
name: demo-scg-rollout
namespace: gateway
spec:
minReadySeconds: 30
revisionHistoryLimit: 3