-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
836a97f2b387ff921591f967e601145c2001c0dc
- Loading branch information
0 parents
commit 8de0b79
Showing
18 changed files
with
448 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,105 @@ | ||
version: 2 | ||
jobs: | ||
build: | ||
docker: | ||
- image: circleci/openjdk:8u171-jdk | ||
working_directory: ~/repo | ||
environment: | ||
MAVEN_OPTS: -Xmx3200m | ||
steps: | ||
- checkout | ||
- restore_cache: | ||
keys: | ||
- v1-dependencies-{{ checksum "pom.xml" }} | ||
- v1-dependencies- | ||
- run: mvn dependency:go-offline | ||
- save_cache: | ||
paths: | ||
- ~/.m2 | ||
key: v1-dependencies-{{ checksum "pom.xml" }} | ||
- run: mvn package | ||
- run: | ||
name: Codecov | ||
command: | | ||
bash <(curl -s https://codecov.io/bash) | ||
- persist_to_workspace: | ||
root: target | ||
paths: | ||
- config.jar | ||
deploy_registry: | ||
docker: | ||
- image: docker:18.06.1-ce-git | ||
working_directory: ~/repo | ||
steps: | ||
- checkout | ||
- setup_remote_docker | ||
- attach_workspace: | ||
at: target | ||
- run: | ||
name: Docker build and push | ||
command: | | ||
docker login -u ${DOCKER_USER} -p ${DOCKER_PASS} | ||
docker build \ | ||
--build-arg COMMIT_REF=${CIRCLE_SHA1} \ | ||
--build-arg BUILD_DATE=`date -u +”%Y-%m-%dT%H:%M:%SZ”` \ | ||
-t ${SERVICE_NAME} . | ||
docker tag ${SERVICE_NAME} ${DOCKER_USER}/${IMAGE_NAME}:${CIRCLE_SHA1} | ||
docker tag ${SERVICE_NAME} ${DOCKER_USER}/${IMAGE_NAME}:latest | ||
docker push ${DOCKER_USER}/${IMAGE_NAME}:${CIRCLE_SHA1} | ||
docker push ${DOCKER_USER}/${IMAGE_NAME}:latest | ||
deploy_gcp: | ||
docker: | ||
- image: google/cloud-sdk | ||
working_directory: ~/repo | ||
steps: | ||
- checkout | ||
- attach_workspace: | ||
at: target | ||
- run: | ||
name: Setup Google Cloud SDK | ||
command: | | ||
echo $GCLOUD_SERVICE_KEY > ${HOME}/gcloud-service-key.json | ||
gcloud auth activate-service-account --key-file=${HOME}/gcloud-service-key.json | ||
gcloud --quiet config set project ${GOOGLE_PROJECT_ID} | ||
gcloud --quiet config set compute/zone ${GOOGLE_COMPUTE_ZONE} | ||
gcloud --quiet container clusters get-credentials ${GOOGLE_CLUSTER_NAME} | ||
- setup_remote_docker | ||
- run: | ||
name: Docker build and push | ||
command: | | ||
docker build \ | ||
--build-arg COMMIT_REF=${CIRCLE_SHA1} \ | ||
--build-arg BUILD_DATE=`date -u +”%Y-%m-%dT%H:%M:%SZ”` \ | ||
-t ${SERVICE_NAME} . | ||
docker tag ${SERVICE_NAME} us.gcr.io/${GOOGLE_PROJECT_ID}/${IMAGE_NAME}:${CIRCLE_SHA1} | ||
gcloud auth print-access-token | docker login -u oauth2accesstoken --password-stdin https://us.gcr.io | ||
docker push us.gcr.io/${GOOGLE_PROJECT_ID}/${IMAGE_NAME}:${CIRCLE_SHA1} | ||
- run: | ||
name: Deploy to Kubernetes | ||
command: | | ||
kubectl patch deployment "$SERVICE_NAME" -p '{"spec":{"template":{"spec":{"containers":[{"name":"'"$SERVICE_NAME"'","image":"us.gcr.io/'"$GOOGLE_PROJECT_ID"'/'"$IMAGE_NAME"':'"$CIRCLE_SHA1"'"}]}}}}' | ||
workflows: | ||
version: 2 | ||
test_build_and_deploy: | ||
jobs: | ||
- build | ||
- deploy_registry: | ||
requires: | ||
- build | ||
filters: | ||
branches: | ||
only: master | ||
- request-testing: | ||
type: approval | ||
requires: | ||
- build | ||
filters: | ||
branches: | ||
only: master | ||
- deploy_gcp: | ||
requires: | ||
- build | ||
- request-testing | ||
filters: | ||
branches: | ||
only: master |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
# Intellij | ||
.idea/ | ||
*.iml | ||
*.iws | ||
|
||
# Mac | ||
.DS_Store | ||
|
||
# Maven | ||
log/ | ||
target/ | ||
|
||
# Eclipse | ||
**/*.project | ||
**/*.classpath | ||
**/*.settings |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
FROM java:8-jre-alpine | ||
|
||
ENV APP_COMMIT_REF=${COMMIT_REF} \ | ||
APP_BUILD_DATE=${BUILD_DATE} | ||
|
||
ADD ./target/config.jar /app/ | ||
CMD ["java", "-Xmx200m", "-jar", "/app/config.jar"] | ||
|
||
HEALTHCHECK --interval=30s --timeout=30s CMD curl -f http://localhost:8888/actuator/health || exit 1 | ||
|
||
EXPOSE 8888 |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
The MIT License (MIT) | ||
|
||
Copyright (c) 2016 Alexander Lukyanchikov, http://sqshq.com | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
# Piggy Metrics (Kubernetes) - Config service | ||
|
||
[![CircleCI](https://circleci.com/gh/afermon/PiggyMetrics-config-service.svg?style=svg)](https://circleci.com/gh/afermon/PiggyMetrics-config-service) [![codecov](https://codecov.io/gh/afermon/PiggyMetrics-config-service/branch/master/graph/badge.svg)](https://codecov.io/gh/afermon/PiggyMetrics-config-service) [![GitHub license](https://img.shields.io/github/license/mashape/apistatus.svg)](https://github.com/afermon/PiggyMetrics-config-service/blob/master/LICENCE) | ||
|
||
[Spring Cloud Config](http://cloud.spring.io/spring-cloud-config/spring-cloud-config.html) is horizontally scalable centralized configuration service for distributed systems. It uses a pluggable repository layer that currently supports local storage, Git, and Subversion. | ||
|
||
In this project, I use `native profile`, which simply loads config files from the local classpath. You can see `shared` directory in [Config service resources](https://github.com/sqshq/PiggyMetrics/tree/master/config/src/main/resources). Now, when Notification-service requests it's configuration, Config service responses with `shared/notification-service.yml` and `shared/application.yml` (which is shared between all client applications). | ||
|
||
For more information please refer to the main repository [afermon/PiggyMetrics-Kubernetes](https://github.com/afermon/PiggyMetrics-Kubernetes) | ||
|
||
## Refereces | ||
* Forked from [sqshq/PiggyMetrics](https://github.com/sqshq/PiggyMetrics) |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
<?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> | ||
|
||
<artifactId>config</artifactId> | ||
<version>1.0.0-SNAPSHOT</version> | ||
<packaging>jar</packaging> | ||
|
||
<name>config</name> | ||
<description>Configuration Server</description> | ||
|
||
<parent> | ||
<groupId>com.piggymetrics</groupId> | ||
<artifactId>piggymetrics</artifactId> | ||
<version>1.0-SNAPSHOT</version> | ||
</parent> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>org.springframework.cloud</groupId> | ||
<artifactId>spring-cloud-config-server</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-starter-security</artifactId> | ||
</dependency> | ||
</dependencies> | ||
|
||
<build> | ||
<plugins> | ||
<plugin> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-maven-plugin</artifactId> | ||
<configuration> | ||
<finalName>config</finalName> | ||
</configuration> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
|
||
</project> |
14 changes: 14 additions & 0 deletions
14
src/main/java/com/piggymetrics/config/ConfigApplication.java
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package com.piggymetrics.config; | ||
|
||
import org.springframework.boot.SpringApplication; | ||
import org.springframework.boot.autoconfigure.SpringBootApplication; | ||
import org.springframework.cloud.config.server.EnableConfigServer; | ||
|
||
@SpringBootApplication | ||
@EnableConfigServer | ||
public class ConfigApplication { | ||
|
||
public static void main(String[] args) { | ||
SpringApplication.run(ConfigApplication.class, args); | ||
} | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package com.piggymetrics.config; | ||
|
||
import org.springframework.context.annotation.Configuration; | ||
import org.springframework.security.config.annotation.web.builders.HttpSecurity; | ||
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter; | ||
|
||
/** | ||
* @author cdov | ||
*/ | ||
@Configuration | ||
public class SecurityConfig extends WebSecurityConfigurerAdapter { | ||
|
||
@Override | ||
protected void configure(HttpSecurity http) throws Exception { | ||
http.csrf().disable(); | ||
http | ||
.authorizeRequests() | ||
.antMatchers("/actuator/**").permitAll() | ||
.anyRequest().authenticated() | ||
.and() | ||
.httpBasic() | ||
; | ||
} | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
spring: | ||
cloud: | ||
config: | ||
server: | ||
native: | ||
search-locations: classpath:/shared | ||
profiles: | ||
active: native | ||
security: | ||
user: | ||
password: ${CONFIG_SERVICE_PASSWORD} | ||
|
||
server: | ||
port: 8888 | ||
|
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
security: | ||
oauth2: | ||
client: | ||
clientId: account-service | ||
clientSecret: ${ACCOUNT_SERVICE_PASSWORD} | ||
accessTokenUri: http://auth-service:5000/uaa/oauth/token | ||
grant-type: client_credentials | ||
scope: server | ||
|
||
spring: | ||
data: | ||
mongodb: | ||
host: account-mongodb | ||
username: user | ||
password: ${MONGODB_PASSWORD} | ||
database: piggymetrics | ||
port: 27017 | ||
|
||
server: | ||
servlet: | ||
context-path: /accounts | ||
port: 6000 | ||
|
||
feign: | ||
hystrix: | ||
enabled: true |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
logging: | ||
level: | ||
org.springframework.security: INFO | ||
|
||
hystrix: | ||
command: | ||
default: | ||
execution: | ||
isolation: | ||
thread: | ||
timeoutInMilliseconds: 10000 | ||
|
||
eureka: | ||
instance: | ||
prefer-ip-address: true | ||
client: | ||
serviceUrl: | ||
defaultZone: http://registry:8761/eureka/ | ||
|
||
security: | ||
oauth2: | ||
resource: | ||
user-info-uri: http://auth-service:5000/uaa/users/current | ||
|
||
spring: | ||
rabbitmq: | ||
host: rabbitmq |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
spring: | ||
data: | ||
mongodb: | ||
host: auth-mongodb | ||
username: user | ||
password: ${MONGODB_PASSWORD} | ||
database: piggymetrics | ||
port: 27017 | ||
|
||
server: | ||
servlet: | ||
context-path: /uaa | ||
port: 5000 |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
hystrix: | ||
command: | ||
default: | ||
execution: | ||
isolation: | ||
thread: | ||
timeoutInMilliseconds: 20000 | ||
|
||
ribbon: | ||
ReadTimeout: 20000 | ||
ConnectTimeout: 20000 | ||
|
||
zuul: | ||
ignoredServices: '*' | ||
host: | ||
connect-timeout-millis: 20000 | ||
socket-timeout-millis: 20000 | ||
|
||
routes: | ||
auth-service: | ||
path: /uaa/** | ||
url: http://auth-service:5000 | ||
stripPrefix: false | ||
sensitiveHeaders: | ||
|
||
account-service: | ||
path: /accounts/** | ||
serviceId: account-service | ||
stripPrefix: false | ||
sensitiveHeaders: | ||
|
||
statistics-service: | ||
path: /statistics/** | ||
serviceId: statistics-service | ||
stripPrefix: false | ||
sensitiveHeaders: | ||
|
||
notification-service: | ||
path: /notifications/** | ||
serviceId: notification-service | ||
stripPrefix: false | ||
sensitiveHeaders: | ||
|
||
server: | ||
port: 4000 |
Empty file.
Oops, something went wrong.