Skip to content

Commit

Permalink
Work on deployment
Browse files Browse the repository at this point in the history
  • Loading branch information
jleach committed Jun 4, 2021
1 parent 16810c2 commit 70f037a
Show file tree
Hide file tree
Showing 6 changed files with 159 additions and 22 deletions.
27 changes: 23 additions & 4 deletions devops/base/api/deploy.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
# Copyright 2021 The Province of British Columbia
#
# 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.
#
---
apiVersion: apps/v1
kind: Deployment
Expand All @@ -10,6 +24,7 @@ spec:
selector:
matchLabels:
app: timemachine
component: api
strategy:
type: RollingUpdate
rollingParams:
Expand All @@ -22,6 +37,8 @@ spec:
metadata:
labels:
app: timemachine
role: api
component: api
spec:
containers:
- name: timemachine-api
Expand All @@ -32,11 +49,11 @@ spec:
protocol: TCP
resources:
limits:
cpu: 250m
memory: 200Mi
cpu: 60m
memory: 256Mi
requests:
cpu: 100m
memory: 100Mi
cpu: 20m
memory: 128Mi
envFrom:
- configMapRef:
name: api-env
Expand Down Expand Up @@ -67,8 +84,10 @@ kind: Route
metadata:
labels:
app: timemachine
component: api
name: timemachine-api
spec:
# path: /api
port:
targetPort: 8080-tcp
tls:
Expand Down
1 change: 1 addition & 0 deletions devops/base/api/kustomization.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,5 @@ apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
- deploy.yaml
- policy.yaml

33 changes: 33 additions & 0 deletions devops/base/api/policy.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# Copyright 2021 The Province of British Columbia
#
# 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.
#
---
kind: NetworkPolicy
apiVersion: networking.k8s.io/v1
metadata:
name: allow-api-to-patroni
spec:
# Allow the API to talk to the patroni
# database cluster on the given port.
podSelector:
matchLabels:
statefulset: timemachine-patroni
ingress:
- from:
- podSelector:
matchLabels:
role: api
ports:
- protocol: TCP
port: 5432
59 changes: 59 additions & 0 deletions devops/base/web/config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
# Copyright 2020 The Province of British Columbia
#
# 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.
#
---
apiVersion: v1
kind: ConfigMap
metadata:
name: timemachine-web-config
labels:
app: timemachine
data:
Caddyfile: |
# Where caddy should listen
:2015
# Turn on the Web/file server
file_server
templates {
mime "text/javascript" "application/javascript"
}
# The site root
root * /opt/app-root/src
# Because we should
encode zstd gzip
# This rewrite rule may be required to get React apps
# to deal with trailing slashes properly.
#@filter {
# not path_regexp ^\/0.0.0.0
# file {
# try_files {path} {path}/ /?url={uri}
# }
#}
#rewrite @try_files {http.matchers.file.relative}
# This properly deals with react routes.
try_files {path} {path}/ /index.html
# On OCP we should log to stdout so Prometheus can
# slurp up the logs for human consumption.
log {
#errors stdout
output stdout
format single_field common_log
level info
}
60 changes: 43 additions & 17 deletions devops/base/web/deploy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,23 +13,6 @@
# limitations under the License.
#
---
apiVersion: v1
kind: Service
metadata:
labels:
app: timemachine
component: web
name: timemachine-web
spec:
selector:
app: timemachine
component: web
ports:
- name: 8080-tcp
port: 8080
protocol: TCP
targetPort: 8080
---
apiVersion: apps/v1
kind: Deployment
metadata:
Expand Down Expand Up @@ -76,3 +59,46 @@ spec:
requests:
cpu: 20m
memory: 64Mi
# volumeMounts:
# - name: config-vol
# mountPath: /opt/app-root/etc/Caddyfile
# subPath: Caddyfile
# volumes:
# - name: config-vol
# configMap:
# name: timemachine-web-config
---
apiVersion: v1
kind: Service
metadata:
labels:
app: timemachine
component: web
name: timemachine-web
spec:
selector:
app: timemachine
component: web
ports:
- name: 8080-tcp
port: 8080
protocol: TCP
targetPort: 8080
---
apiVersion: v1
kind: Route
metadata:
labels:
app: timemachine
component: web
name: timemachine-web
spec:
port:
targetPort: 8080-tcp
tls:
insecureEdgeTerminationPolicy: Redirect
terminationc: edge
to:
kind: Service
name: timemachine-web
weight: 100
1 change: 0 additions & 1 deletion devops/base/web/kustomization.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,3 @@ apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
- deploy.yaml

0 comments on commit 70f037a

Please sign in to comment.