-
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.
- Loading branch information
Showing
16 changed files
with
4,473 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
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,3 @@ | ||
apiVersion: v2 | ||
name: currencyservice | ||
version: 1.0.0 |
54 changes: 54 additions & 0 deletions
54
app/.helm/charts/currencyservice/templates/deployment.yaml
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,54 @@ | ||
--- | ||
apiVersion: apps/v1 | ||
kind: Deployment | ||
metadata: | ||
name: currencyservice | ||
spec: | ||
selector: | ||
matchLabels: | ||
app: currencyservice | ||
template: | ||
metadata: | ||
labels: | ||
app: currencyservice | ||
spec: | ||
serviceAccountName: default | ||
terminationGracePeriodSeconds: 5 | ||
securityContext: | ||
fsGroup: 1000 | ||
runAsGroup: 1000 | ||
runAsNonRoot: true | ||
runAsUser: 1000 | ||
imagePullSecrets: | ||
- name: registrysecret | ||
containers: | ||
- name: server | ||
securityContext: | ||
allowPrivilegeEscalation: false | ||
capabilities: | ||
drop: | ||
- ALL | ||
privileged: false | ||
readOnlyRootFilesystem: true | ||
image: {{ $.Values.werf.image.currencyservice }} | ||
ports: | ||
- name: grpc | ||
containerPort: 7000 | ||
env: | ||
- name: PORT | ||
value: "7000" | ||
- name: DISABLE_PROFILER | ||
value: "1" | ||
readinessProbe: | ||
grpc: | ||
port: 7000 | ||
livenessProbe: | ||
grpc: | ||
port: 7000 | ||
resources: | ||
requests: | ||
cpu: 100m | ||
memory: 64Mi | ||
limits: | ||
cpu: 200m | ||
memory: 128Mi |
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 @@ | ||
--- | ||
apiVersion: v1 | ||
kind: Service | ||
metadata: | ||
name: currencyservice | ||
spec: | ||
type: ClusterIP | ||
selector: | ||
app: currencyservice | ||
ports: | ||
- name: grpc | ||
port: 7000 | ||
targetPort: 7000 |
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,2 @@ | ||
client.js | ||
node_modules/ |
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 @@ | ||
node_modules/ |
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 @@ | ||
# Copyright 2020 Google LLC | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
FROM node:20.11.0-alpine@sha256:8e6a472eb9742f4f486ca9ef13321b7fc2e54f2f60814f339eeda2aff3037573 as base | ||
|
||
FROM base as builder | ||
|
||
# Some packages (e.g. @google-cloud/profiler) require additional | ||
# deps for post-install scripts | ||
RUN apk add --update --no-cache \ | ||
python3 \ | ||
make \ | ||
g++ | ||
|
||
WORKDIR /usr/src/app | ||
|
||
COPY package*.json ./ | ||
|
||
RUN npm install --only=production | ||
|
||
FROM base | ||
|
||
WORKDIR /usr/src/app | ||
|
||
COPY --from=builder /usr/src/app/node_modules ./node_modules | ||
|
||
COPY . . | ||
|
||
EXPOSE 7000 | ||
|
||
ENTRYPOINT [ "node", "server.js" ] |
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,68 @@ | ||
/* | ||
* | ||
* Copyright 2015 gRPC authors. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
* | ||
*/ | ||
require('@google-cloud/trace-agent').start(); | ||
|
||
const path = require('path'); | ||
const grpc = require('grpc'); | ||
const pino = require('pino'); | ||
|
||
const PROTO_PATH = path.join(__dirname, './proto/demo.proto'); | ||
const PORT = 7000; | ||
|
||
const shopProto = grpc.load(PROTO_PATH).hipstershop; | ||
const client = new shopProto.CurrencyService(`localhost:${PORT}`, | ||
grpc.credentials.createInsecure()); | ||
|
||
const logger = pino({ | ||
name: 'currencyservice-client', | ||
messageKey: 'message', | ||
formatters: { | ||
level (logLevelString, logLevelNum) { | ||
return { severity: logLevelString } | ||
} | ||
} | ||
}); | ||
|
||
const request = { | ||
from: { | ||
currency_code: 'CHF', | ||
units: 300, | ||
nanos: 0 | ||
}, | ||
to_code: 'EUR' | ||
}; | ||
|
||
function _moneyToString (m) { | ||
return `${m.units}.${m.nanos.toString().padStart(9,'0')} ${m.currency_code}`; | ||
} | ||
|
||
client.getSupportedCurrencies({}, (err, response) => { | ||
if (err) { | ||
logger.error(`Error in getSupportedCurrencies: ${err}`); | ||
} else { | ||
logger.info(`Currency codes: ${response.currency_codes}`); | ||
} | ||
}); | ||
|
||
client.convert(request, (err, response) => { | ||
if (err) { | ||
logger.error(`Error in convert: ${err}`); | ||
} else { | ||
logger.log(`Convert: ${_moneyToString(request.from)} to ${_moneyToString(response)}`); | ||
} | ||
}); |
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,35 @@ | ||
{ | ||
"EUR": "1.0", | ||
"USD": "1.1305", | ||
"JPY": "126.40", | ||
"BGN": "1.9558", | ||
"CZK": "25.592", | ||
"DKK": "7.4609", | ||
"GBP": "0.85970", | ||
"HUF": "315.51", | ||
"PLN": "4.2996", | ||
"RON": "4.7463", | ||
"SEK": "10.5375", | ||
"CHF": "1.1360", | ||
"ISK": "136.80", | ||
"NOK": "9.8040", | ||
"HRK": "7.4210", | ||
"RUB": "74.4208", | ||
"TRY": "6.1247", | ||
"AUD": "1.6072", | ||
"BRL": "4.2682", | ||
"CAD": "1.5128", | ||
"CNY": "7.5857", | ||
"HKD": "8.8743", | ||
"IDR": "15999.40", | ||
"ILS": "4.0875", | ||
"INR": "79.4320", | ||
"KRW": "1275.05", | ||
"MXN": "21.7999", | ||
"MYR": "4.6289", | ||
"NZD": "1.6679", | ||
"PHP": "59.083", | ||
"SGD": "1.5349", | ||
"THB": "36.012", | ||
"ZAR": "16.0583" | ||
} |
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,23 @@ | ||
#!/bin/bash -eu | ||
# | ||
# Copyright 2018 Google LLC | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
# [START gke_currencyservice_genproto] | ||
|
||
# protos are loaded dynamically for node, simply copies over the proto. | ||
mkdir -p proto | ||
cp -r ../../protos/* ./proto | ||
|
||
# [END gke_currencyservice_genproto] |
Oops, something went wrong.