Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: use common chart, prepare for gcp2 #128

Closed
wants to merge 15 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 3 additions & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -111,4 +111,6 @@ workflows:
- build
filters:
branches:
only: master
only:
- master
- prepare-gcp2
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -43,3 +43,5 @@ src/main/resources/stops/agency.txt

local_config/
node_modules

.terraform
6 changes: 6 additions & 0 deletions helm/tiamat-gcp2/Chart.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
dependencies:
- name: common
repository: https://entur.github.io/helm-charts
version: 1.1.0
digest: sha256:24dad2384359deaa8d9e7ec582eb58aef4980abedfce52a84d9c3c6eea3b8eb0
generated: "2022-08-09T09:46:14.789654282+02:00"
17 changes: 17 additions & 0 deletions helm/tiamat-gcp2/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
apiVersion: v2
appVersion: "0.1.99.2"
description: NSR (National Stoppalce Register)
name: tiamat
version: 0.1.0
keywords:
- kakka
sources:
- https://github.com/entur/tiamat
maintainers:
- name: 'team-ror'
email: team.rutedata@entur.org
engine: gotpl
dependencies:
- name: common
version: 1.1.0
repository: "https://entur.github.io/helm-charts"
Binary file added helm/tiamat-gcp2/charts/common-1.1.0.tgz
Binary file not shown.
84 changes: 84 additions & 0 deletions helm/tiamat-gcp2/templates/configmap.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: tiamat-application
namespace: {{ .Release.Namespace }}
labels:
app: release-name
shortname: tiamatno
team: ror
data:
application.properties: |-
server.port={{ .Values.common.service.internalPort }}
nearbyStopsWithSameTypeFinder.limits={railStation:'200',airport:'3000'}
tariffzoneLookupService.resetReferences=true
publicationDeliveryStreamingOutput.validateAgainstSchema=true
publicationDeliveryUnmarshaller.validateAgainstSchema=true
netex.import.enabled.types=MERGE
changelog.publish.enabled=true
spring.activemq.broker-url=tcp://activemq.default:61616?jms.redeliveryPolicy.maximumRedeliveries=0
netex.id.valid.prefix.list={TopographicPlace:{'KVE','WOF','OSM','ENT','LAN'},TariffZone:{'*'},FareZone:{'*'},GroupOfTariffZones:{'*'}}
netex.profile.version=1.12:NO-NeTEx-stops:1.4

# GCS properties
blobstore.gcs.bucket.name={{.Values.configMap.gcsBucketName}}
blobstore.gcs.blob.path=export
blobstore.gcs.project.id={{.Values.configMap.blobstoreProjectId}}

# Database properties
spring.jpa.properties.javax.persistence.query.timeout=15000
spring.jpa.properties.hibernate.dialect=org.hibernate.spatial.dialect.postgis.PostgisDialect
spring.jpa.properties.hibernate.cache.region.factory_class=org.rutebanken.tiamat.hazelcast.TiamatHazelcastCacheRegionFactory
spring.jpa.properties.hibernate.cache.use_second_level_cache=true
spring.jpa.properties.hibernate.cache.use_minimal_puts=true
spring.jpa.properties.hibernate.cache.use_query_cache=true
spring.jpa.hibernate.ddl-auto=none
spring.jpa.hibernate.use-new-id-generator-mappings=true
spring.jpa.open-in-view=false
spring.jpa.database=POSTGRESQL
spring.jpa.show-sql=false
spring.database.driverClassName=org.postgresql.Driver
spring.datasource.hikari.maximumPoolSize=30
spring.datasource.url=jdbc:postgresql://localhost:5432/{{ .Values.tiamat.database }}
spring.datasource.username=tiamat
spring.datasource.platform=postgres
spring.datasource.password=${PGPASSWORD}
graphql.query.max.depth =100


#flyway
spring.flyway.table =schema_version



# Security config with auth0

authorization.enabled=true

#OAuth2 Resource Server
spring.security.oauth2.resourceserver.jwt.issuer-uri={{ .Values.auth0.ror.url }}/
tiamat.oauth2.resourceserver.auth0.ror.jwt.audience={{ .Values.auth0.ror.audience }}
tiamat.oauth2.resourceserver.auth0.ror.claim.namespace=https://ror.entur.io/


# Logging Properties
logging.level.org.rutebanken.tiamat=INFO
logging.level.org.rutebanken.tiamat.repository=DEBUG
logging.level.org.rutebanken.tiamat.importer.finder=INFO
logging.level.org.rutebanken.tiamat.dtoassembling.disassembler.StopPlaceSearchDisassembler=WARN
logging.level.org.rutebanken.tiamat.rest.netex.publicationdelivery.PublicationDeliveryUnmarshaller=INFO
logging.level.org.rutebanken.tiamat.rest.netex.publicationdelivery=INFO
logging.level.org.rutebanken.tiamat.rest.netex.publicationdelivery.PublicationDeliveryStreamingOutput=INFO
logging.level.org.springframework.orm.hibernate4.support=WARN
logging.level.org.hibernate.SQL=WARN
logging.level.org.hibernate.tool.hbm2ddl=INFO
logging.level.org.hibernate.type=WARN
logging.level.org.hibernate.id.enhanced=INFO

#Profile
spring.profiles.active=gcs-blobstore,google-pubsub

# pubsub
spring.cloud.gcp.project-id={{ .Values.configMap.pubsubProjectId }}
changelog.topic.name={{ .Values.configMap.pubsubTopicName }}

14 changes: 14 additions & 0 deletions helm/tiamat-gcp2/values-kub-ent-dev-nordic.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
common:
app: tiamat-nordic
env: dev

configMap:
blobstoreProjectId: entur-ror-dev
pubsubProjectId: entur-ror-dev
pubsubTopicName: ror.tiamat-nordic.changelog
gcsBucketName: tiamat-nordic-dev

auth0:
ror:
url: https://ror-entur-dev.eu.auth0.com
audience: https://ror.api.dev.entur.io
2 changes: 2 additions & 0 deletions helm/tiamat-gcp2/values-kub-ent-dev.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
common:
env: dev
2 changes: 2 additions & 0 deletions helm/tiamat-gcp2/values-kub-ent-prd.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
common:
env: prd
2 changes: 2 additions & 0 deletions helm/tiamat-gcp2/values-kub-ent-tst.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
common:
env: tst
45 changes: 45 additions & 0 deletions helm/tiamat-gcp2/values.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
tiamat:
database: tiamat-ns
common:
app: tiamat
shortname: tiamatno
team: ror
service:
internalPort: 8777
ingress:
host: stop-places-v1-nordic.dev.entur.io
trafficType: api
container:
image: ${artifact.metadata.image}
cpu: 1.2
memory: 7500
probes:
liveness:
path: /health/live
readiness:
path: /health/ready
envFrom:
- configMapRef:
name: tiamat-application
prometheus:
enabled: true
path: /health/scrape
volumeMounts:
- mountPath: /etc/application-config
name: application-config
readOnly: true
volumes:
- configMap:
defaultMode: 420
name: tiamat-application
name: application-config
postgres:
enabled: true
configmap:
data:
JAVA_OPTIONS: -server -Xss1024m -Xmx7g -Dspring.config.location=/etc/application-config/application.properties
-Dfile.encoding=UTF-8 -Drutebanken.kubernetes.enabled=true -Drutebanken.hazelcast.management.url=http://tiamat-hzmgmt/mancenter/
-Drutebanken.kubernetes.namespace=default -Dhazelcast.ignoreXxeProtectionFailures=true
TZ: Europe/Oslo
enabled: true
toEnv: true
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
package org.rutebanken.tiamat.service;

import com.google.cloud.storage.Storage;
import com.google.cloud.http.HttpTransportOptions;
import com.google.cloud.storage.StorageOptions;
import org.rutebanken.helper.gcp.BlobStoreHelper;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
Expand All @@ -30,23 +32,21 @@
@Profile("gcs-blobstore")
public class GcsBlobStoreService implements BlobStoreService {

private static final int CONNECT_AND_READ_TIMEOUT = 60000;
private static final Logger logger = LoggerFactory.getLogger(GcsBlobStoreService.class);

private final String bucketName;

private final String blobPath;
private final String credentialPath;
private final String projectId;


public GcsBlobStoreService(@Value("${blobstore.gcs.credential.path}") String credentialPath,
@Value("${blobstore.gcs.bucket.name}") String bucketName,
public GcsBlobStoreService(@Value("${blobstore.gcs.bucket.name}") String bucketName,
@Value("${blobstore.gcs.blob.path}") String blobPath,
@Value("${blobstore.gcs.project.id}") String projectId) {

this.bucketName = bucketName;
this.blobPath = blobPath;
this.credentialPath = credentialPath;
this.projectId = projectId;
}

Expand All @@ -62,11 +62,19 @@ public void upload(String fileName, InputStream inputStream) {
}

public Storage getStorage() {
logger.info("Get storage for project {}", projectId);

try {
logger.info("Get storage for project {}", projectId);
return BlobStoreHelper.getStorage(credentialPath, projectId);
HttpTransportOptions transportOptions = StorageOptions.getDefaultHttpTransportOptions();
transportOptions = transportOptions.toBuilder().setConnectTimeout(CONNECT_AND_READ_TIMEOUT).setReadTimeout(CONNECT_AND_READ_TIMEOUT)
.build();

return StorageOptions.newBuilder()
.setProjectId(projectId)
.setTransportOptions(transportOptions)
.build().getService();
} catch (RuntimeException e) {
throw new RuntimeException("Error setting up BlobStore from blobstore.gcs.credential.path '" + credentialPath + "' and blobstore.gcs.project.id '" + projectId + "'", e);
throw new RuntimeException(e);
}
}

Expand Down
1 change: 0 additions & 1 deletion src/test/resources/application.properties
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ blobstore.gcs.blob.path=exports
blobstore.gcs.bucket.name=tiamat-test

# Replace with your gcload storage
blobstore.gcs.credential.path=gcloud-storage.json
blobstore.gcs.project.id=carbon-1287

server.port=1888
Expand Down
1 change: 1 addition & 0 deletions terraform-nordic/.tool-versions
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
terraform 0.13.2
5 changes: 5 additions & 0 deletions terraform-nordic/backend.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
terraform {
backend "gcs" {
bucket = "ent-gcs-tfa-tiamatno"
}
}
1 change: 1 addition & 0 deletions terraform-nordic/env/kub-ent-dev.tfvars
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
env = "dev"
49 changes: 49 additions & 0 deletions terraform-nordic/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
locals {
topic_name = "${module.init.app.owner}.${module.init.app.name}.changelog"
}

# Terraform configuration for tiamat
module "init" {
source = "github.com/entur/terraform-google-init//modules/init?ref=v0.2.1"
app_id = "tiamatno"
environment = var.env
}

# https://github.com/entur/terraform-google-sql-db/tree/master/modules/postgresql#inputs
module "postgres" {
source = "github.com/entur/terraform-google-sql-db//modules/postgresql?ref=v0.1.2"
init = module.init
generation = 1
database_version = "POSTGRES_14"
databases = ["tiamatno"]
}

# https://github.com/entur/terraform-google-cloud-storage/tree/master/modules/bucket#inputs
module "cloud-storage" {
source = "github.com/entur/terraform-google-cloud-storage//modules/bucket?ref=v0.1.0"
init = module.init
}

# Create folder in a bucket
resource "google_storage_bucket_object" "content_folder" {
name = "export/"
content = "Not really a directory, but it's empty."
bucket = module.cloud-storage.cloud_storage_bucket.name
}

# Create pubsub topic
resource "google_pubsub_topic" "changelog" {
name = local.topic_name
project = module.init.app.project_id
labels = module.init.labels
}

# Create pubsub subscription
resource "google_pubsub_subscription" "changelog-subscription" {
name = local.topic_name
topic = google_pubsub_topic.changelog.name
project = module.init.app.project_id
labels = module.init.labels
}


3 changes: 3 additions & 0 deletions terraform-nordic/variables.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
variable "env" {
description = "Environment. dev|tst|prd."
}