init
This commit is contained in:
45
.gitignore
vendored
Normal file
45
.gitignore
vendored
Normal file
@@ -0,0 +1,45 @@
|
||||
/target/
|
||||
/bin/
|
||||
/.settings/
|
||||
*#
|
||||
*.iml
|
||||
*.ipr
|
||||
*.iws
|
||||
*.jar
|
||||
*.sw?
|
||||
*~
|
||||
.#*
|
||||
.*.md.html
|
||||
.DS_Store
|
||||
.classpath
|
||||
.factorypath
|
||||
.gradle
|
||||
.idea
|
||||
.metadata
|
||||
.project
|
||||
.recommenders
|
||||
.settings
|
||||
.springBeans
|
||||
/build
|
||||
/code
|
||||
MANIFEST.MF
|
||||
_site/
|
||||
activemq-data
|
||||
bin
|
||||
build
|
||||
build.log
|
||||
dependency-reduced-pom.xml
|
||||
dump.rdb
|
||||
interpolated*.xml
|
||||
lib/
|
||||
manifest.yml
|
||||
overridedb.*
|
||||
settings.xml
|
||||
target
|
||||
transaction-logs
|
||||
.flattened-pom.xml
|
||||
secrets.yml
|
||||
.gradletasknamecache
|
||||
.sts4-cache
|
||||
node_modules
|
||||
.dist/
|
||||
4
Dockerfile
Normal file
4
Dockerfile
Normal file
@@ -0,0 +1,4 @@
|
||||
FROM openjdk:8u212-jdk-alpine
|
||||
COPY target/*SNAPSHOT.jar app.jar
|
||||
EXPOSE 8080
|
||||
ENTRYPOINT ["java","-Xmx400M","-Djava.security.egd=file:/dev/./urandom","-jar","/app.jar","--spring.profiles.active=docker"]
|
||||
77
cloudbuild.yaml
Normal file
77
cloudbuild.yaml
Normal file
@@ -0,0 +1,77 @@
|
||||
steps:
|
||||
### Build
|
||||
- id: 'build'
|
||||
name: 'gcr.io/cloud-builders/docker'
|
||||
entrypoint: 'bash'
|
||||
args:
|
||||
- '-c'
|
||||
- |
|
||||
echo '$COMMIT_SHA =' $COMMIT_SHA
|
||||
docker build -t gcr.io/$PROJECT_ID/$_PROJECT_NAME:$COMMIT_SHA .
|
||||
### Test
|
||||
### Publish
|
||||
- id: 'publish'
|
||||
name: 'gcr.io/cloud-builders/docker'
|
||||
entrypoint: 'bash'
|
||||
args:
|
||||
- '-c'
|
||||
- |
|
||||
docker push gcr.io/$PROJECT_ID/$_PROJECT_NAME:$COMMIT_SHA
|
||||
### deploy
|
||||
- id: 'deploy'
|
||||
name: 'gcr.io/cloud-builders/gcloud'
|
||||
entrypoint: 'bash'
|
||||
args:
|
||||
- '-c'
|
||||
- |
|
||||
PROJECT=$$(gcloud config get-value core/project)
|
||||
gcloud container clusters get-credentials "$${CLOUDSDK_CONTAINER_CLUSTER}" \
|
||||
--project "$${PROJECT}" \
|
||||
--zone "$${CLOUDSDK_COMPUTE_ZONE}"
|
||||
|
||||
cat <<EOF | kubectl apply -f -
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: $_PROJECT_NAME
|
||||
labels:
|
||||
app: $_PROJECT_NAME
|
||||
spec:
|
||||
ports:
|
||||
- port: 8080
|
||||
targetPort: 8080
|
||||
selector:
|
||||
app: $_PROJECT_NAME
|
||||
type:
|
||||
LoadBalancer
|
||||
EOF
|
||||
|
||||
cat <<EOF | kubectl apply -f -
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: $_PROJECT_NAME
|
||||
labels:
|
||||
app: $_PROJECT_NAME
|
||||
spec:
|
||||
replicas: 1
|
||||
selector:
|
||||
matchLabels:
|
||||
app: $_PROJECT_NAME
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app: $_PROJECT_NAME
|
||||
spec:
|
||||
containers:
|
||||
- name: $_PROJECT_NAME
|
||||
image: gcr.io/$PROJECT_ID/$_PROJECT_NAME:$COMMIT_SHA
|
||||
ports:
|
||||
- containerPort: 8080
|
||||
EOF
|
||||
|
||||
options:
|
||||
env:
|
||||
# # location/name of GKE cluster (used by all kubectl commands)
|
||||
- CLOUDSDK_COMPUTE_ZONE=asia-northeast1-a
|
||||
- CLOUDSDK_CONTAINER_CLUSTER=standard-cluster-1
|
||||
54
pom.xml
Normal file
54
pom.xml
Normal file
@@ -0,0 +1,54 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-parent</artifactId>
|
||||
<version>2.1.1.RELEASE</version>
|
||||
<relativePath/> <!-- lookup parent from repository -->
|
||||
</parent>
|
||||
<groupId>com.example</groupId>
|
||||
<artifactId>boot-camp-gateway</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
<name>boot-camp-gateway</name>
|
||||
|
||||
<properties>
|
||||
<java.version>1.8</java.version>
|
||||
<spring-cloud.version>Greenwich.RELEASE</spring-cloud.version>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
<!-- Add Stackdriver Trace Starter -->
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-actuator</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-starter-gateway</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<dependencyManagement>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-dependencies</artifactId>
|
||||
<version>${spring-cloud.version}</version>
|
||||
<type>pom</type>
|
||||
<scope>import</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</dependencyManagement>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
</project>
|
||||
18
src/main/java/com/example/template/Application.java
Normal file
18
src/main/java/com/example/template/Application.java
Normal file
@@ -0,0 +1,18 @@
|
||||
package com.example.template;
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
|
||||
@SpringBootApplication
|
||||
public class Application {
|
||||
|
||||
public static ApplicationContext applicationContext;
|
||||
public static void main(String[] args) {
|
||||
applicationContext = SpringApplication.run(Application.class, args);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
//package com.example.template;
|
||||
//
|
||||
//import com.nimbusds.jose.jwk.JWKSet;
|
||||
//import com.nimbusds.jose.jwk.RSAKey;
|
||||
//import org.springframework.security.oauth2.provider.endpoint.FrameworkEndpoint;
|
||||
//import org.springframework.web.bind.annotation.GetMapping;
|
||||
//import org.springframework.web.bind.annotation.ResponseBody;
|
||||
//import org.springframework.web.bind.annotation.RestController;
|
||||
//
|
||||
//import java.security.KeyPair;
|
||||
//import java.security.Principal;
|
||||
//import java.security.interfaces.RSAPublicKey;
|
||||
//import java.util.Map;
|
||||
//
|
||||
//@FrameworkEndpoint
|
||||
//@RestController
|
||||
//public class JwkSetEndpointConfiguration {
|
||||
// KeyPair keyPair;
|
||||
//
|
||||
// public JwkSetEndpointConfiguration(KeyPair keyPair) {
|
||||
// this.keyPair = keyPair;
|
||||
// }
|
||||
//
|
||||
// @GetMapping("/.well-known/jwks.json")
|
||||
// @ResponseBody
|
||||
// public Map<String, Object> getKey(Principal principal) {
|
||||
// RSAPublicKey publicKey = (RSAPublicKey) this.keyPair.getPublic();
|
||||
// RSAKey key = new RSAKey.Builder(publicKey).build();
|
||||
// return new JWKSet(key).toJSONObject();
|
||||
// }
|
||||
//}
|
||||
@@ -0,0 +1,42 @@
|
||||
//package com.example.template;
|
||||
//import org.springframework.context.annotation.Bean;
|
||||
//import org.springframework.context.annotation.Configuration;
|
||||
//import org.springframework.core.io.ClassPathResource;
|
||||
//import org.springframework.security.config.annotation.web.reactive.EnableWebFluxSecurity;
|
||||
//import org.springframework.security.config.web.server.ServerHttpSecurity;
|
||||
//import org.springframework.security.oauth2.provider.token.store.KeyStoreKeyFactory;
|
||||
//import org.springframework.security.web.server.SecurityWebFilterChain;
|
||||
//
|
||||
//import java.security.KeyPair;
|
||||
//
|
||||
//@Configuration
|
||||
//@EnableWebFluxSecurity
|
||||
//public class ResourceServerConfiguration {
|
||||
//
|
||||
// @Bean
|
||||
// SecurityWebFilterChain springSecurityFilterChain(ServerHttpSecurity http) throws Exception {
|
||||
//
|
||||
// http
|
||||
// .cors().and()
|
||||
// .csrf().disable()
|
||||
// .authorizeExchange()
|
||||
// .pathMatchers("/oauth/**","/login/**","/.well-known/jwks.json").permitAll()
|
||||
// .anyExchange().authenticated()
|
||||
// .and()
|
||||
// .oauth2ResourceServer()
|
||||
// .jwt()
|
||||
// ;
|
||||
//
|
||||
// return http.build();
|
||||
// }
|
||||
//
|
||||
// @Bean
|
||||
// public KeyPair makeKeyPair(){
|
||||
// KeyPair keyPair = new KeyStoreKeyFactory(
|
||||
// new ClassPathResource("server.jks"), "qweqwe".toCharArray())
|
||||
// .getKeyPair("uengine", "qweqwe".toCharArray());
|
||||
// return keyPair;
|
||||
// }
|
||||
//
|
||||
//
|
||||
//}
|
||||
85
src/main/resources/application.yml
Normal file
85
src/main/resources/application.yml
Normal file
@@ -0,0 +1,85 @@
|
||||
|
||||
server:
|
||||
port: 8088
|
||||
|
||||
---
|
||||
spring:
|
||||
profiles: default
|
||||
# security:
|
||||
# oauth2:
|
||||
# resourceserver:
|
||||
# jwt:
|
||||
# jwk-set-uri: http://localhost:8080/.well-known/jwks.json
|
||||
cloud:
|
||||
gateway:
|
||||
routes:
|
||||
- id: product
|
||||
uri: http://localhost:8081
|
||||
predicates:
|
||||
- Path=/product/**
|
||||
- id: order
|
||||
uri: http://localhost:8082
|
||||
predicates:
|
||||
- Path=/order/**
|
||||
- id: delivery
|
||||
uri: http://localhost:8083
|
||||
predicates:
|
||||
- Path=/deliverys/**
|
||||
- id: marketing
|
||||
uri: http://localhost:8084
|
||||
predicates:
|
||||
- Path=/serveys/**
|
||||
- id: servicecenter
|
||||
uri: http://localhost:8081
|
||||
predicates:
|
||||
- Path=/customers/**
|
||||
globalcors:
|
||||
corsConfigurations:
|
||||
'[/**]':
|
||||
allowedOrigins:
|
||||
- "*"
|
||||
allowedMethods:
|
||||
- "*"
|
||||
allowedHeaders:
|
||||
- "*"
|
||||
allowCredentials: true
|
||||
|
||||
|
||||
---
|
||||
spring:
|
||||
profiles: docker
|
||||
cloud:
|
||||
gateway:
|
||||
routes:
|
||||
- id: product
|
||||
uri: http://product:8080
|
||||
predicates:
|
||||
- Path=/product/**
|
||||
- id: order
|
||||
uri: http://order:8080
|
||||
predicates:
|
||||
- Path=/order/**
|
||||
- id: delivery
|
||||
uri: http://delivery:8080
|
||||
predicates:
|
||||
- Path=/deliveries/**
|
||||
- id: marketing
|
||||
uri: http://marketing:8080
|
||||
predicates:
|
||||
- Path=/serveys/**
|
||||
- id: servicecenter
|
||||
uri: http://servicecenter:8080
|
||||
predicates:
|
||||
- Path=/customers/**
|
||||
globalcors:
|
||||
corsConfigurations:
|
||||
'[/**]':
|
||||
allowedOrigins:
|
||||
- "*"
|
||||
allowedMethods:
|
||||
- "*"
|
||||
allowedHeaders:
|
||||
- "*"
|
||||
allowCredentials: true
|
||||
server:
|
||||
port: 8080
|
||||
BIN
src/main/resources/server.jks
Normal file
BIN
src/main/resources/server.jks
Normal file
Binary file not shown.
Reference in New Issue
Block a user