Skip to content

Commit 1a00a73

Browse files
authored
CORE-2512: Add mode and topology (#13)
add a new dropdown option `gatewayFlow` that encompasses the topology and direction of the gateway also: * add `externalPort` variable for the external load balancer port * add `billing-gateway` tag and apply it to the billing container so that we don't end up targeting the billing container with the load balancer
1 parent 29d4118 commit 1a00a73

File tree

11 files changed

+104
-22
lines changed

11 files changed

+104
-22
lines changed

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
2.15.5
1+
3.4.2

chart/gateway/data-test/schema.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,11 @@ properties:
3333
default: fake-gatewayApiSecret
3434
x-google-marketplace:
3535
type: STRING
36+
gatewayFlow:
37+
type: string
38+
default: "Outbound - Data Loss Prevention"
39+
x-google-marketplace:
40+
type: STRING
3641
primaryMailingDomain:
3742
type: string
3843
default: example.com

chart/gateway/templates/NOTES.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
NOTE: It may take a few minutes for the LoadBalancer IP to be available.
1414
You can watch the status of by running 'kubectl get --namespace {{ .Release.Namespace }} svc -w {{ include "gateway.fullname" . }}'
1515
export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ include "gateway.fullname" . }} --template "{{"{{ range (index .status.loadBalancer.ingress 0) }}{{.}}{{ end }}"}}")
16-
echo http://$SERVICE_IP:{{ .Values.service.port }}
16+
echo http://$SERVICE_IP:{{ .Values.service.externalPort }}
1717
{{- else if contains "ClusterIP" .Values.service.type }}
1818
export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app.kubernetes.io/name={{ include "gateway.name" . }},app.kubernetes.io/instance={{ .Release.Name }}" -o jsonpath="{.items[0].metadata.name}")
1919
echo "Visit http://127.0.0.1:8080 to use your application"

chart/gateway/templates/_helpers.tpl

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@ Expand the name of the chart.
55
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }}
66
{{- end }}
77

8+
{{- define "billing.name" -}}
9+
{{- printf "billing-%s" (default .Chart.Name .Values.nameOverride) | trunc 63 | trimSuffix "-" }}
10+
{{- end}}
11+
812
{{/*
913
Create a default fully qualified app name.
1014
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
@@ -50,6 +54,11 @@ app.kubernetes.io/name: {{ include "gateway.name" . }}
5054
app.kubernetes.io/instance: {{ .Release.Name }}
5155
{{- end }}
5256

57+
{{- define "billing.selectorLabels" -}}
58+
app.kubernetes.io/name: {{ include "billing.name" . }}
59+
app.kubernetes.io/instance: {{ .Release.Name }}
60+
{{- end }}
61+
5362
{{/*
5463
Create the name of the service account to use
5564
*/}}
Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,19 @@ data:
99
GATEWAY_ACM_URL: {{ .Values.gatewayAcmUrl }}
1010
GATEWAY_API_TOKEN_NAME: {{ .Values.gatewayApiTokenName }}
1111
GATEWAY_HOSTNAME: {{ .Values.gatewayHostname }}
12-
GATEWAY_MODE: {{ .Values.gatewayMode }}
1312
GATEWAY_ORGANIZATION_DOMAIN: {{ .Values.primaryMailingDomain }}
14-
GATEWAY_TOPOLOGY: {{ .Values.gatewayTopology }}
13+
{{- if contains "data loss prevention" (lower .Values.gatewayFlow) }}
14+
GATEWAY_MODE: "dlp"
15+
{{- else if contains "encrypt" (lower .Values.gatewayFlow) }}
16+
GATEWAY_MODE: "encrypt-everything"
17+
{{- else }}
18+
GATEWAY_MODE: "decrypt-everything"
19+
{{- end }}
20+
{{- if contains "inbound" (lower .Values.gatewayFlow) }}
21+
GATEWAY_TOPOLOGY: "inbound"
22+
{{- else }}
23+
GATEWAY_TOPOLOGY: "outbound"
24+
{{- end }}
1525
GATEWAY_REMOTE_CONTENT_BASE_URL: {{ .Values.gatewayRemoteContentBaseUrl }}
1626
GATEWAY_PROXY_PROTOCOL: "0"
1727
GATEWAY_TRANSPORT_MAPS: '*=>[smtp-relay.gmail.com]:587'

chart/gateway/templates/deployment-billing.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ metadata:
77
spec:
88
selector:
99
matchLabels:
10-
{{- include "gateway.selectorLabels" . | nindent 6 }}
10+
{{- include "billing.selectorLabels" . | nindent 6 }}
1111
# Use a single replica. Multiple replicas may cause duplicate billing.
1212
replicas: 1
1313
strategy:
@@ -19,7 +19,7 @@ spec:
1919
{{- toYaml . | nindent 8 }}
2020
{{- end }}
2121
labels:
22-
{{- include "gateway.selectorLabels" . | nindent 8 }}
22+
{{- include "billing.selectorLabels" . | nindent 8 }}
2323
spec:
2424
{{- with .Values.imagePullSecrets }}
2525
imagePullSecrets:

chart/gateway/templates/service.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ metadata:
1111
spec:
1212
type: {{ .Values.service.type }}
1313
ports:
14-
- port: {{ .Values.service.port }}
14+
- port: {{ .Values.service.externalPort }}
1515
targetPort: {{ .Values.service.port }}
1616
protocol: TCP
1717
selector:

chart/gateway/values.yaml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@ securityContext: {}
3030

3131
service:
3232
type: LoadBalancer
33-
port: 2525
33+
port: 25
34+
externalPort: 2525
3435
annotations:
3536
external-dns.alpha.kubernetes.io/hostname: gateway-development.preprod.virtru.com
3637

@@ -57,7 +58,5 @@ gatewayRemoteContentBaseUrl: https://secure.virtru.com/start
5758
gatewayHostname: my-domain.example.com
5859
gatewayApiTokenName: my-token
5960
gatewayApiSecret: my-secret
60-
gatewayMode: encrypt-everything
61-
gatewayTopology: outbound
6261
gatewayTransportMaps: '*=>[smtp-relay.gmail.com]:587'
6362
ubbagentImage: "gcr.io/cloud-marketplace-tools/metering/ubbagent:latest"

gke-deploy.sh

Lines changed: 32 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,17 +17,43 @@
1717

1818
set -eu
1919

20-
export TAG=2.15.4;
21-
export DEPLOYER_VERSION=2.15;
22-
export REGISTRY=gcr.io/virtru-public/staging/gateway;
20+
if [[ "${ENVIRONMENT:-}" = 'production' ]]; then
21+
export REGISTRY=gcr.io/virtru-public/gateway;
22+
printf 'Deploying to production. Using registry [%s]\n' $REGISTRY
23+
else
24+
export REGISTRY=gcr.io/virtru-public/staging/gateway;
25+
printf 'Deploying to staging. Using registry [%s]\n' $REGISTRY
26+
fi
27+
28+
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
29+
VERSION="$(< "${SCRIPT_DIR}/VERSION" )"
30+
31+
export TAG="${VERSION}";
32+
export DEPLOYER_VERSION="$(echo "${VERSION}" | cut -d'.' -f 1-2)";
33+
34+
printf 'Using container tag = [%s] and deployer version = [%s]\n' $TAG $DEPLOYER_VERSION
35+
2336
docker build --no-cache --build-arg TAG=$TAG --build-arg REGISTRY=$REGISTRY \
24-
-t "${REGISTRY}/deployer:${DEPLOYER_VERSION}" -f dev.Dockerfile .
37+
-t "${REGISTRY}/deployer:${DEPLOYER_VERSION}" -f dev.Dockerfile "${SCRIPT_DIR}"
38+
2539
docker push "${REGISTRY}/deployer:${DEPLOYER_VERSION}"
2640

2741
# reportingSecret:
2842
# To actually report to the real Google ServiceControlEndpoint use "gateway-reportingsecret"
2943
# To make sure not to bill, use "gs://cloud-marketplace-tools/reporting_secrets/fake_reporting_secret.yaml"}'
44+
parameters=$(cat <<virtruparams
45+
{
46+
"name": "gateway",
47+
"namespace": "virtru",
48+
"gatewayHostname": "gateway-development.virtru.com",
49+
"gatewayApiTokenName": "token",
50+
"gatewayApiSecret": "mysecret",
51+
"numberOfLicenses":"10",
52+
"primaryMailingDomain":"virtru.example.com",
53+
"reportingSecret":"gs://cloud-marketplace-tools/reporting_secrets/fake_reporting_secret.yaml"
54+
}
55+
virtruparams
56+
)
3057

3158
# mpdev install to install, mpdev verify to test
32-
mpdev install --deployer="${REGISTRY}/deployer:${DEPLOYER_VERSION}" \
33-
--parameters='{"name": "gateway", "namespace": "virtru", "gatewayHostname": "gateway-development.virtru.com", "gatewayApiTokenName": "token", "gatewayApiSecret": "mysecret", "numberOfLicenses":"10", "primaryMailingDomain":"virtru.example.com", "reportingSecret":"gs://cloud-marketplace-tools/reporting_secrets/fake_reporting_secret.yaml"}'
59+
mpdev install --deployer="${REGISTRY}/deployer:${DEPLOYER_VERSION}" --parameters="${parameters}"

gke-verify.sh

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,25 @@
88

99
set -eu
1010

11-
export TAG=2.15.4;
12-
export DEPLOYER_VERSION=2.15;
11+
12+
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
13+
VERSION="$(< "${SCRIPT_DIR}/VERSION" )"
14+
15+
export TAG="${VERSION}";
16+
export DEPLOYER_VERSION="$(echo "${VERSION}" | cut -d'.' -f 1-2)";
1317
export REGISTRY=gcr.io/virtru-public/staging/gateway;
14-
docker build --no-cache --build-arg TAG=$TAG --build-arg REGISTRY=$REGISTRY \
15-
-t "${REGISTRY}/deployer:${DEPLOYER_VERSION}" -f dev.Dockerfile .
18+
19+
printf 'Using container tag = [%s] and deployer version = [%s]\n' $TAG $DEPLOYER_VERSION
20+
21+
# reportingSecret:
22+
# To actually report to the real Google ServiceControlEndpoint use "gateway-reportingsecret"
23+
# To make sure not to bill, use "gs://cloud-marketplace-tools/reporting_secrets/fake_reporting_secret.yaml"}'
24+
25+
docker build --no-cache --build-arg TAG="${TAG}" --build-arg REGISTRY="${REGISTRY}" \
26+
-t "${REGISTRY}/deployer:${DEPLOYER_VERSION}" -f dev.Dockerfile "${SCRIPT_DIR}"
27+
1628
docker push "${REGISTRY}/deployer:${DEPLOYER_VERSION}"
1729

1830
# mpdev install to install, mpdev verify to test
19-
mpdev verify --deployer="${REGISTRY}/deployer:${DEPLOYER_VERSION}"
31+
# TODO: figure out how to get the parameter values into the app
32+
mpdev verify --deployer="${REGISTRY}/deployer:${DEPLOYER_VERSION}"

0 commit comments

Comments
 (0)