Skip to content

Commit

Permalink
add missing cases of openshift deployment
Browse files Browse the repository at this point in the history
Signed-off-by: Sunyanan Choochotkaew <sunyanan.choochotkaew1@ibm.com>
  • Loading branch information
sunya-ch committed Sep 12, 2023
1 parent 10e0742 commit e4a3589
Show file tree
Hide file tree
Showing 7 changed files with 148 additions and 26 deletions.
24 changes: 17 additions & 7 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -72,21 +72,31 @@ test: build-test test-pipeline test-estimator test-model-server test-offline-tra

# set image
set-image:
cd ./manifests/base && kustomize edit set image kepler_model_server=$(IMAGE)
cd ./manifests/server && kustomize edit set image kepler_model_server=$(IMAGE)
@cd ./manifests/base && kustomize edit set image kepler_model_server=$(IMAGE)
@cd ./manifests/server && kustomize edit set image kepler_model_server=$(IMAGE)

# deploy
_deploy:
$(MAKE) set-image
kustomize build ./manifests/base|kubectl apply -f -
@$(MAKE) set-image
@kustomize build ./manifests/base|kubectl apply -f -

# print
_print:
@$(MAKE) set-image
@kustomize build ./manifests/base|cat

cleanup:
kustomize build manifests/base|kubectl delete -f -

deploy:
chmod +x ./manifests/set.sh
./manifests/set.sh "${OPTS}"
$(MAKE) _deploy
@chmod +x ./manifests/set.sh
@./manifests/set.sh "${OPTS}"
@$(MAKE) _deploy

manifest:
@chmod +x ./manifests/set.sh
@./manifests/set.sh "${OPTS}"
@$(MAKE) _print

e2e-test:
chmod +x ./tests/e2e_test.sh
Expand Down
9 changes: 9 additions & 0 deletions manifests/base/openshift/estimate-only/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
namespace: kepler

patchesStrategicMerge:
- ./patch/patch-estimator-sidecar.yaml
- ./patch/patch-openshift.yaml

resources:
- ../kepler
- ./openshift/scc.yaml
11 changes: 11 additions & 0 deletions manifests/base/openshift/estimate-with-server/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
namespace: kepler

patchesStrategicMerge:
- ./patch/patch-estimator-sidecar.yaml
- ./patch/patch-model-server.yaml
- ./patch/patch-openshift.yaml

resources:
- ../kepler
- ../server
- ./openshift/scc.yaml
30 changes: 30 additions & 0 deletions manifests/base/openshift/scc.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# scc for the Kepler
kind: SecurityContextConstraints
apiVersion: security.openshift.io/v1
metadata:
name: kepler-scc
# To allow running privilegedContainers
allowPrivilegedContainer: true
allowHostDirVolumePlugin: true
allowHostNetwork: false
allowHostPorts: false
allowHostIPC: false
allowHostPID: true
readOnlyRootFilesystem: true
defaultAddCapabilities:
- SYS_ADMIN
runAsUser:
type: RunAsAny
seLinuxContext:
type: RunAsAny
fsGroup:
type: RunAsAny
volumes:
- configMap
- projected
- emptyDir
- hostPath
- secret
users:
- kepler
- system:serviceaccount:kepler:kepler-sa
10 changes: 10 additions & 0 deletions manifests/base/openshift/serve-only/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
namespace: kepler

patchesStrategicMerge:
- ./patch/patch-model-server.yaml
- ./patch/patch-openshift.yaml

resources:
- ../kepler
- ../server
- ./openshift/scc.yaml
34 changes: 34 additions & 0 deletions manifests/base/patch/patch-openshift.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
apiVersion: v1
kind: Namespace
metadata:
annotations:
openshift.io/description: "Kepler exporter"
openshift.io/display-name: ""
name: kepler
---
apiVersion: apps/v1
kind: DaemonSet
metadata:
name: kepler-exporter
namespace: kepler
spec:
template:
spec:
containers:
- name: kepler-exporter
volumeMounts:
- name: kernel-src
mountPath: /usr/src/kernels
- name: kernel-debug
mountPath: /sys/kernel/debug
securityContext:
privileged: true
volumes:
- name: kernel-debug
hostPath:
path: /sys/kernel/debug
type: Directory
- name: kernel-src
hostPath:
path: /usr/src/kernels
type: Directory
56 changes: 37 additions & 19 deletions manifests/set.sh
Original file line number Diff line number Diff line change
Expand Up @@ -33,35 +33,53 @@ fi

echo "Preparing manifests..."

if [ ! -z ${ESTIMATOR} ]; then
echo "add estimator-sidecar"
cp ./manifests/base/estimate-only/kustomization.yaml ./manifests/base/kustomization.yaml
fi

if [ ! -z ${SERVER} ]; then
echo "deploy model server"
if [ ! -z ${ESTIMATOR} ]; then
# with estimator, replace estimate-only with estimate-with-server
echo "add estimator-sidecar"
# OPTS="ESTIMATOR SERVER" --> base
cp ./manifests/base/estimate-with-server/kustomization.yaml ./manifests/base/kustomization.yaml
if [ ! -z ${OPENSHIFT_DEPLOY} ]; then
echo "patch openshift deployment for exporter (estimator-with-server)"
# OPTS="ESTIMATOR SERVER OPENSHIFT_DEPLOY" --> base
cp ./manifests/base/openshift/estimate-with-server/kustomization.yaml ./manifests/base/kustomization.yaml
fi
else
# OPTS="SERVER" --> base
cp ./manifests/base/serve-only/kustomization.yaml ./manifests/base/kustomization.yaml
if [ ! -z ${OPENSHIFT_DEPLOY} ]; then
echo "patch openshift deployment for exporter (serve-only)"
# OPTS="SERVER OPENSHIFT_DEPLOY" --> base
cp ./manifests/base/openshift/serve-only/kustomization.yaml ./manifests/base/kustomization.yaml
fi
fi
# default
cp ./manifests/server/base/kustomization.yaml ./manifests/server/kustomization.yaml
if [ ! -z ${OPENSHIFT_DEPLOY} ]; then
# replace with openshift serve-only
echo "openshift deployment"
cp ./manifests/server/openshift/serve-only/kustomization.yaml ./manifests/server/kustomization.yaml
fi


if [ ! -z ${ONLINE_TRAINER} ]; then
# replace with online-train
echo "add online trainer"
if [ ! -z ${OPENSHIFT_DEPLOY} ]; then
cp ./manifests/server/openshift/online-train/kustomization.yaml ./manifests/server/kustomization.yaml
else
cp ./manifests/server/online-train/kustomization.yaml ./manifests/server/kustomization.yaml
# OPTS="... SERVER ONLINE_TRAINER" --> server
cp ./manifests/server/online-train/kustomization.yaml ./manifests/server/kustomization.yaml
if [ ! -z ${OPENSHIFT_DEPLOY} ]; then
echo "patch openshift deployment for server (with online trainer)"
# OPTS="... SERVER ONLINE_TRAINER OPENSHIFT_DEPLOY" --> server
cp ./manifests/server/openshift/online-train/kustomization.yaml ./manifests/server/kustomization.yaml
fi
else
# OPTS="... SERVER" --> server
cp ./manifests/server/base/kustomization.yaml ./manifests/server/kustomization.yaml
if [ ! -z ${OPENSHIFT_DEPLOY} ]; then
echo "patch openshift deployment for server"
# OPTS="... SERVER OPENSHIFT_DEPLOY" --> server
cp ./manifests/server/openshift/serve-only/kustomization.yaml ./manifests/server/kustomization.yaml
fi
fi
elif [ ! -z ${ESTIMATOR} ]; then
echo "add estimator-sidecar"
# OPTS="ESTIMATOR" --> base
cp ./manifests/base/estimate-only/kustomization.yaml ./manifests/base/kustomization.yaml
if [ ! -z ${OPENSHIFT_DEPLOY} ]; then
echo "patch openshift deployment for exporter (estimator-only)"
# OPTS="ESTIMATOR OPENSHIFT_DEPLOY" --> base
cp ./manifests/base/openshift/estimate-only/kustomization.yaml ./manifests/base/kustomization.yaml
fi
fi

Expand Down

0 comments on commit e4a3589

Please sign in to comment.