Skip to content
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
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
operator.tgz
cover.out
bin
bin/*
testbin/*
onpremtest/*
ords/*zip
Expand All @@ -10,4 +11,4 @@ ords/*zip
.DS_Store
# development
.idea
.local
.local
38 changes: 38 additions & 0 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
build-operator:
stage: build
variables:
IMAGE: "$DOCKER_REPO:$CI_COMMIT_SHORT_SHA"
OP_YAML: oracle-database-operator.yaml
BUILD_INTERNAL: "true"
script:
- export GOLANG_VERSION=1.25.1
- export GOROOT=$(go${GOLANG_VERSION} env GOROOT)
- export PATH="${GOROOT}/bin:${PATH}"
- make operator-yaml IMG=$IMAGE GOLANG_VERSION=$GOLANG_VERSION
- if [ "$CI_COMMIT_BRANCH" = "master" ]; then
podman run --rm --privileged multiarch/qemu-user-static --reset -p yes;
make image-build image-push IMG="$IMAGE" BUILD_MANIFEST=true GOLANG_VERSION=$GOLANG_VERSION;
podman manifest rm "$IMAGE";
else
make image-build image-push IMG="$IMAGE" GOLANG_VERSION=$GOLANG_VERSION;
podman rmi "$IMAGE";
sed -i "s/\(replicas.\) 3/\1 1/g" ./$OP_YAML;
fi
- buildah containers -q | xargs -n1 buildah rm || true
- podman system prune -f
- curl -s --netrc-file $HOME/.netrc_gitlab $ARTIFACTORY_REPO/$CI_COMMIT_BRANCH/$OP_YAML -T ./$OP_YAML
only:
variables:
- $CI_COMMIT_MESSAGE =~ /\#run-pipeline/
- $CI_COMMIT_BRANCH =~ /master/
- $CI_MERGE_REQUEST_ID != ""
except:
variables:
- $CI_COMMIT_MESSAGE =~ /\#skip-pipeline/
- $CI_COMMIT_TAG != null

cleanup:
stage: .post
script:
- echo "Clean up downloaded binaries"
- rm -rf bin/
37 changes: 26 additions & 11 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@
#

# Build the manager binary
ARG BUILDER_IMG
FROM ${BUILDER_IMG} as builder
ARG BUILDER_IMG="oraclelinux:9"
ARG RUNNER_IMG="oraclelinux:9-slim"
FROM ${BUILDER_IMG} AS builder

ARG TARGETARCH
# Download golang if INSTALL_GO is set to true
Expand All @@ -18,35 +19,49 @@ RUN if [ "$INSTALL_GO" = "true" ]; then \
echo "Go Arch: $(/usr/local/go/bin/go env GOARCH)"; \
fi
ENV PATH=${GOLANG_VERSION:+"${PATH}:/usr/local/go/bin"}
ENV GOCACHE=/go-cache
ENV GOMODCACHE=/gomod-cache

WORKDIR /workspace
# Copy the Go Modules manifests
COPY go.mod go.mod
COPY go.sum go.sum
# cache deps before building and copying source so that we don't need to re-download as much
# and so that source changes don't invalidate our downloaded layer
RUN go mod download

# Copy the go source
COPY LICENSE.txt LICENSE.txt
COPY THIRD_PARTY_LICENSES_DOCKER.txt THIRD_PARTY_LICENSES_DOCKER.txt
COPY main.go main.go
COPY apis/ apis/
COPY controllers/ controllers/
COPY commons/ commons/
COPY LICENSE.txt LICENSE.txt
COPY THIRD_PARTY_LICENSES_DOCKER.txt THIRD_PARTY_LICENSES_DOCKER.txt
COPY controllers/ controllers/

# Build
RUN CGO_ENABLED=0 GOOS=linux GOARCH=${TARGETARCH} GO111MODULE=on go build -a -o manager main.go
RUN --mount=type=cache,target=/go-cache --mount=type=cache,target=/gomod-cache CGO_ENABLED=0 GOOS=linux GOARCH=${TARGETARCH} GO111MODULE=on go build -o manager main.go

# Use oraclelinux:9 as base image to package the manager binary
FROM oraclelinux:9
# Use oraclelinux:9-slim as default base image to package the manager binary
FROM ${RUNNER_IMG}
# Labels
# ------
LABEL "provider"="Oracle" \
"issues"="https://github.com/oracle/oracle-database-operator/issues" \
"maintainer"="paramdeep.saini@oracle.com, sanjay.singh@oracle.com, kuassi.mensah@oracle.com" \
"version"="2.0" \
"description"="DB Operator Image V2.0" \
"vendor"="Oracle Coporation" \
"release"="2.0" \
"summary"="Oracle Database Operator 2.0" \
"name"="oracle-database-operator.v2.0"
ARG CI_COMMIT_SHA
ARG CI_COMMIT_BRANCH
ENV COMMIT_SHA=${CI_COMMIT_SHA} \
COMMIT_BRANCH=${CI_COMMIT_BRANCH}
WORKDIR /
COPY --from=builder /workspace/manager .
COPY ords/ords_init.sh .
COPY ords/ords_start.sh .
COPY LICENSE.txt /licenses/
COPY THIRD_PARTY_LICENSES_DOCKER.txt /licenses/
COPY THIRD_PARTY_LICENSES.txt /licenses/
RUN useradd -u 1002 nonroot
USER nonroot

Expand Down
33 changes: 17 additions & 16 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#

# Current Operator version
VERSION ?= 0.0.1
VERSION ?= 2.0
# Default bundle image tag
BUNDLE_IMG ?= controller-bundle:$(VERSION)
# Options for 'bundle-build'
Expand All @@ -23,7 +23,7 @@ IMG ?= controller:latest
# https://github.com/kubernetes-sigs/kubebuilder/issues/1140
CRD_OPTIONS ?= "crd:maxDescLen=0,allowDangerousTypes=true"
# ENVTEST_K8S_VERSION refers to the version of kubebuilder assets to be downloaded by envtest binary.
ENVTEST_K8S_VERSION = 1.29.0
ENVTEST_K8S_VERSION = 1.31.0
# Operator YAML file
OPERATOR_YAML=$$(basename $$(pwd)).yaml
# Get the currently used golang install path (in GOPATH/bin, unless GOBIN is set)
Expand Down Expand Up @@ -70,12 +70,14 @@ build: generate fmt vet ## Build manager binary.
run: manifests generate fmt vet ## Run a controller from your host.
go run ./main.go

GOLANG_VERSION ?= 1.23.3
GOLANG_VERSION ?= 1.25.1
DOCKER ?= podman
## Download golang in the Dockerfile if BUILD_INTERNAL is set to true.
## Otherwise, use golang image from docker hub as the builder.
ifeq ($(BUILD_INTERNAL), true)
BUILDER_IMG = oraclelinux:9
BUILD_ARGS = --build-arg BUILDER_IMG=$(BUILDER_IMG) --build-arg GOLANG_VERSION=$(GOLANG_VERSION) --build-arg INSTALL_GO=true
DOCKER = podman
else
BUILDER_IMG = golang:$(GOLANG_VERSION)
BUILD_ARGS = --build-arg BUILDER_IMG=$(BUILDER_IMG) --build-arg INSTALL_GO="false" --build-arg GOLANG_VERSION=$(GOLANG_VERSION)
Expand All @@ -86,18 +88,18 @@ PUSH_ARGS := manifest
else
BUILD_ARGS := $(BUILD_ARGS) --platform=linux/amd64 --tag
endif
docker-build: #manifests generate fmt vet #test ## Build docker image with the manager. Disable the test but keep the validations to fail fast
docker build --no-cache=true --build-arg http_proxy=$(HTTP_PROXY) --build-arg https_proxy=$(HTTPS_PROXY) \
image-build: #manifests generate fmt vet #test ## Build docker image with the manager. Disable the test but keep the validations to fail fast
$(DOCKER) build --build-arg http_proxy=$(HTTP_PROXY) --build-arg https_proxy=$(HTTPS_PROXY) \
--build-arg CI_COMMIT_SHA=$(CI_COMMIT_SHA) --build-arg CI_COMMIT_BRANCH=$(CI_COMMIT_BRANCH) \
$(BUILD_ARGS) $(IMG) .
docker-push: ## Push docker image with the manager.
docker $(PUSH_ARGS) push $(IMG)

image-push: ## Push docker image with the manager.
$(DOCKER) $(PUSH_ARGS) push $(IMG)

# Push to minikube's local registry enabled by registry add-on
minikube-push:
docker tag $(IMG) $$(minikube ip):5000/$(IMG)
docker push --tls-verify=false $$(minikube ip):5000/$(IMG)
$(DOCKER) tag $(IMG) $$(minikube ip):5000/$(IMG)
$(DOCKER) push --tls-verify=false $$(minikube ip):5000/$(IMG)

##@ Deployment

Expand All @@ -123,7 +125,6 @@ operator-yaml: manifests kustomize
(echo --- && sed '/^apiVersion: apps\/v1/,/---/!d' "$(OPERATOR_YAML).bak") >> "$(OPERATOR_YAML)"
rm "$(OPERATOR_YAML).bak"

minikube-operator-yaml: IMG:=localhost:5000/$(IMG)
minikube-operator-yaml: operator-yaml
sed -i.bak 's/\(replicas.\) 3/\1 1/g' "$(OPERATOR_YAML)"
rm "$(OPERATOR_YAML).bak"
Expand All @@ -144,8 +145,8 @@ CONTROLLER_GEN ?= $(LOCALBIN)/controller-gen
ENVTEST ?= $(LOCALBIN)/setup-envtest

## Tool Versions
KUSTOMIZE_VERSION ?= v5.3.0
CONTROLLER_TOOLS_VERSION ?= v0.16.5
KUSTOMIZE_VERSION ?= v5.7.1
CONTROLLER_TOOLS_VERSION ?= v0.17

KUSTOMIZE_INSTALL_SCRIPT ?= "https://raw.githubusercontent.com/kubernetes-sigs/kustomize/master/hack/install_kustomize.sh"
.PHONY: kustomize
Expand Down Expand Up @@ -173,11 +174,11 @@ bundle: manifests kustomize ## Generate bundle manifests and metadata, then vali

.PHONY: bundle-build
bundle-build: ## Build the bundle image.
docker build -f bundle.Dockerfile -t $(BUNDLE_IMG) .
$(DOCKER) build -f bundle.Dockerfile -t $(BUNDLE_IMG) .

.PHONY: bundle-push
bundle-push: ## Push the bundle image.
$(MAKE) docker-push IMG=$(BUNDLE_IMG)
$(MAKE) image-push IMG=$(BUNDLE_IMG)

.PHONY: opm
OPM = ./bin/opm
Expand Down Expand Up @@ -218,4 +219,4 @@ catalog-build: opm ## Build a catalog image.
# Push the catalog image.
.PHONY: catalog-push
catalog-push: ## Push a catalog image.
$(MAKE) docker-push IMG=$(CATALOG_IMG)
$(MAKE) image-push IMG=$(CATALOG_IMG)
28 changes: 27 additions & 1 deletion PROJECT
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# More info: https://book.kubebuilder.io/reference/project-config.html
domain: oracle.com
layout:
- go.kubebuilder.io/v2
- go.kubebuilder.io/v4
multigroup: true
plugins:
manifests.sdk.operatorframework.io/v2: {}
Expand Down Expand Up @@ -259,4 +259,30 @@ resources:
webhooks:
conversion: true
webhookVersion: v1beta1
- api:
crdVersion: v1
namespaced: true
controller: true
domain: oracle.com
group: omlai
kind: PrivateAi
path: github.com/oracle/oracle-database-operator/api/omlai/v4
version: v4
webhooks:
defaulting: true
validation: true
webhookVersion: v1
- api:
crdVersion: v1
namespaced: true
controller: true
domain: oracle.com
group: database
kind: OracleRestart
path: github.com/oracle/oracle-database-operator/api/database/v4
version: v4
webhooks:
defaulting: true
validation: true
webhookVersion: v1
version: "3"
Loading