Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(#199): migrate from devshift registry to quay.io #218

Open
wants to merge 10 commits into
base: master
Choose a base branch
from
22 changes: 12 additions & 10 deletions .make/Makefile.deploy.prow
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ oc-deploy-hook: build-hook deploy-hook ## Deploys hook service only
@echo "Deploys hook service ${TAG}"
@oc process -f $(CLUSTER_DIR)/hook-template.yaml \
-p REGISTRY=$(REGISTRY) \
-p DOCKER_REPO=$(DOCKER_REPO) \
-p IMG_REPO=$(IMG_REPO) \
-p PROJECT_NAME=$(OC_PROJECT_NAME) \
-p IMAGE_TAG=$(TAG) \
-o yaml | oc apply -f -

Expand All @@ -21,16 +22,16 @@ build-hook: update

.PHONY: build-hook-image
build-hook-image:
$(DOCKER) build --build-arg BINARY=hook -t $(REGISTRY)/$(DOCKER_REPO)/hook -f $(DEPLOY_DOCKERFILE) .
$(DOCKER) tag $(REGISTRY)/$(DOCKER_REPO)/hook $(REGISTRY)/$(DOCKER_REPO)/hook:$(TAG)
$(DOCKER) build --build-arg BINARY=hook -t $(REGISTRY)/$(IMG_REPO)/$(OC_PROJECT_NAME)-hook -f $(DEPLOY_DOCKERFILE) .
$(DOCKER) tag $(REGISTRY)/$(IMG_REPO)-hook $(REGISTRY)/$(IMG_REPO)/$(OC_PROJECT_NAME)-hook:$(TAG)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't $(REGISTRY)/$(IMG_REPO)-hook be $(REGISTRY)/$(IMG_REPO)/$(OC_PROJECT_NAME)-hook now?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think so too.


.PHONY: push-hook-image
push-hook-image: build-hook-image
$(DOCKER) push $(REGISTRY)/$(DOCKER_REPO)/hook
$(DOCKER) push $(REGISTRY)/$(IMG_REPO)/$(OC_PROJECT_NAME)-hook

.PHONY: clean-hook-image
clean-hook-image:
$(DOCKER) rmi -f $(REGISTRY)/$(DOCKER_REPO)/hook
$(DOCKER) rmi -f $(REGISTRY)/$(IMG_REPO)/$(OC_PROJECT_NAME)-hook

.PHONY: oc-deploy-plugins ## Builds plugin images, updates configuration and deploys new version of ike-plugins
oc-deploy-plugins: oc-init-project compile deploy-plugins oc-generate-deployments
Expand All @@ -41,7 +42,8 @@ $(OC_DEPLOYMENTS): oc-%: %
@mkdir -p $(PLUGIN_DEPLOYMENTS_DIR)
@oc process -f $(CLUSTER_DIR)/ike-prow-template.yaml \
-p REGISTRY=$(REGISTRY) \
-p DOCKER_REPO=$(DOCKER_REPO) \
-p IMG_REPO=$(IMG_REPO) \
-p PROJECT_NAME=$(OC_PROJECT_NAME) \
-p PLUGIN_NAME=$< \
-p IMAGE_TAG=$(TAG) \
-o yaml > $(PLUGIN_DEPLOYMENTS_DIR)/$<.yaml
Expand All @@ -54,16 +56,16 @@ deploy-plugins: build-plugin-images push-plugin-images
.PHONY: build-plugin-images $(PLUGINS)
build-plugin-images: $(BUILD_IMAGES)
$(BUILD_IMAGES): build-%: %
$(DOCKER) build --build-arg BINARY=$< -t $(REGISTRY)/$(DOCKER_REPO)/$< -f $(DEPLOY_DOCKERFILE) .
$(DOCKER) tag $(REGISTRY)/$(DOCKER_REPO)/$< $(REGISTRY)/$(DOCKER_REPO)/$<:$(TAG)
$(DOCKER) build --build-arg BINARY=$< -t $(REGISTRY)/$(IMG_REPO)/$(OC_PROJECT_NAME)-$< -f $(DEPLOY_DOCKERFILE) .
$(DOCKER) tag $(REGISTRY)/$(IMG_REPO)/$< $(REGISTRY)/$(IMG_REPO)/$(OC_PROJECT_NAME)-$<:$(TAG)


.PHONY: clean-plugin-images
clean-plugin-images: $(CLEAN_IMAGES)
$(CLEAN_IMAGES): clean-%: %
$(DOCKER) rmi -f $(REGISTRY)/$(DOCKER_REPO)/$<
$(DOCKER) rmi -f $(REGISTRY)/$(IMG_REPO)/$(OC_PROJECT_NAME)-$<

.PHONY: push-plugin-images
push-plugin-images: build-plugin-images $(PUSH_IMAGES)
$(PUSH_IMAGES): push-%: %
$(DOCKER) push $(REGISTRY)/$(DOCKER_REPO)/$<
$(DOCKER) push $(REGISTRY)/$(IMG_REPO)/$(OC_PROJECT_NAME)-$<
2 changes: 1 addition & 1 deletion Dockerfile.deploy.rhel
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM prod.registry.devshift.net/osio-prod/base/pcp-tools:latest
FROM quay.io/openshiftio/rhel-base-pcp-tools:latest

LABEL maintainer="Devtools <[email protected]>"
LABEL maintainer="Devtools-test <[email protected]>"
Expand Down
32 changes: 25 additions & 7 deletions Gopkg.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ BINARY_DIR:=${PWD}/bin
CLUSTER_DIR?=${PWD}/cluster
PLUGIN_DEPLOYMENTS_DIR?=$(CLUSTER_DIR)/generated

REGISTRY?=docker.io
DOCKER_REPO?=ike-prow-plugins
REGISTRY?=quay.io
IMG_REPO?=openshiftio
BUILD_IMAGES:=$(patsubst %,build-%, $(PLUGINS))
PUSH_IMAGES:=$(patsubst %,push-%, $(PLUGINS))
CLEAN_IMAGES:=$(patsubst %,clean-%, $(PLUGINS))
Expand Down
10 changes: 5 additions & 5 deletions cico_setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ set -e
function load_jenkins_vars() {
if [ -e "jenkins-env" ]; then
cat jenkins-env \
| grep -E "(DEVSHIFT_TAG_LEN|DEVSHIFT_USERNAME|DEVSHIFT_PASSWORD|JENKINS_URL|GIT_BRANCH|GIT_COMMIT|BUILD_NUMBER|ghprbSourceBranch|ghprbActualCommit|BUILD_URL|ghprbPullId)=" \
| grep -E "(IMG_REPO_TAG_LEN|IMG_REPO_USERNAME|IMG_REPO_PASSWORD|JENKINS_URL|GIT_BRANCH|GIT_COMMIT|BUILD_NUMBER|ghprbSourceBranch|ghprbActualCommit|BUILD_URL|ghprbPullId)=" \
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know from where DEVSHIFT_* is coming. Might be env variable of Centos-CI. Can you make sure we are doing the right thing here?

Copy link
Contributor

@jmelis jmelis Jul 2, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That is correct, DEVSHIFT_USERNAME and DEVSHIFT_PASSWORD are coming from CentOS-CI, however if migrating to quay, we should be using QUAY_USERNAME and QUAY_PASSWORD instead. Can you gobally replace DEVSHIFT_USERNAME and DEVSHIFT_PASSWORD with their quay counterparts? also, please keep DEVSHIFT_TAG_LEN as is, that's a special variable that contains the expected length of git commit hash and can't be renamed.

Also, I recommend you to no longer use such a mechanism to load the env, but rather use this:

function load_jenkins_vars() {
  if [ -e "jenkins-env.json" ]; then
    eval "$(./env-toolkit load -f jenkins-env.json \
        DEVSHIFT_TAG_LEN \
        QUAY_USERNAME \
        QUAY_PASSWORD \
        JENKINS_URL \
        GIT_BRANCH \
        GIT_COMMIT \
        BUILD_NUMBER \
        ghprbSourceBranch \
        ghprbActualCommit \
        BUILD_URL \
        ghprbPullId)"
  fi
}

It's a much safer approach as it's resilient to env vars with spaces, newlines and special chars.

| sed 's/^/export /g' \
> ~/.jenkins-env
source ~/.jenkins-env
Expand Down Expand Up @@ -49,17 +49,17 @@ function cleanup_env {
}

function deploy() {
export REGISTRY="push.registry.devshift.net"
export REGISTRY="quay.io"
export PLUGINS='work-in-progress test-keeper pr-sanitizer'

if [ "${TARGET}" = "rhel" ]; then
export DEPLOY_DOCKERFILE='Dockerfile.deploy.rhel'
export DOCKER_REPO="osio-prod/ike-prow-plugins"
export IMG_REPO="openshiftio/rhel-"
fi

# Login first
if [ -n "${DEVSHIFT_USERNAME}" -a -n "${DEVSHIFT_PASSWORD}" ]; then
docker login -u ${DEVSHIFT_USERNAME} -p ${DEVSHIFT_PASSWORD} ${REGISTRY}
if [ -n "${IMG_REPO_USERNAME}" -a -n "${IMG_REPO_PASSWORD}" ]; then
docker login -u ${IMG_REPO_USERNAME} -p ${IMG_REPO_PASSWORD} ${REGISTRY}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please replace with QUAY_...

else
echo "Could not login, missing credentials for the registry"
fi
Expand Down
11 changes: 7 additions & 4 deletions cluster/hook-template.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,13 @@ apiVersion: v1
parameters:
- name: REGISTRY
required: true
value: docker.io
- name: DOCKER_REPO
value: quay.io
- name: IMG_REPO
required: true
value: arquillian
value: openshiftio
- name: PROJECT_NAME
required: true
value: ike-prow-plugins
- name: IMAGE_TAG
required: true
value: latest
Expand Down Expand Up @@ -42,7 +45,7 @@ objects:
terminationGracePeriodSeconds: 180
containers:
- name: hook
image: ${REGISTRY}/${DOCKER_REPO}/hook:${IMAGE_TAG}
image: ${REGISTRY}/${IMG_REPO}/${PROJECT_NAME}-hook:${IMAGE_TAG}
imagePullPolicy: Always
resources:
requests:
Expand Down
11 changes: 7 additions & 4 deletions cluster/ike-prow-template.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,13 @@ apiVersion: v1
parameters:
- name: REGISTRY
required: true
value: docker.io
- name: DOCKER_REPO
value: quay.io
- name: IMG_REPO
required: true
value: arquillian
value: openshiftio
- name: PROJECT_NAME
required: true
value: ike-prow-plugins
- name: PLUGIN_NAME
required: true
- name: IMAGE_TAG
Expand Down Expand Up @@ -42,7 +45,7 @@ objects:
terminationGracePeriodSeconds: 180
containers:
- name: ${PLUGIN_NAME}
image: ${REGISTRY}/${DOCKER_REPO}/${PLUGIN_NAME}:${IMAGE_TAG}
image: ${REGISTRY}/${IMG_REPO}/${PROJECT_NAME}-${PLUGIN_NAME}:${IMAGE_TAG}
imagePullPolicy: Always
resources:
requests:
Expand Down
2 changes: 1 addition & 1 deletion local.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
eval $(minishift docker-env)
docker login -u $(oc whoami) -p $(oc whoami -t) $(minishift openshift registry)
export REGISTRY=$(minishift openshift registry)
export DOCKER_REPO=$(oc project -q)
export IMG_REPO=$(oc project -q)
# end::local_docker_registry[]

# tag::seeding_secrets[]
Expand Down