Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions Dockerfile.ocp
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# ---- build stage ----
FROM node:18-alpine AS build
WORKDIR /app

# (optional) allow overriding paddles URL at build time
ARG REACT_APP_PADDLES_SERVER
ENV REACT_APP_PADDLES_SERVER=$REACT_APP_PADDLES_SERVER

COPY package*.json ./
RUN npm install

COPY . .
RUN npm run build

# ---- runtime stage ----
FROM nginxinc/nginx-unprivileged:stable-alpine
COPY --from=build /app/build /usr/share/nginx/html
COPY openshift/nginx/default.conf /etc/nginx/conf.d/default.conf
68 changes: 66 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ In [teuthology's docker-compose](https://github.com/ceph/teuthology/blob/main/do
ports:
- 8081:8081
```
[recommended] For developement purposes:
[recommended] For development purposes:
Add the following to `pulpito-ng` container:

```
Expand All @@ -51,4 +51,68 @@ pulpito-ng:
volumes:
- ../../../pulpito-ng:/app/:rw
- /app/node_modules
```
```

## Deploying in OpenShift

``Dockerfile.ocp`` and the files under ``openshift/`` are files used to deploy pulpito-ng in OpenShift.

You may wish to change the number of replicas in ``openshift/pulpito-ng-deploy.yaml`` depending on how many worker nodes you have.

To deploy:

Create a new project (if necessary)
```
oc new-project pulpito
```

Create the Image Stream
```
oc -n pulpito apply -f openshift/pulpito-ng-imagestream.yaml
```

Modify the Build Config if necessary and start the build
```
oc -n pulpito apply -f openshift/pulpito-ng-build.yaml
```

Define the paddles URL
```
oc -n pulpito set env bc/pulpito-ng \
REACT_APP_PADDLES_SERVER=http://paddles.example.com
```

Start the build
```
oc -n pulpito start-build pulpito-ng --follow
```

Deploy!
```
oc -n pulpito apply -f openshift/pulpito-ng-deploy.yaml

oc -n pulpito get route pulpito-ng
```

### Deploying code changes in OpenShift

If you just want to deploy the latest code in ``main`` (and your Build Config in ``openshift/pulpito-ng-build.yaml`` doesn't have a different branch defined),

(Note, the ``--follow`` will likely timout if you do not wait for the first build from above to finish)
```
oc -n pulpito start-build pulpito-ng --follow
```

If you wish to deploy code from a different pulpito-ng.git branch,

Start a one-off build of the branch. The deployment will automatically roll this out.
```
oc -n pulpito start-build pulpito-ng --follow --commit=<branch-name>
```

To make the deployment use this branch permanently, modify ``spec.source.git.ref:`` in ``openshift/pulpito-ng-build.yaml``, and build it:
```
oc -n pulpito apply -f openshift/pulpito-ng-build.yaml

oc -n pulpito start-build pulpito-ng --follow
```
13 changes: 13 additions & 0 deletions openshift/nginx/default.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Note: This file is intended for OCP-based deployments
server {
listen 8080;
server_name _;

root /usr/share/nginx/html;
index index.html;

# SPA routes: anything that isn't a real file falls back to index.html
location / {
try_files $uri $uri/ /index.html;
}
}
21 changes: 21 additions & 0 deletions openshift/pulpito-ng-build.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
apiVersion: build.openshift.io/v1
kind: BuildConfig
metadata:
name: pulpito-ng
spec:
runPolicy: Serial
source:
type: Git
git:
uri: https://github.com/ceph/pulpito-ng
ref: main
strategy:
type: Docker
dockerStrategy:
dockerfilePath: Dockerfile.ocp
output:
to:
kind: ImageStreamTag
name: pulpito-ng:latest
triggers:
- type: ConfigChange
78 changes: 78 additions & 0 deletions openshift/pulpito-ng-deploy.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: pulpito-ng
labels:
app: pulpito-ng
annotations:
# When the BuildConfig updates the ImageStreamTag pulpito-ng:latest,
# automatically roll out the Deployment to the new image.
image.openshift.io/triggers: >-
[{"from":{"kind":"ImageStreamTag","name":"pulpito-ng:latest"},
"fieldPath":"spec.template.spec.containers[?(@.name==\"pulpito-ng\")].image"}]
spec:
replicas: 2
revisionHistoryLimit: 10
progressDeadlineSeconds: 300
strategy:
type: RollingUpdate
rollingUpdate:
maxSurge: 1
maxUnavailable: 0
selector:
matchLabels:
app: pulpito-ng
template:
metadata:
labels:
app: pulpito-ng
spec:
containers:
- name: pulpito-ng
# This gets rewritten by the ImageStream trigger above.
image: pulpito-ng:latest
imagePullPolicy: Always
ports:
- name: http
containerPort: 8080
readinessProbe:
httpGet:
path: /
port: http
initialDelaySeconds: 3
timeoutSeconds: 2
periodSeconds: 5
failureThreshold: 6
livenessProbe:
httpGet:
path: /
port: http
initialDelaySeconds: 10
timeoutSeconds: 2
periodSeconds: 10
failureThreshold: 3
---
apiVersion: v1
kind: Service
metadata:
name: pulpito-ng
labels:
app: pulpito-ng
spec:
selector:
app: pulpito-ng
ports:
- name: http
port: 8080
targetPort: http
---
apiVersion: route.openshift.io/v1
kind: Route
metadata:
name: pulpito-ng
spec:
to:
kind: Service
name: pulpito-ng
port:
targetPort: http
4 changes: 4 additions & 0 deletions openshift/pulpito-ng-imagestream.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
apiVersion: image.openshift.io/v1
kind: ImageStream
metadata:
name: pulpito-ng