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

Bootstrap the Red Hat product devfile registry #1

Merged
merged 3 commits into from
Jul 7, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions .ci/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
FROM quay.io/openshift-pipeline/golang:1.15-alpine AS builder

# Install dependencies

RUN apk add --no-cache git bash curl zip

# Install yq
RUN curl -sL -O https://github.com/mikefarah/yq/releases/download/v4.9.5/yq_linux_amd64 -o /usr/local/bin/yq && mv ./yq_linux_amd64 /usr/local/bin/yq && chmod +x /usr/local/bin/yq

COPY . /registry

# Download the registry build tools
RUN git clone https://github.com/devfile/registry-support.git /registry-support

# Run the registry build tools
RUN /registry-support/build-tools/build.sh /registry /build

FROM quay.io/devfile/devfile-index-base:next

COPY --from=builder /build /registry
34 changes: 34 additions & 0 deletions .ci/acceptance-tests/devfile-registry-acceptance.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
---
apiVersion: v1
kind: Template
metadata:
name: devfile-registry-acceptance
objects:
- apiVersion: batch/v1
kind: Job
metadata:
name: devfile-registry-acceptance-${JOB_NAME}
spec:
backoffLimit: 5
template:
spec:
restartPolicy: Never
containers:
- image: ${IMAGE}:${IMAGE_TAG}
imagePullPolicy: Always
name: github-mirror-acceptance
env:
- name: REGISTRY
value: ${REGISTRY}
parameters:
- name: IMAGE
value: quay.io/devfile/devfile-registry-integration
- name: IMAGE_TAG
value: "next"
required: true
- name: REGISTRY
value: "https://registry.stage.devfile.io"
required: true
- name: JOB_NAME
generate: expression
from: "[a-z0-9]{5}"
7 changes: 7 additions & 0 deletions .ci/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/usr/bin/env bash
# This script downloads the registry build tools and builds up this repository
# This script runs on both the GitHub action CI and the CICD for the hosted registry

ABSOLUTE_PATH="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"

docker build --no-cache -t devfile-index -f $ABSOLUTE_PATH/Dockerfile $ABSOLUTE_PATH/..
22 changes: 22 additions & 0 deletions .ci/build_and_deploy.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/usr/bin/env bash
# This script downloads the registry build tools and builds up this repository then pushes it to quay.io
# This will be run via the app-sre CI.
set -ex
ABSOLUTE_PATH="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
GIT_REV="$(git rev-parse --short=7 HEAD)"
IMAGE="${IMAGE:-quay.io/app-sre/product-devfile-index}"
IMAGE_TAG="${IMAGE_TAG:-${GIT_REV}}"

# Run the build script
$ABSOLUTE_PATH/build.sh

# Push the iamge to quay.io
if [[ -n "$QUAY_USER" && -n "$QUAY_TOKEN" ]]; then
DOCKER_CONF="$PWD/.docker"
mkdir -p "$DOCKER_CONF"
docker tag devfile-index "${IMAGE}:${IMAGE_TAG}"
docker tag devfile-index "${IMAGE}:next"
docker --config="$DOCKER_CONF" login -u="$QUAY_USER" -p="$QUAY_TOKEN" quay.io
docker --config="$DOCKER_CONF" push "${IMAGE}:${IMAGE_TAG}"
docker --config="$DOCKER_CONF" push "${IMAGE}:next"
fi
187 changes: 187 additions & 0 deletions .ci/deploy/devfile-registry.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,187 @@
#
# Copyright (c) 2021 Red Hat, Inc.
# This program and the accompanying materials are made
# available under the terms of the Eclipse Public License 2.0
# which is available at https://www.eclipse.org/legal/epl-2.0/
#
# SPDX-License-Identifier: EPL-2.0
#
---
apiVersion: v1
kind: Template
metadata:
name: devfile-registry
objects:
- apiVersion: apps/v1
kind: Deployment
metadata:
labels:
app: devfile-registry
name: devfile-registry
spec:
replicas: ${{REPLICAS}}
selector:
matchLabels:
app: devfile-registry
strategy:
type: RollingUpdate
rollingUpdate:
maxSurge: 25%
maxUnavailable: 25%
template:
metadata:
labels:
app: devfile-registry
spec:
volumes:
- name: devfile-registry-storage
emptyDir: {}
- name: config
configMap:
name: devfile-registry
items:
- key: registry-config.yml
path: config.yml
containers:
- image: ${DEVFILE_INDEX_IMAGE}:${DEVFILE_INDEX_IMAGE_TAG}
imagePullPolicy: "${DEVFILE_INDEX_PULL_POLICY}"
name: devfile-registry
ports:
- containerPort: 8080
livenessProbe:
httpGet:
path: /
port: 8080
initialDelaySeconds: 30
periodSeconds: 10
timeoutSeconds: 3
readinessProbe:
httpGet:
path: /
port: 8080
initialDelaySeconds: 3
periodSeconds: 10
timeoutSeconds: 3
resources:
requests:
cpu: 1m
memory: 5Mi
limits:
cpu: 100m
memory: ${DEVFILE_INDEX_MEMORY_LIMIT}
- image: ${OCI_REGISTRY_IMAGE}:${OCI_REGISTRY_IMAGE_TAG}
imagePullPolicy: "${OCI_REGISTRY_PULL_POLICY}"
name: oci-registry
livenessProbe:
httpGet:
path: /v2/
port: 5000
initialDelaySeconds: 30
periodSeconds: 10
timeoutSeconds: 3
readinessProbe:
httpGet:
path: /v2/
port: 5000
initialDelaySeconds: 3
periodSeconds: 10
timeoutSeconds: 3
resources:
requests:
cpu: 1m
memory: 5Mi
limits:
cpu: 100m
memory: ${OCI_REGISTRY_MEMORY_LIMIT}
volumeMounts:
- name: devfile-registry-storage
mountPath: "/var/lib/registry"
- name: config
mountPath: "/etc/docker/registry"
readOnly: true
- apiVersion: v1
kind: Service
metadata:
name: devfile-registry
labels:
app: devfile-registry
spec:
ports:
- name: http
protocol: TCP
port: 8080
targetPort: 8080
- name: oci-metrics
protocol: TCP
port: 5001
targetPort: 5001
- name: index-metrics
protocol: TCP
port: 7071
targetPort: 7071
selector:
app: devfile-registry
- apiVersion: v1
kind: ConfigMap
metadata:
name: devfile-registry
annotations:
qontract.recycle: "true"
data:
registry-config.yml: |
version: 0.1
log:
fields:
service: registry
storage:
cache:
blobdescriptor: inmemory
filesystem:
rootdirectory: /var/lib/registry
http:
addr: :5000
headers:
X-Content-Type-Options: [nosniff]
debug:
addr: :5001
prometheus:
enabled: true
path: /metrics

parameters:
- name: DEVFILE_INDEX_IMAGE
value: quay.io/app-sre/product-devfile-index
displayName: Devfile registry index image
description: Devfile registry index docker image. Defaults to quay.io/devfile/devfile-index
- name: DEVFILE_INDEX_IMAGE_TAG
value: next
displayName: Devfile registry version
description: Devfile registry version which defaults to next
- name: DEVFILE_INDEX_MEMORY_LIMIT
value: 256Mi
displayName: Memory Limit
description: Maximum amount of memory the container can use. Defaults 256Mi
- name: DEVFILE_INDEX_PULL_POLICY
value: Always
displayName: Devfile registry image pull policy
description: Always pull by default. Can be IfNotPresent
- name: OCI_REGISTRY_IMAGE
value: quay.io/devfile/oci-registry
displayName: OCI registry index image
description: OCI registry index docker image. Defaults to quay.io/devfile/devfile-index
- name: OCI_REGISTRY_IMAGE_TAG
value: next
displayName: OCI registry version
description: OCI registry version which defaults to next
- name: OCI_REGISTRY_MEMORY_LIMIT
value: 256Mi
displayName: Memory Limit
description: Maximum amount of memory the OCI registry container can use. Defaults 256Mi
- name: OCI_REGISTRY_PULL_POLICY
value: Always
displayName: Devfile registry image pull policy
description: Always pull by default. Can be IfNotPresent
- name: REPLICAS
value: "1"
displayName: Devfile registry replicas
description: The number of replicas for the hosted devfile registry service
24 changes: 24 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: CI

on:
push:
branches: [ main ]
pull_request:
branches: [ main ]

jobs:
build:
name: Check registry build
runs-on: ubuntu-latest
steps:
- name: Check out code
uses: actions/checkout@v2
with:
path: registry-repo
- name: Setup Go environment
uses: actions/setup-go@v2
with:
go-version: 1.13

- name: Check if devfile registry build is working
run: registry-repo/.ci/build.sh
Loading