From 11431e70b151d2eb25a7a2f4a0ad31bbfca6ae22 Mon Sep 17 00:00:00 2001 From: Arunprasad Rajkumar Date: Sat, 29 Aug 2020 00:38:05 +0530 Subject: [PATCH 1/3] fix: Upgrade oc to 4.4 and use UBI8 base image --- Dockerfile | 14 +++++++------- Dockerfile.rhel | 21 --------------------- Makefile | 2 +- openshift/template.yaml | 13 +++++++++++++ openshift/workerscaler.rolebinding.yaml | 9 --------- openshift/workerscaler.serviceaccount.yaml | 4 ---- 6 files changed, 21 insertions(+), 42 deletions(-) delete mode 100644 Dockerfile.rhel delete mode 100644 openshift/workerscaler.rolebinding.yaml delete mode 100644 openshift/workerscaler.serviceaccount.yaml 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/openshift/template.yaml b/openshift/template.yaml index fe8f8ee..5736967 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: 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 From fe77da88683b08c3a7f79509d78b07a9cc86bcfa Mon Sep 17 00:00:00 2001 From: Arunprasad Rajkumar Date: Sat, 29 Aug 2020 00:52:20 +0530 Subject: [PATCH 2/3] Fix issue for cert file for subscription-manager-rhsm-certificates package --- cico_setup.sh | 2 ++ 1 file changed, 2 insertions(+) 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 } From 986c278fcbd5d040bc3cde73ec740c249b663805 Mon Sep 17 00:00:00 2001 From: Arunprasad Rajkumar Date: Sat, 29 Aug 2020 01:05:03 +0530 Subject: [PATCH 3/3] ServiceAccount is meant for a namespace --- openshift/template.yaml | 8 -------- scale.sh | 4 ++-- 2 files changed, 2 insertions(+), 10 deletions(-) diff --git a/openshift/template.yaml b/openshift/template.yaml index 5736967..b37e486 100644 --- a/openshift/template.yaml +++ b/openshift/template.yaml @@ -68,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: @@ -138,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/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