-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Scripts to build & deploy the api-server onto a cluster. The deployment uses a route to expose the port 9443 of the pod running the express server so that any client can connect to it.
- Loading branch information
Showing
8 changed files
with
228 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
FROM registry.access.redhat.com/ubi8/nodejs-20:latest AS BUILD_IMAGE | ||
|
||
### BEGIN REMOTE SOURCE | ||
# Use the COPY instruction only inside the REMOTE SOURCE block | ||
# Use the COPY instruction only to copy files to the container path $REMOTE_SOURCES_DIR/activemq-artemis-jolokia-api-server/app | ||
ARG REMOTE_SOURCES_DIR=/tmp/remote_source | ||
RUN mkdir -p $REMOTE_SOURCES_DIR/activemq-artemis-jolokia-api-server/app | ||
WORKDIR $REMOTE_SOURCES_DIR/activemq-artemis-jolokia-api-server/app | ||
# Copy package.json and yarn.lock to the container | ||
COPY package.json package.json | ||
COPY yarn.lock yarn.lock | ||
ADD . $REMOTE_SOURCES_DIR/activemq-artemis-jolokia-api-server/app | ||
RUN command -v yarn || npm i -g yarn | ||
### END REMOTE SOURCE | ||
|
||
USER root | ||
|
||
## Set directory | ||
RUN mkdir -p /usr/src/ | ||
RUN cp -r $REMOTE_SOURCES_DIR/activemq-artemis-jolokia-api-server/app /usr/src/ | ||
WORKDIR /usr/src/app | ||
|
||
## Install dependencies | ||
RUN yarn install --network-timeout 1000000 | ||
|
||
## Build application | ||
RUN yarn build | ||
|
||
FROM registry.access.redhat.com/ubi8/nodejs-20-minimal:latest | ||
|
||
USER root | ||
|
||
WORKDIR /app | ||
|
||
COPY --from=BUILD_IMAGE /usr/src/app/dist /usr/share/amq-spp/dist | ||
COPY --from=BUILD_IMAGE /usr/src/app/.env /usr/share/amq-spp/.env | ||
|
||
WORKDIR /usr/share/amq-spp | ||
|
||
RUN npm install connect \ | ||
cors \ | ||
express \ | ||
express-openapi-validator \ | ||
swagger-routes-express \ | ||
typescript \ | ||
validator \ | ||
yaml \ | ||
base-64 \ | ||
jsonwebtoken \ | ||
dotenv \ | ||
express-rate-limit \ | ||
node-fetch@2 \ | ||
@peculiar/x509 | ||
|
||
RUN echo "node /usr/share/amq-spp/dist/app.js" > run.sh | ||
RUN chmod +x run.sh | ||
|
||
USER 1001 | ||
|
||
ENV NODE_ENV=production | ||
|
||
CMD ["node", "dist/app.js"] | ||
|
||
## Labels | ||
LABEL name="artemiscloud/activemq-artemis-jolokia-api-server" | ||
LABEL description="ActiveMQ Artemis Jolokia api-server" | ||
LABEL maintainer="Roderick Kieley <[email protected]>" | ||
LABEL version="0.1.0" |
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,39 @@ | ||
#!/usr/bin/env sh | ||
|
||
DEFAULT_IMAGE="quay.io/artemiscloud/activemq-artemis-jolokia-api-server:latest" | ||
PLUGIN_IMAGE=${DEFAULT_IMAGE} | ||
|
||
SCRIPT_NAME=$(basename "$0") | ||
|
||
function printUsage() { | ||
echo "${SCRIPT_NAME}: Deploying to openshift" | ||
echo "Usage:" | ||
echo " ./${SCRIPT_NAME} -i|--image <image url>" | ||
echo "Options: " | ||
echo " -i|--image Specify the plugin image to deploy. (default is ${DEFAULT_IMAGE})" | ||
echo " -h|--help Print this message." | ||
} | ||
|
||
while [[ $# -gt 0 ]]; do | ||
case $1 in | ||
-h|--help) | ||
printUsage | ||
exit 0 | ||
;; | ||
-i|--image) | ||
PLUGIN_IMAGE="$2" | ||
shift | ||
shift | ||
;; | ||
-*|--*) | ||
echo "Unknown option $1" | ||
printUsage | ||
exit 1 | ||
;; | ||
*) | ||
;; | ||
esac | ||
done | ||
|
||
echo "deploying using image: ${PLUGIN_IMAGE}" | ||
oc kustomize deploy | sed "s|image: .*|image: ${PLUGIN_IMAGE}|" | oc apply -f - |
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,52 @@ | ||
apiVersion: apps/v1 | ||
kind: Deployment | ||
metadata: | ||
namespace: activemq-artemis-jolokia-api-server | ||
name: activemq-artemis-jolokia-api-server | ||
labels: | ||
app: activemq-artemis-jolokia-api-server | ||
spec: | ||
replicas: 1 | ||
selector: | ||
matchLabels: | ||
app: activemq-artemis-jolokia-api-server | ||
template: | ||
metadata: | ||
labels: | ||
app: activemq-artemis-jolokia-api-server | ||
spec: | ||
containers: | ||
- name: activemq-artemis-jolokia-api-server | ||
image: quay.io/artemiscloud/activemq-artemis-jolokia-api-server:latest | ||
ports: | ||
- containerPort: 9443 | ||
protocol: TCP | ||
args: ['dist/app.js'] | ||
command: | ||
- node | ||
imagePullPolicy: Always | ||
securityContext: | ||
allowPrivilegeEscalation: false | ||
capabilities: | ||
drop: | ||
- ALL | ||
resources: | ||
requests: | ||
cpu: 10m | ||
memory: 50Mi | ||
volumeMounts: | ||
- name: plugin-serving-cert | ||
readOnly: true | ||
mountPath: /var/serving-cert | ||
volumes: | ||
- name: plugin-serving-cert | ||
secret: | ||
secretName: plugin-serving-cert | ||
defaultMode: 420 | ||
restartPolicy: Always | ||
dnsPolicy: ClusterFirst | ||
strategy: | ||
type: RollingUpdate | ||
rollingUpdate: | ||
maxUnavailable: 25% | ||
maxSurge: 25% |
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,6 @@ | ||
namespace: activemq-artemis-jolokia-api-server | ||
|
||
resources: | ||
- namespace.yaml | ||
- deployment.yaml | ||
- service.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,4 @@ | ||
apiVersion: v1 | ||
kind: Namespace | ||
metadata: | ||
name: activemq-artemis-jolokia-api-server |
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,22 @@ | ||
apiVersion: v1 | ||
kind: Service | ||
metadata: | ||
annotations: | ||
service.beta.openshift.io/serving-cert-secret-name: plugin-serving-cert | ||
name: activemq-artemis-jolokia-api-server | ||
namespace: activemq-artemis-jolokia-api-server | ||
labels: | ||
app: activemq-artemis-jolokia-api-server | ||
app.kubernetes.io/component: activemq-artemis-jolokia-api-server | ||
app.kubernetes.io/instance: activemq-artemis-jolokia-api-server | ||
app.kubernetes.io/part-of: activemq-artemis-jolokia-api-server | ||
spec: | ||
ports: | ||
- name: 443-tcp | ||
protocol: TCP | ||
port: 9443 | ||
targetPort: 9443 | ||
selector: | ||
app: activemq-artemis-jolokia-api-server | ||
type: ClusterIP | ||
sessionAffinity: None |
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 @@ | ||
#!/usr/bin/env sh | ||
|
||
oc kustomize deploy | oc delete -f - |