Skip to content

Commit

Permalink
feature: ZENKO-2413 Build ISO Solution
Browse files Browse the repository at this point in the history
* Deps.txt to store zenko dependencies
* Pull zenko-operator dependencies from zenko-cr.yaml
* Copy operator yaml files into ISO
* Build product.txt in ISO
* Generate a solutions ISO similar to examples
  • Loading branch information
miniscruff committed May 19, 2020
1 parent dd24341 commit 30fa054
Show file tree
Hide file tree
Showing 12 changed files with 1,215 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@ tests/artifacts
.DS_Store
.tox/

*_build
**/_build
docs/_templates/page.html_orig
*.pyc
122 changes: 122 additions & 0 deletions solution/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
#!/bin/bash
PWD=$(pwd)
BUILD_ROOT=${PWD}/_build
ISO_ROOT=${BUILD_ROOT}/root
IMAGES_ROOT=${ISO_ROOT}/images

PRODUCT_NAME=Zenko
PRODUCT_LOWERNAME=zenko
BUILD_TIMESTAMP=$(date -u +"%Y-%m-%dT%H:%M:%SZ")
BUILD_HOST=$(hostname)

VERSION_SHORT=$(git describe --abbrev=0)
VERSION_FULL=${VERSION_SHORT}-dev
GIT_REVISION=$(git describe --long --always --tags --dirty)
ISO=${BUILD_ROOT}/${PRODUCT_LOWERNAME}-${VERSION_FULL}.iso

DOCKER=docker
DOCKER_OPTS=
DOCKER_SOCKET=unix:///var/run/docker.sock
HARDLINK=hardlink
OPERATOR_SDK=operator-sdk
OPERATOR_SDK_OPTS=
SKOPEO=skopeo
SKOPEO_OPTS="--override-os linux --insecure-policy"

# grab our dependencies from our deps.txt file as an array
readarray -t DEP_IMAGES < deps.txt
# add the CR dependencies by joining image: and tag: lines
readarray -t CR_IMAGES < <(grep image: zenko-version-cr.yaml | awk '{print $2}')
readarray -t CR_TAGS < <(grep tag: zenko-version-cr.yaml | awk '{print $2}')

for index in ${!CR_IMAGES[@]}; do
DEP_IMAGES+=(${CR_IMAGES[index]}:${CR_TAGS[index]})
done

function clean()
{
rm -rf ${BUILD_ROOT}
}

function mkdirs()
{
mkdir -p ${ISO_ROOT}
}

function copy_yamls()
{
OPERATOR_TAG=$(grep /zenko-operator: deps.txt | awk -F ':' '{print $2}')
sed "s/ZENKO_OPERATOR_TAG/${OPERATOR_TAG}/" config.yaml > ${ISO_ROOT}/config.yaml
cp -R -f operator/ ${ISO_ROOT}/operator
}

function gen_product_txt()
{
cat > ${ISO_ROOT}/product.txt <<EOF
NAME=${PRODUCT_NAME}
VERSION=${VERSION_FULL}
SHORT_VERSION=${VERSION_SHORT}
GIT=${GIT_REVISION}
DEVELOPMENT_RELEASE=1
BUILD_TIMESTAMP=${BUILD_TIMESTAMP}
BUILD_HOST=${BUILD_HOST}
EOF
}

function gen_operator_yaml()
{
OPERATOR_IMAGE=$(grep /zenko-operator: deps.txt)
# we need to escape / with \/ in our sed command
sed "s/REPLACE_IMAGE/${OPERATOR_IMAGE//\//\\/}/" operator.yaml > ${ISO_ROOT}/operator/operator.yaml
}

function copy_image()
{
FULL_PATH=${IMAGES_ROOT}/${1/:/\/}
mkdir -p ${FULL_PATH}
${SKOPEO} ${SKOPEO_OPTS} copy \
--format v2s2 --dest-compress \
--src-daemon-host ${DOCKER_SOCKET} \
docker-daemon:${1} \
dir:${FULL_PATH}
}

function dedupe()
{
${HARDLINK} -c ${IMAGES_ROOT}
}

function build_iso()
{
mkisofs -output ${ISO} \
-quiet \
-rock \
-joliet \
-joliet-long \
-full-iso9660-filenames \
-volid "${PRODUCT_NAME} ${VERSION_FULL}" \
--iso-level 3 \
-gid 0 \
-uid 0 \
-input-charset iso8859-1 \
-output-charset iso8859-1 \
${ISO_ROOT}
sha256sum ${ISO} > ${ISO_ROOT}/SHA256SUM
echo ISO File at ${ISO}
echo SHA256 for ISO:
cat ${ISO_ROOT}/SHA256SUM
}

# run everything in order
clean
mkdirs
copy_yamls
gen_product_txt
gen_operator_yaml
for img in ${DEP_IMAGES[@]}; do
${DOCKER} ${DOCKER_OPTS} pull ${img}
copy_image ${img}
done
dedupe
build_iso
echo DONE
8 changes: 8 additions & 0 deletions solution/config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
apiVersion: solutions.metalk8s.scality.com/v1alpha1
kind: SolutionConfig
operator:
image:
name: zenko-operator
tag: ZENKO_OPERATOR_TAG
customApiGroups:
- zenko.scality.com
9 changes: 9 additions & 0 deletions solution/deps.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
banzaicloud/kafka-operator:v0.11.2
jimmidyson/configmap-reload:v0.3.0
pravega/zookeeper-operator:latest
quay.io/jetstack/cert-manager-controller:v0.11.0
quay.io/jetstack/cert-manager-webhook:v0.11.0
quay.io/jetstack/cert-manager-cainjector:v0.11.0
quay.io/coreos/prometheus-operator:v0.38.1
quay.io/coreos/prometheus-config-reloader:v0.38.1
registry.scality.com/sf-eng/zenko-operator:10794ca
32 changes: 32 additions & 0 deletions solution/operator.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: zenko-operator
spec:
replicas: 1
selector:
matchLabels:
name: zenko-operator
template:
metadata:
labels:
name: zenko-operator
spec:
serviceAccountName: zenko-operator
containers:
- name: zenko-operator
image: REPLACE_IMAGE
command:
- zenko-operator
imagePullPolicy: Always
env:
- name: WATCH_NAMESPACE
valueFrom:
fieldRef:
fieldPath: metadata.namespace
- name: POD_NAME
valueFrom:
fieldRef:
fieldPath: metadata.name
- name: OPERATOR_NAME
value: "zenko-operator"
168 changes: 168 additions & 0 deletions solution/operator/crds/zenko.io_zenkoconfigurationoverlays_crd.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,168 @@
apiVersion: apiextensions.k8s.io/v1beta1
kind: CustomResourceDefinition
metadata:
name: zenkoconfigurationoverlays.zenko.io
spec:
group: zenko.io
names:
kind: ZenkoConfigurationOverlay
listKind: ZenkoConfigurationOverlayList
plural: zenkoconfigurationoverlays
singular: zenkoconfigurationoverlay
scope: Namespaced
subresources:
status: {}
validation:
openAPIV3Schema:
description: ZenkoConfigurationOverlay is the Schema for the zenkoconfigurationoverlays
API
properties:
apiVersion:
description: 'APIVersion defines the versioned schema of this representation
of an object. Servers should convert recognized schemas to the latest
internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#resources'
type: string
kind:
description: 'Kind is a string value representing the REST resource this
object represents. Servers may infer this from the endpoint the client
submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#types-kinds'
type: string
metadata:
type: object
spec:
description: ZenkoConfigurationOverlaySpec defines the desired state of
ZenkoConfigurationOverlay
properties:
accounts:
items:
description: ZenkoConfigurationOverlaySpecAccount defines a top-level
tenant
properties:
accessKey:
type: string
canonicalID:
type: string
encryptedSecretKey:
type: string
encryptionKeyVersion:
format: int32
type: integer
name:
type: string
type:
type: string
type: object
type: array
blobAPI:
properties:
endpoints:
items:
description: ZenkoConfigurationOverlaySpecEndpoint defines an
endpoint
properties:
hostname:
type: string
isBuiltIn:
type: boolean
locationName:
type: string
type: object
type: array
type: object
locations:
items:
description: ZenkoConfigurationOverlaySpecLocation defines a storage
location
properties:
canonicalID:
type: string
details:
properties:
accessKey:
description: access key
type: string
bootstrapList:
description: bootstrap list
items:
type: string
type: array
bucketMatch:
description: bucket match
type: boolean
bucketName:
description: bucket name
type: string
chordCos:
description: chord cos
format: int64
type: integer
codingParts:
description: coding parts
format: int64
type: integer
dataParts:
description: data parts
format: int64
type: integer
endpoint:
description: endpoint
type: string
mpuBucketName:
description: mpu bucket name
type: string
proxyPath:
description: proxy path
type: string
region:
description: region
type: string
secretKey:
description: secret key
type: string
serverSideEncryption:
description: server side encryption
type: boolean
type: object
encryptionKeyVersion:
format: int32
type: integer
isTransient:
type: boolean
legacyAWSBehavior:
type: boolean
name:
type: string
sizeLimitGB:
format: int32
type: integer
type:
type: string
type: object
type: array
s3API:
properties:
endpoints:
items:
description: ZenkoConfigurationOverlaySpecEndpoint defines an
endpoint
properties:
hostname:
type: string
isBuiltIn:
type: boolean
locationName:
type: string
type: object
type: array
type: object
type: object
status:
description: ZenkoConfigurationOverlayStatus defines the observed state
of ZenkoConfigurationOverlay
type: object
type: object
version: v1alpha1
versions:
- name: v1alpha1
served: true
storage: true
Loading

0 comments on commit 30fa054

Please sign in to comment.