Skip to content

Commit

Permalink
Initial import
Browse files Browse the repository at this point in the history
  • Loading branch information
gilbode committed Jun 19, 2020
0 parents commit 32473bb
Show file tree
Hide file tree
Showing 118 changed files with 16,904 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
build/_output
vendor
.idea
**/*.iml
dist/**
163 changes: 163 additions & 0 deletions Jenkinsfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,163 @@
// Copyright (c) 2020, Oracle Corporation and/or its affiliates.
// Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl.

pipeline {
options {
skipDefaultCheckout true
disableConcurrentBuilds()
}

agent {
docker {
image "${RUNNER_DOCKER_IMAGE}"
args "${RUNNER_DOCKER_ARGS}"
registryUrl "${RUNNER_DOCKER_REGISTRY_URL}"
registryCredentialsId 'ocir-pull-and-push-account'
}
}

environment {
DOCKER_CI_IMAGE_NAME = 'verrazzano-monitoring-operator-jenkins'
DOCKER_PUBLISH_IMAGE_NAME = 'verrazzano-monitoring-operator'
DOCKER_IMAGE_NAME = "${env.BRANCH_NAME == 'master' ? env.DOCKER_PUBLISH_IMAGE_NAME : env.DOCKER_CI_IMAGE_NAME}"
CREATE_LATEST_TAG = "${env.BRANCH_NAME == 'master' ? '1' : '0'}"
GOPATH = '/home/opc/go'
GO_REPO_PATH = "${GOPATH}/src/github.com/oracle"
DOCKER_CREDS = credentials('ocir-pull-and-push-account')
HELM_CHART_NAME = 'verrazzano-monitoring-operator'
VMI_NAMESAPCE_PREFIX = 'vmi'
ELASTICSEARCH_VERSION = '7.2.0'
INGRESS_NODE_PORT = sh(script: "shuf -i 30000-32767 -n 1" , returnStdout: true)
KUBECONFIG = '~/.kube/config'
}

stages {
stage('Clean workspace and checkout') {
steps {
checkout scm
sh """
echo "${DOCKER_CREDS_PSW}" | docker login ${env.DOCKER_REPO} -u ${DOCKER_CREDS_USR} --password-stdin
rm -rf ${GO_REPO_PATH}/verrazzano-monitoring-operator
mkdir -p ${GO_REPO_PATH}/verrazzano-monitoring-operator
tar cf - . | (cd ${GO_REPO_PATH}/verrazzano-monitoring-operator/ ; tar xf -)
"""
}
}

stage('Build') {
when { not { buildingTag() } }
steps {
sh """
cd ${GO_REPO_PATH}/verrazzano-monitoring-operator
make push DOCKER_IMAGE_NAME=${DOCKER_IMAGE_NAME} K8S_NAMESPACE=${VMI_NAMESAPCE_PREFIX}-${env.BUILD_NUMBER} CREATE_LATEST_TAG=${CREATE_LATEST_TAG}
"""
}
}

stage('Third Party License Check') {
when { not { buildingTag() } }
steps {
sh """
cd ${GO_REPO_PATH}/verrazzano-monitoring-operator
make thirdparty-check
"""
}
}

stage('Unit Tests') {
when { not { buildingTag() } }
steps {
sh """
cd ${GO_REPO_PATH}/verrazzano-monitoring-operator
make unit-test
make -B coverage
cp coverage.html ${WORKSPACE}
build/scripts/copy-junit-output.sh ${WORKSPACE}
"""
}
post {
always {
archiveArtifacts artifacts: '**/coverage.html', allowEmptyArchive: true
junit testResults: '**/*test-result.xml', allowEmptyResults: true
}
}
}

stage('Integration Tests') {
when { not { buildingTag() } }
steps {
sh """
cd ${GO_REPO_PATH}/verrazzano-monitoring-operator
echo "To do.."
"""
}
}

stage('basic1 integ tests oke') {
when { not { buildingTag() } }
steps {
sh """
cd ${GO_REPO_PATH}/verrazzano-monitoring-operator
echo "To do.."
"""
}
}

stage('basic2 integ tests oke') {
when { not { buildingTag() } }
steps {
sh """
cd ${GO_REPO_PATH}/verrazzano-monitoring-operator
echo "To do.."
"""
}
}

stage('basic3 integ tests oke') {
when { not { buildingTag() } }
steps {
sh """
cd ${GO_REPO_PATH}/verrazzano-monitoring-operator
echo "To do.."
"""
}
}

stage('basic4 integ tests oke') {
when { not { buildingTag() } }
steps {
sh """
cd ${GO_REPO_PATH}/verrazzano-monitoring-operator
echo "To do.."
"""
}
}

stage('Scan Image') {
when { not { buildingTag() } }
steps {
clairScan "${env.DOCKER_REPO}/${env.DOCKER_NAMESPACE}/${DOCKER_CI_IMAGE_NAME}:${DOCKER_IMAGE_NAME}"
}
}

stage('Publish Image') {
when { buildingTag() }
steps {
sh """
cd ${GO_REPO_PATH}/verrazzano-monitoring-operator
make push-tag DOCKER_REPO=${env.DOCKER_REPO} DOCKER_NAMESPACE=${env.DOCKER_NAMESPACE} DOCKER_IMAGE_NAME=${env.DOCKER_PUBLISH_IMAGE_NAME}
make k8s-dist DOCKER_IMAGE_NAME=${DOCKER_PUBLISH_IMAGE_NAME} VERSION=${BRANCH_NAME} K8S_NAMESPACE=default
"""
}
}
}

post {
failure {
mail to: "${env.BUILD_NOTIFICATION_TO_EMAIL}", from: 'noreply@oracle.com',
subject: "Verrazzano: ${env.JOB_NAME} - Failed",
body: "Job Failed - \"${env.JOB_NAME}\" build: ${env.BUILD_NUMBER}\n\nView the log at:\n ${env.BUILD_URL}\n\nBlue Ocean:\n${env.RUN_DISPLAY_URL}"
}
}

}
37 changes: 37 additions & 0 deletions LICENSE.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
Copyright (c) 2020 Oracle America, Inc. and its affiliates.

The Universal Permissive License (UPL), Version 1.0

Subject to the condition set forth below, permission is hereby granted to any
person obtaining a copy of this software, associated documentation and/or data
(collectively the "Software"), free of charge and under any and all copyright
rights in the Software, and any and all patent rights owned or freely licensable
by each licensor hereunder covering either (i) the unmodified Software as
contributed to or provided by such licensor, or (ii) the Larger Works (as
defined below), to deal in both

(a) the Software, and

(b) any piece of software and/or hardware listed in the lrgrwrks.txt file if
one is included with the Software (each a ¿Larger Work¿ to which the Software
is contributed by such licensors),

without restriction, including without limitation the rights to copy, create
derivative works of, display, perform, and distribute the Software and make,
use, sell, offer for sale, import, export, have made, and have sold the
Software and the Larger Work(s), and to sublicense the foregoing rights on
either these or other terms.

This license is subject to the following condition:

The above copyright notice and either this complete permission notice or at a
minimum a reference to the UPL must be included in all copies or substantial
portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
146 changes: 146 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,146 @@
# Copyright (C) 2020, Oracle Corporation and/or its affiliates.
# Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl.
NAME:=verrazzano-monitoring-operator

DOCKER_IMAGE_NAME ?= ${NAME}-dev
TAG=$(shell git rev-parse HEAD)
VERSION = ${TAG}

CREATE_LATEST_TAG=0

ifeq ($(MAKECMDGOALS),$(filter $(MAKECMDGOALS),push push-tag))
ifndef DOCKER_REPO
$(error DOCKER_REPO must be defined as the name of the docker repository where image will be pushed)
endif
ifndef DOCKER_NAMESPACE
$(error DOCKER_NAMESPACE must be defined as the name of the docker namespace where image will be pushed)
endif
DOCKER_IMAGE_FULLNAME = ${DOCKER_REPO}/${DOCKER_NAMESPACE}/${DOCKER_IMAGE_NAME}
endif

ifdef INTEG_RUN_ID
RUN_ID_OPT=--runid=${INTEG_RUN_ID}
endif

ifdef INTEG_INGRESS
INGRESS_OPT="--ingress"
endif

DOCKER_NAMESPACE ?= verrazzano
DOCKER_REPO ?= container-registry.oracle.com
DOCKER_IMAGE_TAG ?= ${VERSION}
DIST_DIR:=dist
BIN_DIR:=${DIST_DIR}/bin
BIN_NAME:=${NAME}
K8S_EXTERNAL_IP:=localhost
K8S_NAMESPACE:=default
WATCH_NAMESPACE:=
WATCH_VMI:=
EXTRA_PARAMS=
ENV_NAME=verrazzano-monitoring-operator
INTEG_SKIP_TEARDOWN:=false
INTEG_PHASE:=""
INTEG_RUN_REGEX=Test
INGRESS_CONTROLLER_SVC_NAME:=ingress-controller
GO ?= go
HELM_CHART_NAME ?= verrazzano-monitoring-operator

.PHONY: all
all: build

BUILDVERSION=`git describe --tags`
BUILDDATE=`date +%FT%T%z`

#
# Go build related tasks
#
.PHONY: go-install
go-install:
git config core.hooksPath hooks
GO111MODULE=on $(GO) mod vendor
chmod +x vendor/k8s.io/code-generator/*.sh
sh hack/update-codegen.sh
GO111MODULE=on $(GO) install ./cmd/...

.PHONY: go-run
go-run: go-install
GO111MODULE=on $(GO) run cmd/verrazzano-monitoring-ctrl/main.go --kubeconfig=${KUBECONFIG} --v=4 --namespace=${K8S_NAMESPACE} --watchNamespace=${WATCH_NAMESPACE} --watchVmi=${WATCH_VMI} ${EXTRA_PARAMS}

.PHONY: go-fmt
go-fmt:
gofmt -s -e -d $(shell find . -name "*.go" | grep -v /vendor/)

.PHONY: go-vet
go-vet:
echo go vet $(shell go list ./... | grep -v /vendor/)

.PHONY: go-vendor
go-vendor:
glide install -v

#
# Docker-related tasks
#
.PHONY: docker-clean
docker-clean:
rm -rf ${DIST_DIR}

.PHONY: k8s-dist
k8s-dist: docker-clean
echo ${VERSION} ${JENKINS_URL} ${CI_COMMIT_TAG} ${CI_COMMIT_SHA}
echo ${DOCKER_IMAGE_NAME}
mkdir -p ${DIST_DIR}
cp -r docker-images/verrazzano-monitoring-operator/* ${DIST_DIR}
cp -r k8s/manifests/verrazzano-monitoring-operator.yaml $(DIST_DIR)/verrazzano-monitoring-operator.yaml

# Fill in Docker image and tag that's being tested
sed -i.bak "s|${DOCKER_REPO}/${DOCKER_NAMESPACE}/verrazzano-monitoring-operator:latest|${DOCKER_REPO}/${DOCKER_NAMESPACE}/${DOCKER_IMAGE_NAME}:$(DOCKER_IMAGE_TAG)|g" $(DIST_DIR)/verrazzano-monitoring-operator.yaml
sed -i.bak "s/latest/$(DOCKER_IMAGE_TAG)/g" $(DIST_DIR)/verrazzano-monitoring-operator.yaml
sed -i.bak "s/default/${K8S_NAMESPACE}/g" $(DIST_DIR)/verrazzano-monitoring-operator.yaml

rm -rf $(DIST_DIR)/verrazzano-monitoring-operator*.bak
mkdir -p ${BIN_DIR}

.PHONY: build
build: k8s-dist
docker build --pull --no-cache \
--build-arg BUILDVERSION=${BUILDVERSION} \
--build-arg BUILDDATE=${BUILDDATE} \
-t ${DOCKER_IMAGE_NAME}:${DOCKER_IMAGE_TAG} \
-f ${DIST_DIR}/Dockerfile \
.
.PHONY: push
push: build
docker tag ${DOCKER_IMAGE_NAME}:${DOCKER_IMAGE_TAG} ${DOCKER_IMAGE_FULLNAME}:${DOCKER_IMAGE_TAG}
docker push ${DOCKER_IMAGE_FULLNAME}:${DOCKER_IMAGE_TAG}

if [ "${CREATE_LATEST_TAG}" == "1" ]; then \
docker tag ${DOCKER_IMAGE_NAME}:${DOCKER_IMAGE_TAG} ${DOCKER_IMAGE_FULLNAME}:latest; \
docker push ${DOCKER_IMAGE_FULLNAME}:latest; \
fi

.PHONY: push-tag
push-tag:
docker pull ${DOCKER_IMAGE_FULLNAME}:${DOCKER_IMAGE_TAG}
docker tag ${DOCKER_IMAGE_FULLNAME}:${DOCKER_IMAGE_TAG} ${DOCKER_IMAGE_FULLNAME}:${TAG_NAME}
docker push ${DOCKER_IMAGE_FULLNAME}:${TAG_NAME}

#
# Tests-related tasks
#
.PHONY: unit-test
unit-test: go-install
GO111MODULE=on $(GO) test -v ./pkg/... ./cmd/...

.PHONY: thirdparty-check
thirdparty-check:
./build/scripts/thirdparty_check.sh

.PHONY: coverage
coverage:
./build/scripts/coverage.sh html

.PHONY: integ-test
integ-test: go-install
GO111MODULE=on $(GO) get -u github.com/oracle/oci-go-sdk
GO111MODULE=on $(GO) test -v ./test/integ/ -timeout 30m --kubeconfig=${KUBECONFIG} --externalip=${K8S_EXTERNAL_IP} --namespace=${K8S_NAMESPACE} --skipteardown=${INTEG_SKIP_TEARDOWN} --run=${INTEG_RUN_REGEX} --phase=${INTEG_PHASE} --ingressControllerSvcName=${INGRESS_CONTROLLER_SVC_NAME} ${INGRESS_OPT} ${RUN_ID_OPT}
15 changes: 15 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
[![pipeline status](https://github.com/verrazzano/verrazzano-monitoring-operator/badges/master/pipeline.svg)](https://github.com/verrazzano/verrazzano-monitoring-operator/commits/master)
[![coverage report](https://github.com/verrazzano/verrazzano-monitoring-operator/badges/master/coverage.svg)](https://github.com/verrazzano/verrazzano-monitoring-operator/commits/master)
# Verrazzano Monitoring Operator

[![build status](https://github.com/verrazzano/verrazzano-monitoring-operator/badges/master/build.svg)](https://github.com/verrazzano/verrazzano-monitoring-operator/commits/master)

The verrazzano-monitoring-operator (or VMO) is a Kubernetes operator to control the deployment and management of "Verrazzano
Monitoring Instances" (or VMIs). A VMI is a collection of telemetry components like Grafana, Prometheus, AlertManager,
Kibana, and Elasticsearch.

## [Verrazzano Integration](docs/verrazzano-integration.md)

## [Usage](docs/usage.md)

## [Development](docs/development.md)
Loading

0 comments on commit 32473bb

Please sign in to comment.