diff --git a/Dockerfile b/Dockerfile index 99bd7e7..770a0d3 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,15 +1,15 @@ -FROM registry.centos.org/centos/centos:7 -MAINTAINER Tomas Hrcka +FROM registry.access.redhat.com/ubi8/ubi-minimal ENV LANG=en_US.UTF-8 -RUN yum --setopt=tsflags=nodocs install -y epel-release centos-release-openshift-origin36 && \ - yum --setopt=tsflags=nodocs install -y python36-pip wget python36-devel libxml2-devel libxslt-devel python36-requests python36-pycurl origin-clients && \ - yum clean all +RUN microdnf install python3 tar gzip &&\ + microdnf clean all &&\ + rm -fr /var/cache/lib/{dnf,rpm} COPY requirements.txt /tmp/ -RUN pip3 install --upgrade pip && pip install --upgrade wheel -RUN pip3 install -r /tmp/requirements.txt +RUN pip3 install --no-cache-dir --no-cache --upgrade pip && pip install --no-cache-dir --no-cache --upgrade wheel +RUN pip3 install --no-cache-dir --no-cache -r /tmp/requirements.txt +RUN curl https://mirror.openshift.com/pub/openshift-v4/clients/oc/4.4/linux/oc.tar.gz -o - | tar -zx -C /usr/bin RUN mkdir -p /home/scaler/ /var/lib/f8a-scaler/ diff --git a/Dockerfile.rhel b/Dockerfile.rhel deleted file mode 100644 index d5aa58b..0000000 --- a/Dockerfile.rhel +++ /dev/null @@ -1,21 +0,0 @@ -#base image sources https://github.com/rhdt/EL-Dockerfiles/blob/master/base/fabric8-analytics-scaler/Dockerfile - -FROM quay.io/openshiftio/rhel-base-fabric8-analytics-scaler:latest - -ENV LANG=en_US.UTF-8 - -COPY requirements.txt /tmp/ -RUN pip3 install --upgrade pip && pip install --upgrade wheel -RUN pip3 install -r /tmp/requirements.txt - -RUN mkdir -p /home/scaler/ /var/lib/f8a-scaler/ - -RUN echo 1 > /var/lib/f8a-scaler/liveness && \ - echo 0 > /var/lib/f8a-scaler/liveness_prev && \ - chmod 666 /var/lib/f8a-scaler/liveness /var/lib/f8a-scaler/liveness_prev - -COPY scale.sh sqs_status.py liveness_check.sh /home/scaler/ - -WORKDIR /home/scaler - -CMD bash scale.sh diff --git a/Makefile b/Makefile index 8f2da59..74b7898 100644 --- a/Makefile +++ b/Makefile @@ -2,7 +2,7 @@ REGISTRY := quay.io DEFAULT_TAG=latest ifeq ($(TARGET),rhel) - DOCKERFILE := Dockerfile.rhel + DOCKERFILE := Dockerfile REPOSITORY ?= openshiftio/rhel-fabric8-analytics-worker-scaler else DOCKERFILE := Dockerfile diff --git a/cico_setup.sh b/cico_setup.sh index b2095b1..4ffeb42 100755 --- a/cico_setup.sh +++ b/cico_setup.sh @@ -20,6 +20,8 @@ load_jenkins_vars() { prep() { yum -y install epel-release yum -y install docker git python36-pip + # This we should remove once the package subscription-manager-rhsm-certificates fixed + touch /etc/rhsm/ca/redhat-uep.pem systemctl start docker pip3 install -r requirements.txt } diff --git a/openshift/template.yaml b/openshift/template.yaml index fe8f8ee..b37e486 100644 --- a/openshift/template.yaml +++ b/openshift/template.yaml @@ -7,6 +7,19 @@ metadata: annotations: description: f8a-worker-scaler objects: +- apiVersion: v1 + kind: ServiceAccount + metadata: + name: workerscaler +- apiVersion: v1 + kind: RoleBinding + metadata: + name: workerscaler-edit + roleRef: + name: edit + subjects: + - kind: ServiceAccount + name: workerscaler - apiVersion: v1 kind: DeploymentConfig metadata: @@ -55,8 +68,6 @@ objects: value: "${SLEEP_INTERVAL}" - name: DRY_RUN value: "${DRY_RUN}" - - name: OC_PROJECT - value: "${OC_PROJECT}" image: "${DOCKER_REGISTRY}/${DOCKER_IMAGE}:${IMAGE_TAG}" name: f8a-worker-scaler resources: @@ -125,12 +136,6 @@ parameters: name: SQS_QUEUE_NAME value: "ingestion_bayesianFlow_v0,ingestion_bayesianPackageFlow_v0" -- description: Name of the openshift project used for oc command - displayName: Openshift Project Name - required: true - name: OC_PROJECT - value: "bayesian-preview" - - description: Docker registry where the image is displayName: Docker registry required: true diff --git a/openshift/workerscaler.rolebinding.yaml b/openshift/workerscaler.rolebinding.yaml deleted file mode 100644 index 5f2c2f3..0000000 --- a/openshift/workerscaler.rolebinding.yaml +++ /dev/null @@ -1,9 +0,0 @@ -apiVersion: v1 -kind: RoleBinding -metadata: - name: workerscaler-edit -roleRef: - name: edit -subjects: -- kind: ServiceAccount - name: workerscaler \ No newline at end of file diff --git a/openshift/workerscaler.serviceaccount.yaml b/openshift/workerscaler.serviceaccount.yaml deleted file mode 100644 index 22324b7..0000000 --- a/openshift/workerscaler.serviceaccount.yaml +++ /dev/null @@ -1,4 +0,0 @@ -apiVersion: v1 -kind: ServiceAccount -metadata: - name: workerscaler \ No newline at end of file diff --git a/scale.sh b/scale.sh index 7f524a8..378036f 100755 --- a/scale.sh +++ b/scale.sh @@ -25,10 +25,10 @@ while true; do echo "[$(date -u)] Number of messages in ${DEPLOYMENT_PREFIX}_{${SQS_QUEUE_NAME}} is ${msg_count}. Replicas needed: ${replicas}." if [ "$dry_run" == "True" ]; then - echo "[DRY-RUN] oc -n ${OC_PROJECT} scale --replicas=${replicas} dc ${DC_NAME}" + echo "[DRY-RUN] oc scale --replicas=${replicas} dc ${DC_NAME}" else set -x - oc -n ${OC_PROJECT} scale --replicas=${replicas} dc ${DC_NAME} + oc scale --replicas=${replicas} dc ${DC_NAME} set +x fi