Skip to content

Commit 3d6c6b0

Browse files
authored
Merge pull request #163 from psaini79/dboperator_1.2.0_release
Added Features of Oracle DB Operator Release 1.2.0
2 parents a834cfb + b2cd9b9 commit 3d6c6b0

File tree

496 files changed

+74952
-11904
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

496 files changed

+74952
-11904
lines changed

.gitignore

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ ords/*zip
77
.gitattributes
88
.vscode
99
.gitlab-ci.yml
10-
10+
.DS_Store
1111
# development
1212
.idea
1313
.local

Dockerfile

+11-7
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,16 @@
66
ARG BUILDER_IMG
77
FROM ${BUILDER_IMG} as builder
88

9-
# Download golang if BUILD_INTERNAL is set to true
9+
ARG TARGETARCH
10+
# Download golang if INSTALL_GO is set to true
1011
ARG INSTALL_GO
1112
ARG GOLANG_VERSION
1213
RUN if [ "$INSTALL_GO" = "true" ]; then \
13-
curl -LJO https://go.dev/dl/go${GOLANG_VERSION}.linux-amd64.tar.gz &&\
14-
rm -rf /usr/local/go && tar -C /usr/local -xzf go${GOLANG_VERSION}.linux-amd64.tar.gz &&\
15-
rm go${GOLANG_VERSION}.linux-amd64.tar.gz; \
14+
echo -e "\nCurrent Arch: $(arch), Downloading Go for linux/${TARGETARCH}" &&\
15+
curl -LJO https://go.dev/dl/go${GOLANG_VERSION}.linux-${TARGETARCH}.tar.gz &&\
16+
rm -rf /usr/local/go && tar -C /usr/local -xzf go${GOLANG_VERSION}.linux-${TARGETARCH}.tar.gz &&\
17+
rm go${GOLANG_VERSION}.linux-${TARGETARCH}.tar.gz; \
18+
echo "Go Arch: $(/usr/local/go/bin/go env GOARCH)"; \
1619
fi
1720
ENV PATH=${GOLANG_VERSION:+"${PATH}:/usr/local/go/bin"}
1821

@@ -33,16 +36,17 @@ COPY LICENSE.txt LICENSE.txt
3336
COPY THIRD_PARTY_LICENSES_DOCKER.txt THIRD_PARTY_LICENSES_DOCKER.txt
3437

3538
# Build
36-
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 GO111MODULE=on go build -a -o manager main.go
39+
RUN CGO_ENABLED=0 GOOS=linux GOARCH=${TARGETARCH} GO111MODULE=on go build -a -o manager main.go
3740

38-
# Use oraclelinux:8-slim as base image to package the manager binary
39-
FROM oraclelinux:8-slim
41+
# Use oraclelinux:9 as base image to package the manager binary
42+
FROM oraclelinux:9
4043
ARG CI_COMMIT_SHA
4144
ARG CI_COMMIT_BRANCH
4245
ENV COMMIT_SHA=${CI_COMMIT_SHA} \
4346
COMMIT_BRANCH=${CI_COMMIT_BRANCH}
4447
WORKDIR /
4548
COPY --from=builder /workspace/manager .
49+
COPY ords/ords_init.sh .
4650
RUN useradd -u 1002 nonroot
4751
USER nonroot
4852

Makefile

+65-48
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#
2-
# Copyright (c) 2022, Oracle and/or its affiliates.
2+
# Copyright (c) 2025, Oracle and/or its affiliates.
33
# Licensed under the Universal Permissive License v 1.0 as shown at http://oss.oracle.com/licenses/upl.
44
#
55

@@ -18,14 +18,14 @@ BUNDLE_METADATA_OPTS ?= $(BUNDLE_CHANNELS) $(BUNDLE_DEFAULT_CHANNEL)
1818

1919
# Image URL to use all building/pushing image targets
2020
IMG ?= controller:latest
21-
# Produce CRDs that work back to Kubernetes 1.11 (no version conversion)
22-
# API version has to be v1 to use defaulting (https://github.com/kubernetes-sigs/controller-tools/issues/478)
23-
CRD_OPTIONS ?= "crd:trivialVersions=true,preserveUnknownFields=false"
21+
# Enable allowDangerousTypes to use float type in CRD
22+
# Remove the Desc to avoid YAML getting too long. See the discussion:
23+
# https://github.com/kubernetes-sigs/kubebuilder/issues/1140
24+
CRD_OPTIONS ?= "crd:maxDescLen=0,allowDangerousTypes=true"
2425
# ENVTEST_K8S_VERSION refers to the version of kubebuilder assets to be downloaded by envtest binary.
25-
ENVTEST_K8S_VERSION = 1.21
26+
ENVTEST_K8S_VERSION = 1.29.0
2627
# Operator YAML file
2728
OPERATOR_YAML=$$(basename $$(pwd)).yaml
28-
2929
# Get the currently used golang install path (in GOPATH/bin, unless GOBIN is set)
3030
ifeq (,$(shell go env GOBIN))
3131
GOBIN=$(shell go env GOPATH)/bin
@@ -40,127 +40,145 @@ SHELL = /usr/bin/env bash -o pipefail
4040
.SHELLFLAGS = -ec
4141

4242
all: build
43-
4443
##@ Development
4544

4645
manifests: controller-gen ## Generate WebhookConfiguration, ClusterRole and CustomResourceDefinition objects.
4746
$(CONTROLLER_GEN) $(CRD_OPTIONS) rbac:roleName=manager-role webhook paths="./..." output:crd:artifacts:config=config/crd/bases
48-
47+
4948
generate: controller-gen ## Generate code containing DeepCopy, DeepCopyInto, and DeepCopyObject method implementations.
5049
$(CONTROLLER_GEN) object:headerFile="hack/boilerplate.go.txt" paths="./..."
51-
50+
5251
fmt: ## Run go fmt against code.
5352
go fmt ./...
54-
53+
5554
vet: ## Run go vet against code.
5655
go vet ./...
57-
56+
5857
TEST ?= ./apis/database/v1alpha1 ./commons/... ./controllers/...
5958
test: manifests generate fmt vet envtest ## Run unit tests.
6059
KUBEBUILDER_ASSETS="$(shell $(ENVTEST) use $(ENVTEST_K8S_VERSION) -p path)" go test $(TEST) -coverprofile cover.out
61-
60+
6261
E2ETEST ?= ./test/e2e/
6362
e2e: manifests generate fmt vet envtest ## Run e2e tests.
6463
KUBEBUILDER_ASSETS="$(shell $(ENVTEST) use $(ENVTEST_K8S_VERSION) -p path)" go test $(E2ETEST) -test.timeout 0 -test.v --ginkgo.fail-fast
65-
64+
6665
##@ Build
67-
66+
6867
build: generate fmt vet ## Build manager binary.
6968
go build -o bin/manager main.go
70-
69+
7170
run: manifests generate fmt vet ## Run a controller from your host.
7271
go run ./main.go
73-
74-
GOLANG_VERSION ?= 1.21.7
72+
73+
GOLANG_VERSION ?= 1.23.3
7574
## Download golang in the Dockerfile if BUILD_INTERNAL is set to true.
7675
## Otherwise, use golang image from docker hub as the builder.
7776
ifeq ($(BUILD_INTERNAL), true)
78-
BUILDER_IMG = oraclelinux:8
77+
BUILDER_IMG = oraclelinux:9
7978
BUILD_ARGS = --build-arg BUILDER_IMG=$(BUILDER_IMG) --build-arg GOLANG_VERSION=$(GOLANG_VERSION) --build-arg INSTALL_GO=true
8079
else
8180
BUILDER_IMG = golang:$(GOLANG_VERSION)
82-
BUILD_ARGS = --build-arg BUILDER_IMG=$(BUILDER_IMG) --build-arg INSTALL_GO=false
81+
BUILD_ARGS = --build-arg BUILDER_IMG=$(BUILDER_IMG) --build-arg INSTALL_GO="false" --build-arg GOLANG_VERSION=$(GOLANG_VERSION)
82+
endif
83+
ifeq ($(BUILD_MANIFEST), true)
84+
BUILD_ARGS := $(BUILD_ARGS) --platform=linux/arm64,linux/amd64 --jobs=2 --manifest
85+
PUSH_ARGS := manifest
86+
else
87+
BUILD_ARGS := $(BUILD_ARGS) --platform=linux/amd64 --tag
8388
endif
8489
docker-build: #manifests generate fmt vet #test ## Build docker image with the manager. Disable the test but keep the validations to fail fast
8590
docker build --no-cache=true --build-arg http_proxy=$(HTTP_PROXY) --build-arg https_proxy=$(HTTPS_PROXY) \
86-
--build-arg CI_COMMIT_SHA=$(CI_COMMIT_SHA) --build-arg CI_COMMIT_BRANCH=$(CI_COMMIT_BRANCH) \
87-
$(BUILD_ARGS) . -t $(IMG)
88-
91+
--build-arg CI_COMMIT_SHA=$(CI_COMMIT_SHA) --build-arg CI_COMMIT_BRANCH=$(CI_COMMIT_BRANCH) \
92+
$(BUILD_ARGS) $(IMG) .
93+
8994
docker-push: ## Push docker image with the manager.
90-
docker push $(IMG)
95+
docker $(PUSH_ARGS) push $(IMG)
9196

92-
##@ Deployment
97+
# Push to minikube's local registry enabled by registry add-on
98+
minikube-push:
99+
docker tag $(IMG) $$(minikube ip):5000/$(IMG)
100+
docker push --tls-verify=false $$(minikube ip):5000/$(IMG)
93101

102+
##@ Deployment
103+
94104
install: manifests kustomize ## Install CRDs into the K8s cluster specified in ~/.kube/config.
95105
$(KUSTOMIZE) build config/crd | kubectl apply -f -
96-
106+
97107
uninstall: manifests kustomize ## Uninstall CRDs from the K8s cluster specified in ~/.kube/config.
98108
$(KUSTOMIZE) build config/crd | kubectl delete -f -
99-
109+
100110
deploy: manifests kustomize ## Deploy controller to the K8s cluster specified in ~/.kube/config.
101111
cd config/manager && $(KUSTOMIZE) edit set image controller=$(IMG)
102112
$(KUSTOMIZE) build config/default | kubectl apply -f -
103113

114+
minikube-deploy: minikube-operator-yaml minikube-push
115+
kubectl apply -f $(OPERATOR_YAML)
116+
104117
# Bug:34265574
105-
# Used sed to reposition the controller-manager Deployment after the certificate creation in the OPERATOR_YAML
118+
# Used sed to reposition the controller-manager Deployment after the certificate creation in the OPERATOR_YAML
106119
operator-yaml: manifests kustomize
107120
cd config/manager && $(KUSTOMIZE) edit set image controller=$(IMG)
108121
$(KUSTOMIZE) build config/default > "$(OPERATOR_YAML)"
109122
sed -i.bak -e '/^apiVersion: apps\/v1/,/---/d' "$(OPERATOR_YAML)"
110123
(echo --- && sed '/^apiVersion: apps\/v1/,/---/!d' "$(OPERATOR_YAML).bak") >> "$(OPERATOR_YAML)"
111124
rm "$(OPERATOR_YAML).bak"
112125

126+
minikube-operator-yaml: IMG:=localhost:5000/$(IMG)
127+
minikube-operator-yaml: operator-yaml
128+
sed -i.bak 's/\(replicas.\) 3/\1 1/g' "$(OPERATOR_YAML)"
129+
rm "$(OPERATOR_YAML).bak"
130+
113131
undeploy: ## Undeploy controller from the K8s cluster specified in ~/.kube/config.
114132
$(KUSTOMIZE) build config/default | kubectl delete -f -
115-
133+
116134
##@ Build Dependencies
117-
135+
118136
## Location to install dependencies to
119137
LOCALBIN ?= $(shell pwd)/bin
120138
$(LOCALBIN):
121139
mkdir -p $(LOCALBIN)
122-
140+
123141
## Tool Binaries
124142
KUSTOMIZE ?= $(LOCALBIN)/kustomize
125143
CONTROLLER_GEN ?= $(LOCALBIN)/controller-gen
126144
ENVTEST ?= $(LOCALBIN)/setup-envtest
127-
145+
128146
## Tool Versions
129-
KUSTOMIZE_VERSION ?= v3.8.7
130-
CONTROLLER_TOOLS_VERSION ?= v0.6.1
131-
147+
KUSTOMIZE_VERSION ?= v5.3.0
148+
CONTROLLER_TOOLS_VERSION ?= v0.16.5
149+
132150
KUSTOMIZE_INSTALL_SCRIPT ?= "https://raw.githubusercontent.com/kubernetes-sigs/kustomize/master/hack/install_kustomize.sh"
133151
.PHONY: kustomize
134152
kustomize: $(KUSTOMIZE) ## Download kustomize locally if necessary.
135153
$(KUSTOMIZE): $(LOCALBIN)
136154
curl -s $(KUSTOMIZE_INSTALL_SCRIPT) | bash -s -- $(subst v,,$(KUSTOMIZE_VERSION)) $(LOCALBIN)
137-
155+
138156
.PHONY: controller-gen
139157
controller-gen: $(CONTROLLER_GEN) ## Download controller-gen locally if necessary.
140158
$(CONTROLLER_GEN): $(LOCALBIN)
141159
GOBIN=$(LOCALBIN) go install sigs.k8s.io/controller-tools/cmd/controller-gen@$(CONTROLLER_TOOLS_VERSION)
142-
160+
143161
.PHONY: envtest
144162
envtest: $(ENVTEST) ## Download envtest-setup locally if necessary.
145163
$(ENVTEST): $(LOCALBIN)
146164
GOBIN=$(LOCALBIN) go install sigs.k8s.io/controller-runtime/tools/setup-envtest@latest
147-
148-
165+
166+
149167
.PHONY: bundle
150168
bundle: manifests kustomize ## Generate bundle manifests and metadata, then validate generated files.
151169
operator-sdk generate kustomize manifests -q
152170
cd config/manager && $(KUSTOMIZE) edit set image controller=$(IMG)
153171
$(KUSTOMIZE) build config/manifests | operator-sdk generate bundle -q --overwrite --version $(VERSION) $(BUNDLE_METADATA_OPTS)
154172
operator-sdk bundle validate ./bundle
155-
173+
156174
.PHONY: bundle-build
157175
bundle-build: ## Build the bundle image.
158176
docker build -f bundle.Dockerfile -t $(BUNDLE_IMG) .
159-
177+
160178
.PHONY: bundle-push
161179
bundle-push: ## Push the bundle image.
162180
$(MAKE) docker-push IMG=$(BUNDLE_IMG)
163-
181+
164182
.PHONY: opm
165183
OPM = ./bin/opm
166184
opm: ## Download opm locally if necessary.
@@ -172,33 +190,32 @@ ifeq (,$(shell which opm 2>/dev/null))
172190
OS=$(shell go env GOOS) && ARCH=$(shell go env GOARCH) && \
173191
curl -sSLo $(OPM) https://github.com/operator-framework/operator-registry/releases/download/v1.15.1/$${OS}-$${ARCH}-opm ;\
174192
chmod +x $(OPM) ;\
175-
}
193+
}
176194
else
177195
OPM = $(shell which opm)
178196
endif
179197
endif
180-
198+
181199
# A comma-separated list of bundle images (e.g. make catalog-build BUNDLE_IMGS=example.com/operator-bundle:v0.1.0,example.com/operator-bundle:v0.2.0).
182200
# These images MUST exist in a registry and be pull-able.
183201
BUNDLE_IMGS ?= $(BUNDLE_IMG)
184-
202+
185203
# The image tag given to the resulting catalog image (e.g. make catalog-build CATALOG_IMG=example.com/operator-catalog:v0.2.0).
186204
CATALOG_IMG ?= $(IMAGE_TAG_BASE)-catalog:v$(VERSION)
187-
205+
188206
# Set CATALOG_BASE_IMG to an existing catalog image tag to add $BUNDLE_IMGS to that image.
189207
ifneq ($(origin CATALOG_BASE_IMG), undefined)
190208
FROM_INDEX_OPT := --from-index $(CATALOG_BASE_IMG)
191209
endif
192-
210+
193211
# Build a catalog image by adding bundle images to an empty catalog using the operator package manager tool, 'opm'.
194212
# This recipe invokes 'opm' in 'semver' bundle add mode. For more information on add modes, see:
195213
# https://github.com/operator-framework/community-operators/blob/7f1438c/docs/packaging-operator.md#updating-your-existing-operator
196214
.PHONY: catalog-build
197215
catalog-build: opm ## Build a catalog image.
198216
$(OPM) index add --container-tool docker --mode semver --tag $(CATALOG_IMG) --bundles $(BUNDLE_IMGS) $(FROM_INDEX_OPT)
199-
217+
200218
# Push the catalog image.
201219
.PHONY: catalog-push
202220
catalog-push: ## Push a catalog image.
203221
$(MAKE) docker-push IMG=$(CATALOG_IMG)
204-

PREREQUISITES.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
## Prerequisites for Using Oracle Database Operator for Kubernetes
44

5-
Oracle Database Operator for Kubernetes (OraOperator) manages all Cloud deployments of Oracle Database, including:
5+
Oracle Database Operator for Kubernetes (`OraOperator`) manages all Cloud deployments of Oracle Database, including:
66

77
* Oracle Autonomous Database (ADB)
88
* Containerized Oracle Database Single Instance (SIDB)
@@ -19,15 +19,15 @@ To set up a Kubernetes cluster on Oracle Cloud Infrastructure:
1919
1. Create an OKE Cluster
2020
1. Provision persistent storage for data files (NFS or Block)
2121

22-
Note: You must provision persistent storage if you intend to deploy containerized databases over the OKE cluster.
22+
Note: If you intend to deploy containerized databases over the OKE cluster, then you must provision persistent storage.
2323

2424
### Prerequites for Oracle Autonomous Database (ADB)
2525

26-
If you intent to use `OraOperator` to handle Oracle Autonomous Database lifecycles, then read [Oracle Autonomous Database prerequisites](./docs/adb/ADB_PREREQUISITES.md)
26+
If you intend to use `OraOperator` to handle Oracle Autonomous Database lifecycles, then read [Oracle Autonomous Database prerequisites](./docs/adb/ADB_PREREQUISITES.md)
2727

2828
### Prerequites for Single Instance Databases (SIDB)
2929

30-
If you intent to use `OraOperator` to handle Oracle Database Single Instance lifecycles, then read [Single Instance Database Prerequisites](./docs/sidb/PREREQUISITES.md)
30+
If you intend to use `OraOperator` to handle Oracle Database Single Instance lifecycles, then read [Single Instance Database Prerequisites](./docs/sidb/PREREQUISITES.md)
3131

3232
### Prerequites for Oracle Globally Distributed Databases(GDD)
3333

0 commit comments

Comments
 (0)