Skip to content

Commit

Permalink
Merge pull request #995 from amazeeio/pod-priority
Browse files Browse the repository at this point in the history
Pod priority
  • Loading branch information
Schnitzel committed Aug 28, 2019
2 parents c976ad2 + 36f6660 commit cf6c8e3
Show file tree
Hide file tree
Showing 24 changed files with 112 additions and 6 deletions.
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -780,6 +780,7 @@ openshift-lagoon-setup:
oc -n lagoon policy add-role-to-user admin -z openshiftbuilddeploy; \
oc -n lagoon create -f openshift-setup/clusterrole-openshiftbuilddeploy.yaml; \
oc -n lagoon adm policy add-cluster-role-to-user openshiftbuilddeploy -z openshiftbuilddeploy; \
oc -n lagoon create -f openshift-setup/priorityclasses.yaml; \
oc -n lagoon create -f openshift-setup/shared-resource-viewer.yaml; \
oc -n lagoon create -f openshift-setup/policybinding.yaml | oc -n lagoon create -f openshift-setup/rolebinding.yaml; \
oc -n lagoon create serviceaccount docker-host; \
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ parameters:
- name: CRONJOBS
description: Oneliner of Cronjobs
value: ''
- name: ENVIRONMENT_TYPE
description: production level of this environment
objects:
- apiVersion: v1
kind: DeploymentConfig
Expand Down Expand Up @@ -98,6 +100,7 @@ objects:
containers:
- image: ${SERVICE_IMAGE}
name: ${SERVICE_NAME}
priorityClassName: lagoon-priority-${ENVIRONMENT_TYPE}
envFrom:
- configMapRef:
name: lagoon-env
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ parameters:
- name: CRONJOBS
description: Oneliner of Cronjobs
value: ''
- name: ENVIRONMENT_TYPE
description: production level of this environment
required: true
objects:
- apiVersion: v1
kind: DeploymentConfig
Expand Down Expand Up @@ -81,6 +84,7 @@ objects:
containers:
- image: ${SERVICE_IMAGE}
name: ${SERVICE_NAME}
priorityClassName: lagoon-priority-${ENVIRONMENT_TYPE}
envFrom:
- configMapRef:
name: lagoon-env
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ parameters:
value: ""
- name: ENVIRONMENT_TYPE
description: Which environment type this project is
value: development
- name: ROUTE
description: The main route of this project
value: ""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ parameters:
- name: PERSISTENT_STORAGE_SIZE
description: Size of the Storage to request
value: "5Gi"
- name: ENVIRONMENT_TYPE
description: production level of this environment
required: true
objects:
- apiVersion: v1
kind: DeploymentConfig
Expand Down Expand Up @@ -77,6 +80,7 @@ objects:
containers:
- image: ${SERVICE_IMAGE}
name: ${SERVICE_NAME}
priorityClassName: lagoon-priority-${ENVIRONMENT_TYPE}
ports:
- containerPort: 3306
protocol: TCP
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,4 +50,4 @@ objects:
selector:
service: ${SERVICE_NAME}
status:
loadBalancer: {}
loadBalancer: {}
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ parameters:
- name: CRONJOBS
description: Oneliner of Cronjobs
value: ""
- name: ENVIRONMENT_TYPE
description: production level of this environment
required: true
objects:
- apiVersion: v1
kind: DeploymentConfig
Expand Down Expand Up @@ -72,6 +75,7 @@ objects:
containers:
- image: ${SERVICE_IMAGE}
name: ${SERVICE_NAME}
priorityClassName: lagoon-priority-${ENVIRONMENT_TYPE}
ports:
- containerPort: 27017
protocol: TCP
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,9 @@ parameters:
- name: CRONJOBS
description: Oneliner of Cronjobs
value: ''
- name: ENVIRONMENT_TYPE
description: production level of this environment
required: true
objects:
- apiVersion: v1
kind: DeploymentConfig
Expand Down Expand Up @@ -98,6 +101,7 @@ objects:
containers:
- image: ${NGINX_SERVICE_IMAGE}
name: ${NGINX_SERVICE_NAME}
priorityClassName: lagoon-priority-${ENVIRONMENT_TYPE}
ports:
- containerPort: 8080
protocol: TCP
Expand Down Expand Up @@ -133,6 +137,7 @@ objects:
memory: 10Mi
- image: ${PHP_SERVICE_IMAGE}
name: ${PHP_SERVICE_NAME}
priorityClassName: lagoon-priority-${ENVIRONMENT_TYPE}
ports:
- containerPort: 9000
protocol: TCP
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ parameters:
- name: ROUTES_INSECURE
description: Setting of insecure Routes
value: Allow
- name: ENVIRONMENT_TYPE
description: production level of this environment
objects:
- apiVersion: v1
kind: Route
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,9 @@ parameters:
- name: CRONJOBS
description: Oneliner of Cronjobs
value: ''
- name: ENVIRONMENT_TYPE
description: production level of this environment
required: true
objects:
- apiVersion: v1
kind: DeploymentConfig
Expand Down Expand Up @@ -104,6 +107,7 @@ objects:
containers:
- image: ${NGINX_SERVICE_IMAGE}
name: ${NGINX_SERVICE_NAME}
priorityClassName: lagoon-priority-${ENVIRONMENT_TYPE}
ports:
- containerPort: 8080
protocol: TCP
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@ parameters:
- name: CRONJOBS
description: Oneliner of Cronjobs
value: ''
- name: ENVIRONMENT_TYPE
description: production level of this environment
required: true
objects:
- apiVersion: v1
kind: DeploymentConfig
Expand Down Expand Up @@ -85,6 +88,7 @@ objects:
containers:
- image: ${NGINX_SERVICE_IMAGE}
name: ${NGINX_SERVICE_NAME}
priorityClassName: lagoon-priority-${ENVIRONMENT_TYPE}
ports:
- containerPort: 8080
protocol: TCP
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ parameters:
- name: CRONJOBS
description: Oneliner of Cronjobs
value: ''
- name: ENVIRONMENT_TYPE
description: production level of this environment
required: true
objects:
- apiVersion: v1
kind: DeploymentConfig
Expand All @@ -51,6 +54,7 @@ objects:
project: ${SAFE_PROJECT}
name: ${SERVICE_NAME}
spec:

replicas: 1
selector:
service: ${SERVICE_NAME}
Expand All @@ -76,6 +80,7 @@ objects:
containers:
- image: ${SERVICE_IMAGE}
name: ${SERVICE_NAME}
priorityClassName: lagoon-priority-${ENVIRONMENT_TYPE}
ports:
- containerPort: 8080
protocol: TCP
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@ parameters:
- name: CRONJOBS
description: Oneliner of Cronjobs
value: ''
- name: ENVIRONMENT_TYPE
description: production level of this environment
required: true
objects:
- apiVersion: v1
kind: DeploymentConfig
Expand Down Expand Up @@ -89,6 +92,7 @@ objects:
containers:
- image: ${SERVICE_IMAGE}
name: ${SERVICE_NAME}
priorityClassName: lagoon-priority-${ENVIRONMENT_TYPE}
ports:
- containerPort: 3000
protocol: TCP
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ parameters:
- name: CRONJOBS
description: Oneliner of Cronjobs
value: ''
- name: ENVIRONMENT_TYPE
description: production level of this environment
required: true
objects:
- apiVersion: v1
kind: DeploymentConfig
Expand Down Expand Up @@ -76,6 +79,7 @@ objects:
containers:
- image: ${SERVICE_IMAGE}
name: ${SERVICE_NAME}
priorityClassName: lagoon-priority-${ENVIRONMENT_TYPE}
ports:
- containerPort: 3000
protocol: TCP
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ parameters:
- name: CRONJOBS
description: Oneliner of Cronjobs
value: ""
- name: ENVIRONMENT_TYPE
description: production level of this environment
required: true
objects:
- apiVersion: v1
kind: DeploymentConfig
Expand Down Expand Up @@ -71,6 +74,7 @@ objects:
containers:
- image: ${POSTGRES_SERVICE_IMAGE}
name: ${SERVICE_NAME}
priorityClassName: lagoon-priority-${ENVIRONMENT_TYPE}
ports:
- containerPort: 5432
protocol: TCP
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ parameters:
- name: CRONJOBS
description: Oneliner of Cronjobs
value: ""
- name: ENVIRONMENT_TYPE
description: production level of this environment
required: true
objects:
- apiVersion: v1
kind: DeploymentConfig
Expand All @@ -66,6 +69,7 @@ objects:
containers:
- image: ${SERVICE_IMAGE}
name: ${SERVICE_NAME}
priorityClassName: lagoon-priority-${ENVIRONMENT_TYPE}
ports:
- containerPort: 15672
protocol: TCP
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@ parameters:
- name: PERSISTENT_STORAGE_SIZE
description: Size of the Storage to request
value: "1Gi"
- name: ENVIRONMENT_TYPE
description: production level of this environment
required: true
objects:
- apiVersion: v1
kind: DeploymentConfig
Expand Down Expand Up @@ -80,6 +83,7 @@ objects:
containers:
- image: ${SERVICE_IMAGE}
name: ${SERVICE_NAME}
priorityClassName: lagoon-priority-${ENVIRONMENT_TYPE}
ports:
- containerPort: 6379
protocol: TCP
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ parameters:
- name: CRONJOBS
description: Oneliner of Cronjobs
value: ""
- name: ENVIRONMENT_TYPE
description: production level of this environment
required: true
objects:
- apiVersion: v1
kind: DeploymentConfig
Expand Down Expand Up @@ -67,6 +70,7 @@ objects:
containers:
- image: ${SERVICE_IMAGE}
name: ${SERVICE_NAME}
priorityClassName: lagoon-priority-${ENVIRONMENT_TYPE}
ports:
- containerPort: 6379
protocol: TCP
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ parameters:
- name: PERSISTENT_STORAGE_SIZE
description: Size of the Storage to request
value: "1Gi"
- name: ENVIRONMENT_TYPE
description: production level of this environment
required: true
objects:
- apiVersion: v1
kind: DeploymentConfig
Expand Down Expand Up @@ -74,6 +77,7 @@ objects:
containers:
- image: ${SERVICE_IMAGE}
name: ${SERVICE_NAME}
priorityClassName: lagoon-priority-${ENVIRONMENT_TYPE}
ports:
- containerPort: 8149
protocol: TCP
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ parameters:
- name: CRONJOBS
description: Oneliner of Cronjobs
value: ''
- name: ENVIRONMENT_TYPE
description: production level of this environment
required: true
objects:
- apiVersion: v1
kind: DeploymentConfig
Expand Down Expand Up @@ -80,6 +83,7 @@ objects:
containers:
- image: ${SERVICE_IMAGE}
name: ${SERVICE_NAME}
priorityClassName: lagoon-priority-${ENVIRONMENT_TYPE}
ports:
- containerPort: 8080
protocol: TCP
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ parameters:
- name: CRONJOBS
description: Oneliner of Cronjobs
value: ''
- name: ENVIRONMENT_TYPE
description: production level of this environment
required: true
objects:
- apiVersion: v1
kind: DeploymentConfig
Expand Down Expand Up @@ -76,6 +79,7 @@ objects:
containers:
- image: ${SERVICE_IMAGE}
name: ${SERVICE_NAME}
priorityClassName: lagoon-priority-${ENVIRONMENT_TYPE}
ports:
- containerPort: 8080
protocol: TCP
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ else
fi

# Inject Pullable Images into Template
TEMPLATE_IMAGES_PARAMETERS=()
TEMPLATE_ADDITIONAL_PARAMETERS=()
# First check if we need multiple Images in this Template (check for `_SERVICE_IMAGE` - see underline)
if [[ $(oc process --local -f ${OPENSHIFT_TEMPLATE} --parameters | grep _SERVICE_IMAGE) ]]; then
while read line
Expand All @@ -20,13 +20,17 @@ if [[ $(oc process --local -f ${OPENSHIFT_TEMPLATE} --parameters | grep _SERVICE
# Load the Image Hash of the loaded Image
DEPLOYMENT_SERVICETYPE_IMAGE_NAME_HASH="${IMAGE_HASHES[${DEPLOYMENT_SERVICETYPE_IMAGE_NAME}]}"
# Add the Image Hash as Parameter of "[SERVICETYPE]_SERVICE_IMAGE"
TEMPLATE_IMAGES_PARAMETERS+=(-p "${line}=${DEPLOYMENT_SERVICETYPE_IMAGE_NAME_HASH}")
TEMPLATE_ADDITIONAL_PARAMETERS+=(-p "${line}=${DEPLOYMENT_SERVICETYPE_IMAGE_NAME_HASH}")
done < <(oc process --local -f ${OPENSHIFT_TEMPLATE} --parameters | grep _SERVICE_IMAGE | awk '{ print $1 }')
# check if we need a single image to inject
elif [[ $(oc process --local -f ${OPENSHIFT_TEMPLATE} --parameters | grep SERVICE_IMAGE) ]]; then
SERVICE_NAME_IMAGE="${MAP_SERVICE_NAME_TO_IMAGENAME[${SERVICE_NAME}]}"
SERVICE_NAME_IMAGE_HASH="${IMAGE_HASHES[${SERVICE_NAME_IMAGE}]}"
TEMPLATE_IMAGES_PARAMETERS+=(-p "SERVICE_IMAGE=${SERVICE_NAME_IMAGE_HASH}")
TEMPLATE_ADDITIONAL_PARAMETERS+=(-p "SERVICE_IMAGE=${SERVICE_NAME_IMAGE_HASH}")
fi

if [[ $(oc process --local -f ${OPENSHIFT_TEMPLATE} --parameters | grep ENVIRONMENT_TYPE) ]]; then
TEMPLATE_ADDITIONAL_PARAMETERS+=(-p "ENVIRONMENT_TYPE=${ENVIRONMENT_TYPE}")
fi

oc process --local -o yaml --insecure-skip-tls-verify \
Expand All @@ -42,5 +46,5 @@ oc process --local -o yaml --insecure-skip-tls-verify \
-p REGISTRY="${OPENSHIFT_REGISTRY}" \
-p OPENSHIFT_PROJECT=${OPENSHIFT_PROJECT} \
"${TEMPLATE_PARAMETERS[@]}" \
"${TEMPLATE_IMAGES_PARAMETERS[@]}" \
"${TEMPLATE_ADDITIONAL_PARAMETERS[@]}" \
| outputToYaml
Loading

0 comments on commit cf6c8e3

Please sign in to comment.